Adding a static routes in MacOS Mojave
- June 30th, 2019
- Posted in Documentation
- Write comment
To add a permanent static route in MacOS Mojave, open up a terminal session.
List all of your available network services. Services really just seem to be aliases for network interfaces.
$ sudo networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
USB-Serial Controller D
iPad USB
iPhone USB
Wi-Fi
Bluetooth PAN
Thunderbolt Bridge
You will be adding the route to a service, therefore, you will need to know which service to apply the route to.
In my case, I wanted to add the route to my wireless interface:
$ sudo networksetup -setadditionalroutes Wi-Fi network-destination destination-mask gateway-to-use
$ sudo networksetup -setadditionalroutes Wi-Fi 10.1.1.0 255.255.255.0 192.168.0.254
List all of your current routes:
$ sudo networksetup -getadditionalroutes Wi-Fi
10.1.1.0 255.255.255.0 192.168.0.254
To remove static routes from a network service just remove the parameters from the command you used to set the route:
$ sudo networksetup -setadditionalroutes Wi-Fi
No comments yet.