Right now I have a PPTP VPN set up on my remote ubuntu VPS. I would like to have certain applications use the VPN to access the internet (rtorrent, irssi, among others). Currently, it is set up like this:
eth0 Link encap:Ethernet HWaddr 00:16:3e:94:38:ce inet addr:66.xxx.xxx.xxx Bcast:66.xxx.xxx.xxx Mask:255.255.255.0
eth1 Link encap:Ethernet HWaddr 00:16:3e:d7:58:a1 inet addr:10.2.0.111 Bcast:10.255.255.255 Mask:255.0.0.0
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0
ppp0 Link encap:Point-to-Point Protocol inet addr:192.168.10.244 P-t-P:192.168.9.1 Mask:255.255.255.255
Essentially, the way I've seen this issue manifest is like this.
When I run
curl --interface eth0 checkip.dyndns.com
<html><head><title>Current IP Check</title></head><body>Current IP Address: 66.xxx.xxx.xxx</body></html>
And when I run
curl --interface ppp0 checkip.dyndns.com
<html><head><title>Current IP Check</title></head><body>Current IP Address: 95.xxx.xxx.xxx</body></html>
Which is correct.
However, when I run
curl --interface 192.168.10.244 checkip.dyndns.com
it times out and I get nothing. Which doesn't seem to make any sense, as 192.168.10.244 is the IP address of ppp0, and it doesn't seem to me that it should be any different from the above command. Am I missing something? If I can get this to work in curl, I'll be able to get it to work in rtorrent and irssi as I would like as well, curl is just easier to test for this sort of thing. Are there any good starting points for tackling this problem?
EDIT: Fixed it! Here is how I did it.
First I created a new routing table:
# echo "200 vpn" >> /etc/iproute2/rt_tables
Then, I created a rule for requests sourced from my ppp0 IP address to lookup from that new table
# ip rule add from 192.168.10.244 table 200
Then, I created a rule in that table to use ppp0.
# ip route add default dev ppp0 table 200
It works perfectly! Now when I attempt the previously failing curl command:
# curl --interface 192.168.10.244 checkip.dyndns.com <html><head><title>Current IP Check</title></head><body>Current IP Address: 95.xxx.xxx.xxx</body></html>