V_PC1 已经开启数据转发功能,
cat /proc/sys/net/ipv4/ip_forward
1
[root@firewall ~]# iptables -n -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@firewall ~]# iptables -t nat -nL
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
SNAT all -- 192.168.2.10 0.0.0.0/0 to:192.168.1.125
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
V_PC2 的信息
debian:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0
debian:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:298:9E:EB

inet addr:192.168.2.10 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fed8:9eeb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:374 errors:0 dropped:0 overruns:0 frame:0
TX packets:394 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:34434 (33.6 KiB) TX bytes:44139 (43.1 KiB)
Interrupt:169 Base address:0x2000
不才有SNAT,用MASQUEARD时是可以ping通的,也可以访问internet。在pc上抓数据包,可以看到收到报文,但pc就没有返回报文有类似的消息如下:
Num Source Address Dest Address Summary
1 192.168.1.125 192.168.1.2 ICMP:Echo(ping)request
2 192.168.1.125 192.168.1.2 ICMP:Echo(ping)request
3 192.168.1.125 192.168.1.2 ICMP:Echo(ping)request
4 192.168.1.125 192.168.1.2 ICMP:Echo(ping)request