I have Debian 8.0.0-64 running on my server, which has eth1 as the interface with the default gateway. eth0 is pointing to the internal network.
root@server:/home/user# ifconfig
eth0 Link encap:Ethernet HWaddr 06:46:7e:88:72:d7
inet addr:10.168.118.205 Bcast:10.168.118.255 Mask:255.255.255.192
inet6 addr: fe80::446:7eff:fe88:72d7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:161 errors:0 dropped:0 overruns:0 frame:0
TX packets:203 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15215 (14.8 KiB) TX bytes:79027 (77.1 KiB)
eth1 Link encap:Ethernet HWaddr 06:70:65:5f:e9:89
inet addr:167.41.133.218 Bcast:167.41.133.223 Mask:255.255.255.240
inet6 addr: fe80::470:65ff:fe5f:e989/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:697 errors:0 dropped:0 overruns:0 frame:0
TX packets:282 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:46420 (45.3 KiB) TX bytes:33486 (32.7 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:706 errors:0 dropped:0 overruns:0 frame:0
TX packets:706 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:86847 (84.8 KiB) TX bytes:86847 (84.8 KiB)
I set up a VPN (TotalVPN) connection using the following instructions: http://pptpclient.sourceforge.net/howto-debian.phtml#configure_by_hand
With pon amsterdam I can actually open a tunnel:
root@server:/home/user# pon amsterdam
root@server:/home/user# ifconfig
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.126.0.29 P-t-P:10.126.0.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1496 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:60 (60.0 B) TX bytes:66 (66.0 B)
So far so good. Now I'd love to be able to ping, e.g., google.com (ping -I ppp0 google.com) through the tunnel, without losing the possibility to use eth1 as my default interface (ping google.com). How can I setup a route or whatever needed, so that traffic (to the internet) can be going through the tunnel, if specifically asked for, i.e., by defining the interface ppp0 to be used?
Here is some information (the name of the VPN connection is amsterdam):
root@server:/home/user# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 167.41.133.209 0.0.0.0 UG 0 0 0 eth1
10.0.0.0 10.168.118.193 255.0.0.0 UG 0 0 0 eth0
10.168.118.192 0.0.0.0 255.255.255.192 U 0 0 0 eth0
161.26.0.0 10.168.118.193 255.255.0.0 UG 0 0 0 eth0
167.41.133.208 0.0.0.0 255.255.255.240 U 0 0 0 eth1
root@server:/home/user# pon amsterdam
root@server:/home/user# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 UG 0 0 0 eth1
10.0.0.0 10.168.118.193 255.0.0.0 UG 0 0 0 eth0
10.126.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
10.168.118.192 0.0.0.0 255.255.255.192 U 0 0 0 eth0
45.32.239.20 167.41.133.209 255.255.255.255 UGH 0 0 0 eth1
161.26.0.0 10.168.118.193 255.255.0.0 UG 0 0 0 eth0
167.41.133.208 0.0.0.0 255.255.255.240 U 0 0 0 eth1
root@server:/home/user# poff amsterdam
root@server:/home/user# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 167.41.133.209 0.0.0.0 UG 0 0 0 eth1
10.0.0.0 10.168.118.193 255.0.0.0 UG 0 0 0 eth0
10.168.118.192 0.0.0.0 255.255.255.192 U 0 0 0 eth0
45.32.239.20 167.41.133.209 255.255.255.255 UGH 0 0 0 eth1
161.26.0.0 10.168.118.193 255.255.0.0 UG 0 0 0 eth0
167.41.133.208 0.0.0.0 255.255.255.240 U 0 0 0 eth1
root@server:/home/user#
I found two solutions, which worked on the first view, but they really don't work (and I don't know why).
- Adding
route add default metric 10 gw $PPP_REMOTE $PPP_IFNAMEin the up-script, or - add
defaultrouteto the pptp configuration
In both cases, calling curl --interface ppp0 ifconfig.co as root works and returns the IP address of the VPN connection, but I cannot execute the command as any other non-root user. The command curl --interface eth1 ifconfig.co works fine as root or a normal user.