Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # /usr/local/sbin/checkwan.sh
- ###################################
- #!/bin/sh
- gatewayIP=$(netstat -4rn | grep default | awk '{print $2}')
- wanInterface="igb1"
- echo "Gateway: $gatewayIP"
- echo "WAN Interface: $wanInterface"
- if [ -z $gatewayIP ]
- then
- echo "NO Gateway"
- #Bring the interface down then up to renew the WAN DHCP
- ifconfig $wanInterface down
- ifconfig $wanInterface up
- else
- # if return = 0 then host is reachable
- ping -c 1 $gatewayIP > /dev/null
- if [ $? -eq 0 ]
- then
- echo "Gateway Reachable"
- else
- echo "Gateway Unreachable"
- #Bring the interface down then up to renew the WAN DHCP
- ifconfig $wanInterface down
- ifconfig $wanInterface up
- fi
- fi
- ######################################
- #/usr/local/opnsense/service/conf/actions.d/actions_checkwan.conf
- #####################################
- [load]
- command:/usr/local/sbin/checkwan.sh
- parameters:%s
- type:script
- description:Check WAN Interface for IP and reset if none
- message:Resetting WAN Interface for DHCP retrieval
Add Comment
Please, Sign In to add comment