search by tags

for the user

adventures into the land of the command line

adding a persistent static route to your mac

Nooooooormally, on other linux style OSes, you just add the route into like, /etc/network/interfaces or whatever, but on a mac, how do you do it?

You can check your network interfaces.

$ networksetup -listallnetworkservices

An asterisk (*) denotes that a network service is disabled.
USB Ethernet
iPhone USB
Bluetooth PAN

You can get info on a specific interface.

$ networksetup -getinfo 'Wi-Fi'

DHCP Configuration
IP address:
Subnet mask:
Client ID:
IPv6: Automatic
IPv6 IP address: none
IPv6 Router: none
Wi-Fi ID: e9:12:7f:05:e6:24

To add a new route (you’ll need to enter your apple-id password).

$ sudo networksetup -setadditionalroutes  [  ]

$ sudo networksetup -setadditionalroutes 'Wi-Fi'

Check your new route is added.

$ networksetup -getadditionalroutes 'Wi-Fi'

Check it in a more familiar way with netstat. And there it is, second from the top.

$ netstat -nr
Routing tables

Destination        Gateway            Flags        Refs      Use   Netif Expire
default          UGSc          291        0     en0
10/24          UGSc            0        0     en0
127                UCS             2     1989     lo0          UH              9   248104     lo0