一个很让我郁闷的Iptables Masquerade!
最近装一台Linux,想偿试一下Linux下的IPtables共享上网,Eth0接内部交换机,Eth1接天威视讯(DHCP接入),然后在Linux下运行了下面的命令。#echo "1" >/pro/sys/net/ipv4/ip_forward
#iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
以为就可以通过Linux上网了,可是连接交换机上的电脑只能Ping通Eth0、Eth1的IP,请大合侠指教,感激不尽!
下面是Linux的路由表:
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.253.0 * 255.255.255.0 U 0 0 0 eth0
222.248.32.0 * 255.255.240.0 U 0 0 0 eth1
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 222.248.32.1 0.0.0.0 UG 0 0 0 eth1 执行下列命令,结果我看看:
#cat /proc/sys/net/ipv4/ip_forward
#ifconfig
#iptables-save 对不起,现在才回复您。
# cat /proc/sys/net/ipv4/ip_forward
1
# ifconfig
eth0 Link encap:EthernetHWaddr 00:0B:2F:03:2A:8D
inet addr:222.248.40.60Bcast:222.248.47.255Mask:255.255.240.0
UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
RX packets:1008966 errors:0 dropped:0 overruns:0 frame:0
TX packets:1607 errors:0 dropped:0 overruns:0 carrier:0
collisions:6 txqueuelen:100
RX bytes:61515015 (58.6 Mb)TX bytes:139396 (136.1 Kb)
Interrupt:9 Base address:0xf000
eth1 Link encap:EthernetHWaddr 00:10:5A:26:2B:98
inet addr:192.168.253.177Bcast:192.168.253.255Mask:255.255.255.0
UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
RX packets:30445 errors:0 dropped:0 overruns:0 frame:0
TX packets:1127 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2898662 (2.7 Mb)TX bytes:140959 (137.6 Kb)
Interrupt:5 Base address:0xd100
# iptables-save
# Generated by iptables-save v1.2.7a on Thu Apr 20 15:40:30 2006
*filter
:INPUT ACCEPT
:FORWARD ACCEPT
:OUTPUT ACCEPT
COMMIT
# Completed on Thu Apr 20 15:40:30 2006
# Generated by iptables-save v1.2.7a on Thu Apr 20 15:40:30 2006
*nat
:PREROUTING ACCEPT
:POSTROUTING ACCEPT
:OUTPUT ACCEPT
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Thu Apr 20 15:40:30 2006
请问,您还需要什么信息? 你把#iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE 去掉,
然后写入#iptables -t nat -A POSTROUTING -s 192.168. 253.0/24 -o eth1 --to222.248.40.60
不过,你用DHCP接入,得每次开机或者你的共网IP租用到期后,又得重新写入上面一条语句了。 用LINUX上网,我遇到的最大问题是当150多台机子同时上网的时候,连接内网的网卡老是提示繁忙。不知道楼主用的是什么网卡啊。 我用的都是3COM的
今天更让我郁闷的是,我什么都没有改动(那台Linux主机已经运行了两天了),我后面的客户端竟然可以上网了,当重启后,在运行
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth1 -j MASQURERADE
这两个命令后又不行了,真的狂晕,请大侠指点一下,谢谢 我怎么看到这么乱?
你的eth0接内网交换机,地址怎么是这个??
eth0 Link encap:Ethernet HWaddr 00:0B:2F:03:2A:8D
inet addr:222.248.40.60 Bcast:222.248.47.255 Mask:255.255.240.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1008966 errors:0 dropped:0 overruns:0 frame:0
TX packets:1607 errors:0 dropped:0 overruns:0 carrier:0
collisions:6 txqueuelen:100
RX bytes:61515015 (58.6 Mb) TX bytes:139396 (136.1 Kb)
Interrupt:9 Base address:0xf000
页:
[1]