我们可以通过命令行更改 mac 中的默认网关和接口吗
can we change default gateway and interface in mac through commandline
我们可以使用以下命令
查看MAC的默认网关和接口
route -n get default
我知道这在 linux 中是可能的
可以通过以下命令实现
route change default -interface $INTF
route change 192.168.0.0/16 -interface $INTF
但这些在 MAC 中不起作用。我的objective是更改默认网关和接口。
networksetup
实用程序应该能够执行您想要的操作。
例如,要手动设置 IP 为 192.168.100.100
、子网为 255.255.255.0
和网关为 192.168.100.1
的标准以太网接口:
networksetup -setmanual "Ethernet" 192.168.100.100 255.255.255.0 192.168.100.1
您可能还对 -setadditionalroutes
标志感兴趣。
我们可以使用以下命令
查看MAC的默认网关和接口route -n get default
我知道这在 linux 中是可能的 可以通过以下命令实现
route change default -interface $INTF
route change 192.168.0.0/16 -interface $INTF
但这些在 MAC 中不起作用。我的objective是更改默认网关和接口。
networksetup
实用程序应该能够执行您想要的操作。
例如,要手动设置 IP 为 192.168.100.100
、子网为 255.255.255.0
和网关为 192.168.100.1
的标准以太网接口:
networksetup -setmanual "Ethernet" 192.168.100.100 255.255.255.0 192.168.100.1
您可能还对 -setadditionalroutes
标志感兴趣。