基本命令
# 添加默認路由
sudo route add -net 0.0.0.0 192.168.191.1
# 删除默認路由
sudo route -n delete default 192.168.191.1
# 獲取默認路由
sudo route get 0.0.0.0
# 添加普通路由
sudo route -n add -net 10.1.0.0/16 192.168.0.1
# 删除普通路由
sudo route delete -net 10.1.0.0/16 192.168.0.1
# 查看路由表
netstat -rn
- 查看網卡
networksetup -listallnetworkservices
- 查看網卡配置的路由
networksetup -getadditionalroutes [網卡]
- networksetup -setadditionalroutes [網卡] [目标IP] [掩碼] [網關IP]
networksetup -setadditionalroutes ethernet 10.1.0.0 255.255.0.0 172.168.0.1
- 多條路由同時配置
networksetup -setadditionalroutes ethernet 10.1.0.0 255.255.0.0 172.168.0.1 10.2.0.0 255.255.0.0 192.168.1.1