- Find the name of the network adapters
# List network interface name
networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
USB 10/100/1000 LAN
Wi-Fi
Thunderbolt Bridge
# List network interface name with number
networksetup -listnetworkserviceorder
An asterisk (*) denotes that a network service is disabled.
(1) USB 10/100/1000 LAN
(Hardware Port: USB 10/100/1000 LAN, Device: en7)
(2) Wi-Fi
(Hardware Port: Wi-Fi, Device: en0)
(3) Thunderbolt Bridge
(Hardware Port: Thunderbolt Bridge, Device: bridge0)
# usage
networksetup -setadditionalroutes <networkservice> [ <dest> <mask> <gateway> ]
# adding network route 198.18.0.0/16 with gateway 192.168.1.130
networksetup -setadditionalroutes "Wi-Fi" 198.18.0.0 255.255.0.0 192.168.1.130
# validating the route is installed
netstat -rn | grep 198.18.0.0
198.18.0/16 192.168.1.130 UGSc en0
# To remove permanent route
sudo networksetup -setadditionalroutes <interface-name>