#! /bin/sh
#以下为有关防火墙的信息:
#外部网卡:eth0
#外部上网IP地址:192.168.0.121
#外部掩码:255.255.255.0
#wifi网卡:
#内部IP:192.168.10.2
#内部子网掩码:255.255.255.0
#内部网络区号192.168.0.0/24
#设置linux系统允许ip包转发
echo "1" > /proc/sys/net/ipv4/ip_forward
#清除原设置
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X
#设置filter table默认原则
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
#启用NAT功能
iptables -t nat -A POSTROUTING -s 192.168.10.2/24 -o eth0 -j SNAT --to 192.168.0.121
#如果是ADSL,PPP等,本方法同样适用。只需要把NAT的规则稍加更改,采用IP伪装。
#iptables -t nat -A POSTROUTING -s 192.168.10.10/24 -o eth0 -j MASQUERADE
#以下为有关防火墙的信息:
#外部网卡:eth0
#外部上网IP地址:192.168.0.121
#外部掩码:255.255.255.0
#wifi网卡:
#内部IP:192.168.10.2
#内部子网掩码:255.255.255.0
#内部网络区号192.168.0.0/24
#设置linux系统允许ip包转发
echo "1" > /proc/sys/net/ipv4/ip_forward
#清除原设置
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X
#设置filter table默认原则
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
#启用NAT功能
iptables -t nat -A POSTROUTING -s 192.168.10.2/24 -o eth0 -j SNAT --to 192.168.0.121
#如果是ADSL,PPP等,本方法同样适用。只需要把NAT的规则稍加更改,采用IP伪装。
#iptables -t nat -A POSTROUTING -s 192.168.10.10/24 -o eth0 -j MASQUERADE