|
我想用ittables来带局域网共享上网,总是不行
服务端
RHEL4
两块网卡
WAN---192.168.2.180----eth0 (由DHCP获取,IP-192.168.2.180 掩码:255.255.255.0)
LAN----192.168.10.1-----eth1 (手动设置,ip:192.168.10.1 掩码:255.255.255.0)
可以浏览Web页面
客户端
Win2000
192.168.10.*
ping 服务端LAN,是通的
ping 服务端 WAN 不通
也不能上网
谢谢roamingo,是我的客户机网关没设好,在八楼写出总结
请帮忙看看,问题出在哪里,先谢谢了?
我所做的是:
1.
ip_forward打开
vi /etc/sysctl.conf 将 net.ipv4.ip_forward=1
2.
nat脚本 /etc/rc.d/nat
也执行了 chmod u+x
内容如下(这个是修改论坛上的版友的)
#!/bin/bash
# define const here
Open_ports="80" # 自己机器对外开放的端口 80 web 25 smtp 110 pop3 #
Allow_ports="53 80 20 21" # internet的数据可以进入自己机器的端口
#init
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
# The follow is comment , for make it better
# iptables -P INPUT DROP
iptables -A INPUT -i ! eth0 -j ACCEPT
# define ruler so that some data can come in.
for Port in "$Allow_ports" ; do
iptables -A INPUT -i eth0 -p tcp -sport $Port -j ACCEPT
iptables -A INPUT -i eth0 -p udp -sport $Port -j ACCEPT
for Port in "$Open_ports" ; do
iptables -A INPUT -i eth0 -p tcp -dport $Port -j ACCEPT
iptables -A INPUT -i eth0 -p udp -dport $Port -j ACCEPT
done
# This is the last ruler , it can make you firewall better
# iptables -A INPUT -i eth0 -p tcp -j REJECT --reject-with tcp-reset
# iptables -A INPUT -i eth0 -p udp -j REJECT --reject-with icmp-port-unreachable
# define NAT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.10.0/24 -j MASQUERADE
3.
修改/etc/rc.local
在最后添加/etc/rc.d/nat
4.
重启
5.
iptables -L内容:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
6.
iptables -L -t nat内容:
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 192.168.10.0/24 anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
7.
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 * 255.255.255.0 U 0 0 0 eth0
192.168.10.0 * 255.255.255.0 U 0 0 0 eth1
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 192.168.2.1 0.0.0.0 UG 0 0 0 eth0
我能想到的就这些信息 |
|