设备有两张网卡,在 debian 9 会有两个默认路由$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Ifacedefault gateway 0.0.0.0 UG 100 0 0 enp0s8default gateway 0.0.0.0 UG 101 0 0 enp0s310.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3link-local 0.0.0.0 255.255.0.0 U 1000 0 0 enp0s8192.168.20.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s8必须删除一个才能连接外网由于找不到相关设置,所以就想使用脚本开机自动执行删除命令route del -net default netmask 0.0.0.0 dev enp0s8在开机的时候该脚本执行失败,而且还有一个问题,如何保证该脚本在网络配置完成后运行。所以该如何保证只有一个默认路由呢?所以该如何保证只有一个默认路由呢?所以该如何保证只有一个默认路由呢?
2 回答

慕运维8079593
TA贡献1876条经验 获得超5个赞
可修改 debian 网络设置文件 /etc/network/interfaces,两种参考方法
对不需要设置网关的接口,用静态 IP,不用 DHCP,如
auto eth_master inet dhcpauto eth_slave inet static address 192.168.20.0 netmask 255.255.255.0

智慧大石
TA贡献1946条经验 获得超3个赞
在两个接口都要 DHCP 时,可加 metrics 调整优先级,如
auto eth_master inet dhcp metric 0auto eth_slave inet dhcp metric 100
- 2 回答
- 0 关注
- 1581 浏览
添加回答
举报
0/150
提交
取消