1. 在一個interface 上綁定多個IP
# vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
------------------------------------------------------------
DEVICE=eth0:0
BOOTPROTO=none
IPADDR=140.140.140.1
NETMASK=255.255.255.0
ONBOOT=yes
------------------------------------------------------------
# service network restart
2. 開啟IP Forward的功能
# vim /etc/sysctl.conf
------------------------------------------------------------
......
net.ipv4.ip_forward = 1
net.ipv4.tcp_keepalive_time = 86400
......
------------------------------------------------------------
# sysctl -p
3. 加入iptables的NAT policy
# vim /etc/sysconfig/iptables
------------------------------------------------------------
......
*nat
:PREROUTING ACCEPT [417:47118]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# NAT Policy
-A POSTROUTING -s 192.168.1.1 -o eth0 -j SNAT --to-source 140.140.140.1
-A PREROUTING -d 140.140.140.1 -i eth0 -j DNAT --to-destination 192.168.1.1
COMMIT
......
------------------------------------------------------------
# service iptables restart
留言列表