LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1322|回复: 9

[求助]双网卡+hub+固定IP(校园网)在FC3下无法共享上网! (难了我4天了)

[复制链接]
发表于 2005-3-9 09:52:20 | 显示全部楼层 |阅读模式
主机(FC3)
设置如下:
(外网)eth0:
IP:218.193.33.28
Mask:255.255.255.0
网关:218.193.33.1

(内网)eth1:
IP:192.168.0.1
Mask:255.255.255.0
网关: (无)

DNS:210.34.0.14
       210.34.0.18

客户机WinXP:
IP:192.168.0.2
Mask:255.255.255.0
网关: 192.168.0.1

DNS:210.34.0.14
       210.34.0.18
主机在Windows下共享上网成功

在FC3下
客户ping 218.193.33.28成功
客户ping 192.168.0.1成功
但是无法打开WEB页

已经经过无数次的reboot了,还是没有成功,也看了Sir中的许多文章,没有详细介绍这种方案的设置方法的,希望能被详细解答,以便教育网中的其他像我一样的初学者学习


附上:
一、/etc/rc.d/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE

二、/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=Local

三、# iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere            icmp any
ACCEPT     ipv6-crypt--  anywhere             anywhere
ACCEPT     ipv6-auth--  anywhere             anywhere
ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:5353
ACCEPT     udp  --  anywhere             anywhere            udp dpt:ipp
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

四、/etc/sysctl.conf

# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

五、 /etc/sysconfig/iptables

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
发表于 2005-3-9 10:43:17 | 显示全部楼层
1、外网网关设置有问题,网关必须与机器ip地址处于相同网段;查清是网关设置错了还是掩码错了。
2、iptables -L 列表内容与/etc/sysconfig/iptables文件内容不符,前者包括下面规则:
ACCEPT all -- anywhere anywhere
后者则没有这一条。
3、在iptables规则中没有允许域名服务。
回复 支持 反对

使用道具 举报

发表于 2005-3-9 11:07:45 | 显示全部楼层
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE
你这句错了
你的外网是静态IP
在网上有很多关于iptables 的动东
还有你可以看一下RH9+squid+iptables 作的透明代理
回复 支持 反对

使用道具 举报

发表于 2005-3-9 11:19:27 | 显示全部楼层
你的内网不应该用ETH1来做网关用ETH0
正是这句话的意思
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-9 12:23:47 | 显示全部楼层
客户端的DNS是用学校给的,iprables的规则可能是后来给的,所以没有加到/etc/sysconfig/iptables里去
是不是应该把/etc/rc.d/rc.local里改成:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth1 -s 192.168.0.0/24 -j MASQUERADE
回复 支持 反对

使用道具 举报

发表于 2005-3-10 09:45:23 | 显示全部楼层
你的iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE
这句绝对没问题,redhat的防火墙很多事,最好/etc/init.d/iptables stop 之后再运行你的共享脚本。
回复 支持 反对

使用道具 举报

发表于 2005-3-10 11:36:54 | 显示全部楼层
在REDHAT的防火墙设置中将内网网卡设置为信任的。
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE改成
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j SNAT --to 218.193.33.28更好一点
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-10 15:16:44 | 显示全部楼层
不行!继续失败中.....
回复 支持 反对

使用道具 举报

发表于 2005-3-11 05:27:56 | 显示全部楼层
我还有个很好的提议 ;) ,改用Debian,既然你的网络条件好。
回复 支持 反对

使用道具 举报

发表于 2005-3-11 10:51:19 | 显示全部楼层
先把防火墙禁用看看!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表