Switching the default gateway via cli



  • hi there,

    I have a pfsense setup using multi WAN (2 x ADSL2) which is working pretty well.

    The only time I run into trouble is when one of my WAN connection becomes degraded due to line faults, but not degraded to the point where it fails. i.e. the line speed drops to only 2-3Mbps but ping and packet loss is still ok until under load. It doesnt happen often but I am trying to work out some sort of notification for when it does.

    I was hoping to use speedtest-cli on regular intervals and send the info via email. The only problem is, I cant control which gateway speedtest-cli uses when it performs the test.

    Since the system is able to switch the default gateway easily enough when one in the group fails, I figured there should be a command I can use via the CLI to switch them manually. I would then just run speedtest-cli twice, after each gateway swap, and email the results.

    does anyone know if it is possible to control the default gateway in this way? I had thought about just using "route add default x.x.x.x" but since the interfaces are different I didnt think it would work, and I am in a remote location from the server right now so didnt want to break it without having physical access to it :)

    any help appreciated, thanks!


  • LAYER 8 Netgate

    My VDSL:

    speedtest-cli --source 76.2.X.Y

    Retrieving speedtest.net configuration...
    Testing from CenturyLink (76.2.X.Y)...
    Retrieving speedtest.net server list...
    Selecting best server based on ping...
    Hosted by OffsiteDataSync (Las Vegas, NV) [15.98 km]: 39.691 ms
    Testing download speed................................................................................
    Download: 10.35 Mbit/s
    Testing upload speed................................................................................................
    Upload: 0.87 Mbit/s
    
    


  • Had tried this and it didnt work, but just now realised I had the gateway wrong.

    Have set up a daily email to run that script for each gateway that I have, against the same server. Works like a charm! Thanks for your help 👍