My goal is to run openvpn on an Ubuntu VPS which I connect to via ssh.
This is the ifconfig, where a.a.a.a is the VPS public ip address
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:16436 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1628 (1.6 KB) TX bytes:1628 (1.6 KB)
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.2 P-t-P:127.0.0.2 Bcast:0.0.0.0 Mask:255.255.255.255
inet6 addr: a:a:a:a/128 Scope:Global
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:232635 errors:0 dropped:0 overruns:0 frame:0
TX packets:146713 errors:0 dropped:1 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:297637823 (297.6 MB) TX bytes:12683192 (12.6 MB)
venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:a.a.a.a P-t-P:a.a.a.a Bcast:a.a.a.a Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
Before running Openvpn, the routing table was
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default * 0.0.0.0 UG 0 0 0 venet0
But I need to access the VPS via ssh while VPN is running, so I added my local machine's public ip (b.b.b.b) to the routing table
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
b.b.b.b 127.0.0.2 255.255.255.255 UGH 0 0 0 venet0
default * 0.0.0.0 UG 0 0 0 venet0
Then I noticed Openvpn won't start properly with the default gateway set to *, so I set it to 127.0.0.2.
This is the routing table after OpenVpn properly initialized and running
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
b.b.b.b 127.0.0.2 255.255.255.255 UGH 0 0 0 venet0
45.76.23.66.vul 127.0.0.2 255.255.255.255 UGH 0 0 0 venet0
10.8.0.0 * 255.255.255.0 U 0 0 0 tun0
default 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
128.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
default 127.0.0.2 0.0.0.0 UG 0 0 0 venet0
I am not sure why the SECOND entry is like that (45.76.23.66.vul), but 45.76.23.66 is the openvpn server's ip.
After it is running, I first find DNS resolving is not working, so I set /etc/resolv.conf to 8.8.8.8 and 8.8.4.4, DNS worked. But the whole out goning traffic is not going through the tunnel, all servers out there still see my VPS as a.a.a.a, not 45.76.23.66.
Any suggestions please? Thank you