内网:eth0 192.168.1.102

外网:eth1

ADsL ppp0

配置内核:

Networking  --->      
                Networking options  
---> 
                         [
*] Network packet filtering framework (Netfilter)  ---> 
                                          [
*]   Network packet filtering debugging                                                    
                                                         Core Netfilter Configuration  
---> (根据自己的需求选择相应的模块,如果不清楚,可以全部选上)                                                   
                             IP: Netfilter Configuration  
---> (根据自己的需求选择相应的模块,如果不清楚,可以全部选上)

 

安装iptables

# emerge -pv iptables

配置 /etc/sysctl.conf 在最下面增加

net.ipv4.ip_forward = 1

增加iptable规则:

iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

或
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o ppp0 -j MASQUERADE

解决msn不能登陆的问题,增加以下规则:

iptables -A FORWARD -o ppp0 -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1400:1536 -j TCPMSS --clamp-mss-to-pmtu

其他机器只要把网关设置为 192.168.1.102 就可以上网了

更多推荐