We can see default gateway and interface of MAC by using following command
route -n get default
I know that this is possible in linux and can be achieved by following commands
route change default -interface $INTF
route change 192.168.0.0/16 -interface $INTF
But these are not working in MAC. My objective is to change the Default Gateway and interface.
The networksetup
utility should be able to do what you want.
For example, to manually set up the standard Ethernet interface with an IP of 192.168.100.100
, subnet of 255.255.255.0
and gateway of 192.168.100.1
:
networksetup -setmanual "Ethernet" 192.168.100.100 255.255.255.0 192.168.100.1
You might also be interested in the -setadditionalroutes
flag.