I've set up an OpenVPN connection with an external server.
tun0 is the interface which is used for this connection:
user@mypc:~$ ifconfig tun0
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.6 P-t-P:10.8.0.5 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
In server side, the corresponding tun0 interface has the IP address 10.8.0.1. If I ping from one to another the packets are delivered successfully.
My routing table is shown below:
user@mypc:~$ ip r s
default via 192.168.1.1 dev wlan0 proto static
10.8.0.1 via 10.8.0.5 dev tun0
10.8.0.5 dev tun0 proto kernel scope link src 10.8.0.6
169.254.0.0/16 dev wlan0 scope link metric 1000
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.4 metric 2
My purpose is to connect to the internet via VPN. All traffic must pass first from the VPN server and then to the "outside world".
My question is: How can I make the whole external traffic pass only from the tun0 interface? Is it the default gateway that I have to change? or something else?
Thank you.