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

相关推荐
张飞签名上架19 小时前
深耕全球市场:App上架iOS与Google Play全流程指南
macos·ios·cocoa·ios上架·上架·谷歌上架
DisonTangor20 小时前
Mac Studio配备1.5 TB显存——基于雷电5的远程直接内存访问技术
人工智能·macos·开源·aigc
天庭鸡腿哥20 小时前
输入序列号,可激活正版软件!
microsoft·macos·visual studio·everything
FreeBuf_1 天前
朝鲜黑客组织“传染性面试“瞄准macOS:新型“DriverFixer“窃密工具浮出水面
macos·面试·职场和发展
Zfox_2 天前
无缝穿越系统边界:节点小宝4.0如何让我的Mac/iOS像访问本地盘一样操控Windows
windows·macos·ios·节点小宝
MicJordan2 天前
macos安装Claude提示command not found
macos
坠金2 天前
mac电脑网络卡顿解决方法
macos
写点啥呢2 天前
MacOS远程桌面报错0x207解决方法
macos
CrankZ2 天前
幕译 1.7--本地字幕生成与翻译--支持macOS,Windows
macos·whisper
ashcn20012 天前
autohotkey模拟mac中英文切换和ESC切成英文(适配vim)
macos·autohotkey