add a permanent static route in high sierra

I'm adding a route to all 192.168.1.x ips through a gateway like so: sudo route add 192.168.1.0/24 10.0.0.2 . How do I add this route permanently in High Sierra?


I suggest to use networksetup which works persistent and also in separate network locations.

First, open your terminal of choice i.e. iTerm2.app or Terminal.app

  • list your network locations:

networksetup -listlocations

  • choose your desired network location:

sudo networksetup -switchtolocation <locationofchoice>

  • list "devices" called networkservices

networksetup -listallnetworkservices

  • list persistent routes on "device" of choice i.e. "Ethernet"

networksetup -getadditionalroutes Ethernet

  • add your route to "Ethernet"

sudo networksetup -setadditionalroutes Ethernet 192.168.1.0 255.255.255.0 10.0.0.2

  • list persistent routes on "Ethernet" again to check

networksetup -getadditionalroutes Ethernet

To see all commands:

networksetup -help or
networksetup -printcommands

Hope that helps ;)