兩個eth,一個作WAN,一個做LAN

前提: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========

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章