pfSense - WAN IP on diferent subnet than default Gateway
(tested on pfSense (2.1.5-RELEASE (i386))
(my pfSense Forum post about this)
- install Package Shellcmd to run the following comands on reboot (add static route to WAN)
- route add -net <GATEWAY IP /32> -iface <YOUR_INTERFACE_NAME> (ex ->bge0)
- route add default <GATEWAY IP>
- install package Cron and run the follwing script
(adjust IP's Directories to your personal situation)
----------------------------------------------------------------------
#!/bin/sh
# Script name - my_rewrite_routes.sh
# DEZ 2014 - Jose Luis - jluis144@hotmail.com
#
# used to rewrite routes on pfSense when default Gateway not in same subnet of WAN IP
# run with Cron
#
# 2.1.5-RELEASE (i386)
# built on Mon Aug 25 07:44:26 EDT 2014
# FreeBSD 8.3-RELEASE-p16
myDATE='date'
# Get current WAN IP
myNEWWANIP='/sbin/ifconfig bge0 grep "inet" awk '{print $2}''
# Get last WAN IP
read myLASTWANIP < /tmp/.mylastwanip.txt
echo "myNEWWANIP : $myNEWWANIP"
echo "myLASTWANIP : $myLASTWANIP"
if [ "$myNEWWANIP" != "$myLASTWANIP" ]
then
# Update Routes
route add -net <GATEWAY IP>/32 -iface <INTERFACE NAME>
route add default <GATEWAY IP>
# Update current IP helper file / pdate log file
echo "$myNEWWANIP" > /tmp/.mylastwanip.txt
echo "$myDATE - $myNEWWANIP" >> /tmp/.mylastwanip_log.txt
fi
----------------------------------------------------------------------
- Posted on 14 August, 2017
- by Administrator