centos7_debian10_pve_设置静态路由_eth0_wlan0


centos7_debian10_pve_设置静态路由_eth0_wlan0

转载注明来源: 本文链接 来自osnosn的博客,写于 2019-12-31.

centos-6

any net 10.0.0.0/8 gw 10.0.0.1   
any net 192.168.0.0/16 gw 192.168.0.1   
  • 方法2。创建文件, /etc/sysconfig/network-scripts/routes-eth0,内容看Redhat文档。
  • 方法3。用命令 nmtui 修改、添加静态路由。

centos-7

比如网卡名称为: eth0

  • 参考【4.5. CONFIGURING STATIC ROUTES IN IFCFG FILES
  • 可以用 nmtui 配置有线连接,在eth0连接配置中,IPv4配置(IPv4 CONFIGURATION)->显示(Show)->路由(Routing),自行添加静态路由(目标/掩码,下一跳,跃点数)
  • 方法1。创建文件, /etc/sysconfig/network-scripts/routes-eth0, 内容为
10.0.0.0/8 via 10.0.0.1 dev eth0  
192.168.0.0/16 via 192.168.0.1 dev eth0  
  • 方法2。用命令 nmtui 修改、添加静态路由。

centos-8

debian-10(buster) , pve

比如网卡名称为: eth0

  • 【启用NetworkManager管理的网卡】可以用 nmtui 配置有线连接,在eth0连接配置中,IPv4配置->显示->路由,自行添加静态路由(目标/掩码,下一跳,跃点数)
  • 【没有启用NetworkManager管理的网卡】modify "/etc/network/interfaces"
    • 如果系统有route命令。在 iface eth0 inet static 后面加入类似下面这句。
      其中metric自己定义,也可以不要metric。另外 up/down 要对应。
up route add -net 10.0.0.0/8 gw 10.0.0.1 metric 50
up route add -net 192.168.0.0/16 gw 192.168.0.1 metric 50
down route add -net 10.0.0.0/8 gw 10.0.0.1
down route add -net 192.168.0.0/16 gw 192.168.0.1
    • 如果系统没有route命令,但有ip route命令。(比如PVE虚拟机系统)。在 iface eth0 inet static 后面加入类似下面这句。
      其中metric自己定义,也可以不要metric。另外 up/down 要对应。
up ip route add 10.0.0.0/8 via 10.0.0.1 proto static metric 50
up ip route add 192.168.0.0/16 via 192.168.0.1 proto static metric 50
down ip route add 10.0.0.0/8 via 10.0.0.1
down ip route add 192.168.0.0/16 via 192.168.0.1

wlan0 (wifi client)

  • 可以用 nmtui 配置无线连接,在WIFI连接配置中,IPv4配置->显示->路由,自行添加静态路由(目标/掩码,下一跳,跃点数)
  • 也可以修改 "/etc/NetworkManager/system-connections/" 目录中对应wifi的连接配置文件。
    • 在 [ipv4] 段落中加入
route1=10.0.0.0/8,10.0.0.1,50
route2=192.168.0.0/16,192.168.0.1,50

转载注明来源: 本文链接 来自osnosn的博客.


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM