Hello everyone! I have a need to route the WAN IP to a LAN port and at the same time still use the NAT IPs.
The script I found does work on Shibby Tomato but the VLANs don't work for the ISP. Also tried DD-WRT, but it won't work with the ISP either. And... I have also tested that google project firmware (Padavan) but it just keeps locking up. So, here I am The VLAN on Merlin does work, yeah! But does this script?? Please see the script below. Not sure if the ports are named the same or have the same order or if the firmware is based on the same version of Linux. Any help, Ideas??? Asus RT-AC66U.
#!/bin/sh -x
WIF=$(nvram get wan_iface)
WIP=$(nvram get wan_ipaddr)
WNM=$(nvram get wan_netmask)
WGW=$(nvram get wan_gateway)
LIF=$(nvram get lan_ifname)
LIP=$(nvram get lan_ipaddr)
LNM=$(nvram get lan_netmask)
IFCONFIG=/sbin/ifconfig
ROUTE=/sbin/route
IPTABLES=/usr/sbin/iptables
# remove WAN IF IP
$IFCONFIG $WIF 0.0.0.0 up
# replace default route to Gateway through WIF
$ROUTE add -host $WGW dev $WIF
$ROUTE add default gw $WGW
# add route to WAN IP through LAN iface
$ROUTE add -host $WIP dev $LIF
# enable proxy_arp so can use WGW s gateway on LAN device
echo "1" >/proc/sys/net/ipv4/conf/$WIF/proxy_arp
echo "1" >/proc/sys/net/ipv4/conf/$LIF/proxy_arp
# replace MASQ on WIF with SNAT
$IPTABLES -t nat -D POSTROUTING -o $WIF -j MASQUERADE
$IPTABLES -t nat -I POSTROUTING -s $LIP/$LNM -o $WIF -j SNAT --to-source $WIP
# add a bit of extra firewall
$IPTABLES -t nat -I PREROUTING -i $WIF -d ! $WIP -j DROP
The script I found does work on Shibby Tomato but the VLANs don't work for the ISP. Also tried DD-WRT, but it won't work with the ISP either. And... I have also tested that google project firmware (Padavan) but it just keeps locking up. So, here I am The VLAN on Merlin does work, yeah! But does this script?? Please see the script below. Not sure if the ports are named the same or have the same order or if the firmware is based on the same version of Linux. Any help, Ideas??? Asus RT-AC66U.
#!/bin/sh -x
WIF=$(nvram get wan_iface)
WIP=$(nvram get wan_ipaddr)
WNM=$(nvram get wan_netmask)
WGW=$(nvram get wan_gateway)
LIF=$(nvram get lan_ifname)
LIP=$(nvram get lan_ipaddr)
LNM=$(nvram get lan_netmask)
IFCONFIG=/sbin/ifconfig
ROUTE=/sbin/route
IPTABLES=/usr/sbin/iptables
# remove WAN IF IP
$IFCONFIG $WIF 0.0.0.0 up
# replace default route to Gateway through WIF
$ROUTE add -host $WGW dev $WIF
$ROUTE add default gw $WGW
# add route to WAN IP through LAN iface
$ROUTE add -host $WIP dev $LIF
# enable proxy_arp so can use WGW s gateway on LAN device
echo "1" >/proc/sys/net/ipv4/conf/$WIF/proxy_arp
echo "1" >/proc/sys/net/ipv4/conf/$LIF/proxy_arp
# replace MASQ on WIF with SNAT
$IPTABLES -t nat -D POSTROUTING -o $WIF -j MASQUERADE
$IPTABLES -t nat -I POSTROUTING -s $LIP/$LNM -o $WIF -j SNAT --to-source $WIP
# add a bit of extra firewall
$IPTABLES -t nat -I PREROUTING -i $WIF -d ! $WIP -j DROP