基本命令
# 添加默认路由
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