Mac设置内外网同时用

1 查看网卡名称列表
networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
宿舍
外网
内网
USB2.0-Ser!
USB 10/100 LAN
USB 10/100 LAN 2
Bluetooth PAN
Thunderbolt Bridge
2 指定网卡名称添加永久路由
使用无线的时候偏好设置添加完ip之后,还需要在网卡上加一下路由
networksetup -setadditionalroutes “外网” 10.36.0.0 255.252.0.0 192.168.16.1

networksetup -setadditionalroutes “内网” 10.40.0.0 255.255.0.0 192.168.16.1
networksetup -setadditionalroutes “内网” 10.32.0.0 255.255.0.0 192.168.16.1
networksetup -setadditionalroutes “内网” 10.32.0.0 255.240.0.0 192.168.16.1

使用有线的时候偏好设置添加完ip之后,还需要在网卡上加一下路由
networksetup -setadditionalroutes “USB 10/100 LAN” 10.36.0.0 255.252.0.0 192.168.16.1

networksetup -setadditionalroutes “USB 10/100 LAN 2” 10.40.0.0 255.255.0.0 192.168.16.1

3 查看已添加的永久路由
networksetup -getadditionalroutes Wi-Fi
networksetup -getadditionalroutes “USB 10/100 LAN 2”
10.40.0.0 255.255.0.0 192.168.16.1

4 清空网卡的永久路由
networksetup -setadditionalroutes
5、删除和添加临时路由
sudo su 进root
Password:
sudo route -v delete -net 10.36/14 -gateway 192.168.16.1
sudo route -v add -net 10.36/14 -gateway 192.168.16.1
sudo route -n delete -net 10.36.0.0 -netmask 255.252.0.0 192.168.16.1

你可能感兴趣的:(系统,mac)