Networking newbie. I have two interfaces on the host:
tun0 from my OpenVPN client. The IP addresses are:
eth0 192.168.1.22 tun0 10.1.0.8
For outgoing traffic by changing the destination address to that of
tun0 will it force it to use the vpn?
No, but using gateway address for tun0 does. Tested with the following:
iptables -t nat -N VPN iptables -t nat -I OUTPUT -j VPN iptables -t nat -A VPN -p tcp -j DNAT --to-destination 10.1.0.170
10.1.0.170 was the gateway address for VPN (found using
- The above example creates a NEW (
-N) chain for the nat table (
- The jump to the VPN chain is from
OUT(straight after local app). Using insert (
-I) to supersede other rules in OUT.
- It's implied that for traffic originating from any source change destination to gateway of
For outbound traffic is the destination address the IP address of the interface
eth0 or is it the gateway address?
eth0 is default interface/gateway.
For traffic generated from local app what is the source address?
Can this be solved purely by iptables or do I need to modify the routing table? As both interfaces are on the same host (i.e. same debian box).
I'm trying to understand the principles so I can apply it to my case. There are three I address subnets in total, the third is in the range 172.17.42.1/16 associated with another virtual interface
Essentially I want to direct traffic from just 172.17.42.8 via the VPN.