在 A 局域网环境中, 一台服务器使用 VPN 技术拨通了 B 局域网的一台服务器. 如果需要实现 A 局域网的所有服务器到 B 局域网通信, 那么首先需要实现 A 局域网中 VPN(隧道) 服务器的流量转发
防火墙操作
| 1
 | $ iptables-save > /etc/iptables-script
 | 
| 1
 | $ iptables-restore < /etc/iptables-script
 | 
转发流量的防火墙规则
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 | $ cat iptables.conf
 
 *nat
 :PREROUTING ACCEPT [75958158:4710517785]
 :INPUT ACCEPT [11156433:697999260]
 :OUTPUT ACCEPT [11270560:679018758]
 :POSTROUTING ACCEPT [0:0]
 -A POSTROUTING -j MASQUERADE
 COMMIT
 
 
 *filter
 :INPUT ACCEPT [1937717187:1020106795408]
 :FORWARD ACCEPT [2772458722:1915560771769]
 :OUTPUT ACCEPT [2100892309:1998825790936]
 COMMIT
 
 
 | 
| 1
 | $ iptables-restore < iptables.conf
 | 
开启网卡转发
| 1
 | echo 1 > /proc/sys/net/ipv4/ip_forward
 |