分类: LINUX
2009-07-11 13:51:49
主机A:192.168.2.126
主机B:192.168.2.226
在主机A上配置:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING –i eth0 -d 192.168.2.126 --dport 80 -p tcp -j DNAT --to-destination 192.168.2.226:80
iptables -t nat -A POSTROUTING -d 192.168.2.226 -p tcp -m tcp --dport 80 -j SNAT --to-source 192.168.1.126
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
iptables -A FORWARD -o eth0 -d 192.168.2.226 -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -i eth0 -s 192.168.2.226 -p tcp --sport 80 -j ACCEPT