快捷搜索:   nginx

linux 双网卡设置 和 端口映射解决方案

0.#ifconfig
eth0      Link encap:Ethernet HWaddr 00:e0:4c:44:4c:b4
          inet addr:222.195.149.104 Bcast:222.195.149.255 Mask:255.255.255.0
          inet6 addr: fe80::2e0:4cff:fe44:4cb4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:11884 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12675 errors:0 dropped:0 overruns:0 carrier:0
          collisions:2675 txqueuelen:1000
          RX bytes:8934535 (8.5 MB) TX bytes:2848397 (2.7 MB)
          Interrupt:21 Base address:0xdc00

eth1      Link encap:Ethernet HWaddr 00:e0:4c:44:4d:81
          inet addr:192.168.1.254 Bcast:192.168.1.255 Mask:255.255.255.0
          inet6 addr: fe80::2e0:4cff:fe44:4d81/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:10858 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7789 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2548083 (2.4 MB) TX bytes:6768294 (6.4 MB)
          Interrupt:22 Base address:0xe000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 Metric:1
          RX packets:1097 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1097 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:57416 (56.0 KB) TX bytes:57416 (56.0 KB)

1.#vi /etc/rc.local
#added by yu , Mar. 4th 2009
#
-F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

#added by yu, Mar. 6th 2009
#map 6680 to 80 de 192.168.1.170
iptables -t nat -A PREROUTING -d 222.195.149.104 -p -m --dport 6680 -j DNAT --to-destination 192.168.1.170:80
iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.0.0 -d 192.168.1.170 -p tcp -m tcp --dport 80 -j SNAT --to-source 192.168.1.254
#map 6689 to 3389 de 192.168.1.170
iptables -t nat -A PREROUTING -d 222.195.149.104 -p tcp -m tcp --dport 6689 -j DNAT --to-destination 192.168.1.170:3389
iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.0.0 -d 192.168.1.170 -p tcp -m tcp --dport 3389 -j SNAT --to-source 192.168.1.254
############
exit 0

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论