迅维网
标题: centos7_debian10_设置静态路由_eth0_wlan0 [打印本页]
作者: u1458515 时间: 2022-9-26 18:01
标题: centos7_debian10_设置静态路由_eth0_wlan0
本帖最后由 u1458515 于 2022-9-26 18:04 编辑
centos-7eth0- 可以用 nmtui 配置有线连接,在eth0连接配置中,IPv4配置(IPv4 CONFIGURATION)->显示(Show)->路由(Routing),自行添加静态路由(目标/掩码,下一跳,跃点数)
- 创建文件, "/etc/sysconfig/static-routes", 内容为
- any net 10.0.0.0/8 gw 10.0.0.1
- any net 192.168.0.0/16 gw 192.168.0.1
复制代码
debian-10(buster)
eth0- 可以用 nmtui 配置有线连接,在eth0连接配置中,IPv4配置->显示->路由,自行添加静态路由(目标/掩码,下一跳,跃点数)
- 或者,modify "/etc/network/interfaces"
- 在 iface eth0 inet static 后面加入类似下面这句。其中metric自己定义,也可以不要metric。
- up ip route add 10.0.0.0/8 via 10.0.0.1 metric 50
- up ip route add 192.168.0.0/16 via 192.168.0.1 metric 50
复制代码
wlan0 (wifi client)- 可以用 nmtui 配置无线连接,在WIFI连接配置中,IPv4配置->显示->路由,自行添加静态路由(目标/掩码,下一跳,跃点数)
- 也可以修改 "/etc/NetworkManager/system-connections/" 目录中对应wifi的连接配置文件。
- route1=10.0.0.0/8,10.0.0.1,50
- route2=192.168.0.0/16,192.168.0.1,50
复制代码
禁止重启后自动配置网络:
修改/etc/default/networking文件, CONFIGURE_INTERFACES set to 'no'.
- # Set to 'no' to skip interfaces configuration on boot#CONFIGURE_INTERFACES=yes
复制代码
| 欢迎光临 迅维网 (https://www.chinafix.com/) |
Powered by Discuz! X3.4 |