openwrt转发光猫

openwrt 防火墙 自定义规则

192.168.100.1 是光猫地址

1
2
3
4
5
6
7
MODEMIP=192.168.100.1
MODEM_NET=`echo $MODEMIP | cut -d "." -f 1-3`
ROUTER_WAN_PORT_IP=192.168.100.2
WAN_PORT=eth0.2
ifconfig $WAN_PORT $ROUTER_WAN_PORT_IP netmask 255.255.255.0 broadcast $MODEM_NET.255
iptables -A forwarding_rule -d $MODEMIP -j ACCEPT
iptables -t nat -A postrouting_rule -d $MODEMIP -o $WAN_PORT -j MASQUERADE
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus