เป็นการ Nat โดยมี L3 คั่น แล้ว ทำ routing เข้า gateway โดย Linux3 จะเป็นตัวที่ถูก nat และทำ Nat บน Linux1 โดย linux2 จะทำ default route ไปที่ Linux 1 และ linux3 จะทำ default ไปที่ Linux2
[route1]
ip route add 10.0.2.0/24 via 10.0.1.2
net.ipv4.conf.default.rp_filter = 0
net.ipv4.ip_forward = 1
[route2]
net.ipv4.conf.default.rp_filter = 0
net.ipv4.ip_forward = 1
[route3]
[root@route3 html]# ping 10.0.1.1
PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data.
64 bytes from 10.0.1.1: icmp_seq=1 ttl=63 time=1.25 ms
[route3]eth1 -10.0.2.x- eth2[route2]eth1 -10.0.1.x- eth1[route1]eth0 -192.168.213.x- <public>
### Case1. SOURCE NAT
[route3]
%ping 8.8.8.8
8 packets transmitted, 0 received, 100% packet loss, time 7964ms
Source NAT.
[route1]
% iptables -t nat -A POSTROUTING -s 10.0.2.3 -o eth0 -j SNAT –to 192.168.213.81
[root@route3 ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=42 time=32.4 ms
route3 out by ip 192.168.213.81
### Case2. DNAT.
[route1]
% ip addr add 192.168.213.82 brd 192.168.213.127
iptables -t nat -A PREROUTING -p tcp -d 192.168.213.82 –dport 80 -i eth0 -j DNAT –to 10.0.2.3:80
iptables -t nat -A PREROUTING -p tcp -d 192.168.213.82 –dport 22 -i eth0 -j DNAT –to 10.0.2.3:22
On ther client.
$ curl 192.168.213.82
iam route3 ip 10.0.2.3
$ ssh root@192.168.213.82
root@192.168.213.82′s password:
Last login: Mon Nov 7 15:13:32 2016 from 10.0.1.1
[root@route3 ~]#