前提:linux系统,两个网卡,分别是eth0/eth1,其中eth0做wan口,eth1做lan口;
一:wan口配置:
(eth0)自动获得ip: udhcpc -i eth0
# udhcpc -i eth0
udhcpc: started, v1.29.3
udhcpc: sending discover
udhcpc: sending select for 192.168.0.89
udhcpc: lease of 192.168.0.89 obtained, lease time 7200
deleting routers
adding dns 202.96.134.133
adding dns 202.96.128.86
lan 作网关(eth1):
ifup_lan.sh ./udhcpd.conf
============ifup_lan.sh start========
#/bin/sh
killall udhcpd
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -s 192.168.1.1/24 -j ACCEPT
iptables -A FORWARD -d 192.168.1.1/24 -j ACCEPT
ifconfig eth1 192.168.1.1
udhcpd ./udhcpd.conf
echo "==========follow ap6181"
exit 0
============ifup_lan.sh end========
============udhcpd.conf start========
# the start and end of the IP lease block
start 192.168.1.10
end 192.168.1.254
# the interface that udhcpd will use
interface eth1
option subnet 255.255.255.0
opt router 192.168.1.1
opt dns 114.114.114.114 8.8.8.8
option domain local
option lease 864000
============udhcpd.conf end========