As a revision to my earlier post on the matter, here’s a better constructed way to achieve the same effect with a little more accuracy.
Here’s a diagram of the approximate topology that this will cater to:
I shall assert the following facts:
- The “ISP’s Router” is IP address 220.127.116.11
- The DSL model is IP address 18.104.22.168
- The source interface that connects to the ISP router is FastEthernet0/0
- There is an SMTP server that this router has permission to send via at 22.214.171.124
- Your e-mail address is firstname.lastname@example.org
First we use “track” to create 2 track entries to do route tracking. The first defines a “reachability” track which will be used to monitor for and perform actions on the failure of the primary route. This also delays the actions it performs on failure and restore by 20 and 60 seconds respectively to negate the effect of temporary blips. The second is a stub which allows us to take the secondary route up or down.
- track 1 rtr 123 reachability
- delay down 20 up 60
- track 2 stub-object
- default-state down
Next we add the routes. There’s 2 default gateways added, each associated with the track entries. There is also a route to ensure that all traffic to the “ISP’s Router” is sent out of the fa0/0 interface. This is for monitoring.
- ip route 0.0.0.0 0.0.0.0 126.96.36.199 name FIBRE track 1
- ip route 0.0.0.0 0.0.0.0 188.8.131.52 254 name ADSL_BACKUP track 2
- ip route 184.108.40.206 255.255.255.255 FastEthernet0/0
Now we use ip sla to provide the details for our reachability track regarding what it should test. In this case, it pings the “ISP’s Router” every 4 seconds:
- ip sla 123
- icmp-echo 220.127.116.11 source-interface FastEthernet0/0
- timeout 2000
- frequency 4
- ip sla schedule 123 life forever start-time now
Finally we add some event handling to perform some actions on the failure and restore of the primary line. These bring up the second route and e-mail you a notification:
- event manager applet TRACK-1-TIMEOUT
- event track 1 state down
- action 1.0 track set 2 state up
- action 1.1 mail server "18.104.22.168" to "email@example.com" from "firstname.lastname@example.org" subject "IP SLA 123 Timeout" body "Timeout on the primary line"
- event manager applet TRACK-1-OK
- event track 1 state up
- action 1.0 track set 2 state down
- action 1.1 mail server "22.214.171.124" to "email@example.com" from "firstname.lastname@example.org" subject "IP SLA 123 Restored" body "Primary line restored"
That’s largely it. It contrasts with my earlier post in such that it ignores the effect of temporary blips in the line and also sends e-mail notifications.
When a router’s next hop gateway is in the same subnet as the previous hop, it’ll send an ICMPWikipedia: The Internet Control Message Protocol (ICMP) is a supporting protocol in the Internet protocol suite. It is used by network devices, including routers, to send error messages and operational informati... redirect to the previous router in order to cut itself out of the routing. In some setups, this may not be desirable.
To disable this on pfSense, go to System->Advanced and change to the System Tunables tab. Edit net.inet.ip.redirect and/or net.inet6.ip6.redirect to change their values to 0 (zero).