mac上添加路由配置

前言

特殊场景下,需要添加网络的路由

操作

在 Mac 上,可以使用 route 命令来添加静态路由。命令格式如下:

shell 复制代码
sudo route add -net [目标网络] -netmask [子网掩码] -interface [网络接口] -gateway [网关IP]

例如在linux服务器上 添加 路由配置

shell 复制代码
ip route add 10.233.12.0/18 via 192.168.10.100

在 Mac 上的等价命令为:

shell 复制代码
sudo route add -net 10.233.12.0 -netmask 255.255.192.0 -interface [网络接口] -gateway 192.168.10.100

其中 [网络接口] 需要替换为你的实际网络接口名称,可以使用 networksetup -listallhardwareports 命令查看。通常情况下,有线网络接口名为 en0,无线网络接口名为 en1。

例如,如果你要通过有线网络接口 en0 添加上述两条路由,命令应该是:

shell 复制代码
sudo route add -net 10.233.12.0 -netmask 255.255.192.0 -interface en0 -gateway 192.168.10.100

添加完成后,你可以使用 netstat -rn 命令查看路由表,确认路由已经添加成功。

需要注意的是,这些路由是临时的,重启系统后会丢失。如果你需要永久保存路由,可以将这些命令添加到 /etc/rc.local 文件中,该文件在系统启动时会自动执行。


the end !!!

good day !!!

相关推荐
**K7 小时前
how to use Xcode
ide·macos·xcode
石兴稳8 小时前
MacOS 安装 mtr 网络检测工具
macos
云储储8 小时前
植物大战僵尸融合嫁接版 MAC 版本下载安装详细教程
游戏·macos·mac·pvz·mac游戏·植物大战僵尸融合嫁接版
2401_855299218 小时前
mac鼠标键盘共享:ShareMouse for Mac 激活版
macos
南国之风8 小时前
macOS使用Karabiner-Elements解决罗技鼠标G304连击、单击变双击的故障
macos·鼠标·罗技·g304
西西o8 小时前
mac中文件夹怎么显示.git隐藏文件
git·macos
TPBoreas8 小时前
Mac批量替换文件夹下所有文件内容
macos
Mac@分享吧8 小时前
GoLand 2024 for Mac GO语言集成开发工具环境
macos·go·go语言·goland·go语言开发工具
蚁景网络安全21 小时前
MacOS BurpSuite安装指南
macos·网络安全
whatever who cares1 天前
MacOS抹掉重装步骤
macos