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 !!!

相关推荐
OliverQiu36 分钟前
开源一个 macOS 小工具:集中管理 ChatGPT 的网络启动配置
macos·chatgpt·swiftui·mac·proxy·codex·dmg
wangDer_me10 小时前
将mac电脑变成一个虚拟打印机
macos·电脑
加载力科技20 小时前
Mac 打开 ISO 文件完整教程:3 种方法挂载与解压,挂载失败也能提取文件
macos·命令模式·磁盘工具·mac打开iso·hdiutil·iso解压·mac技巧
Web Security Loop20 小时前
MAC安装最新Burpsuite pro详细步骤教程
web安全·macos·网络安全·安全性测试
Raspberry_Pi_官方账号21 小时前
Raspberry Pi Desktop 全面升级,现已登陆 PC 和 Mac
服务器·网络·macos·树莓派·raspberry pi·raspberrypios
king135987455021 小时前
EmbeddingGemma 2 270M 实测:Mac CPU、PDF/Word、256d 与 FTS5
macos·pdf·word
Patrick在香港1 天前
同一份脚本,mac 正常 Windows 乱码:open() 默认编码实测(附 3.15 终局)
utf-8·windows·python·macos·跨平台·编码·标准库
DevLoom_1 天前
Mac装NTFS for Mac,不用修改 SIP 安全设置也能正常读写NTFS硬盘
macos·macos 27·mac读写ntfs·ntfs for mac·mac应用
Laurie三省1 天前
现场版却配上录音室版的歌词?聊聊我给开源 Mac 歌词软件写的多源打分算法
算法·macos·go
David@1 天前
Mac中cursor怎么检查更新
macos