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

相关推荐
aosky1 天前
手机远程畅玩OpenAI Codex
macos·智能手机·cocoa
A懿轩A1 天前
【2026 最新】Python 下载与安装:在 macOS 下使用 Homebrew 和 pyenv 完美管理多版本 Python
python·macos·mac
IKaros_α‌1 天前
mac上安装openclaw从入门到删除
macos
x-cmd1 天前
macOS 内存模型深度解析 | x free 设计哲学
linux·macos·内存·策略模式·free·x-cmd
小李云雾1 天前
Python Web 路由详解:核心知识点全覆盖
开发语言·前端·python·路由
itinymeng1 天前
在 macOS 上遇到 brew: command not found 错误,通常是因为 ‌Homebrew 未安装‌ 或 ‌PATH 环境变量未正确配置‌
macos
oscar9991 天前
Claude Code 的“计算机使用”功能:让命令行助手真正操控macOS桌面
macos·claude code·computer
克莱因3581 天前
思科 单区域OSPF(1
网络·路由·思科
zs宝来了2 天前
ShardingSphere 分库分表原理:SQL 解析与路由
shardingsphere·分库分表·路由·sql解析
老兵发新帖2 天前
软件开发国内常用镜像源配置及回退方法(MAC版)
macos·软件工程