linux 多网卡 跃点数

您所在的位置:网站首页 网关跃点设置40 linux 多网卡 跃点数

linux 多网卡 跃点数

2024-07-13 02:51| 来源: 网络整理| 查看: 265

centos6.4

配置两块网卡,eth0设置静态IP,8网段,eth1无线配置dhcp,都是开机启动。

但是eth1无线网卡一旦连接至开放网络(需要web登陆),就替换了之前eth0配置的默认网关,在没有通过web验证前无法上网,eth0又没有设置网关,导致每次开机都要手动设置网关。

后面修改了/etc/rc.local文件,添加(metric 是设置该网关的跃点):

#无线网卡,跃点为2#route add default gw 192.168.15.1 metric 2#无线网卡,跃点为2#route add default gw 192.168.1.1 metric 2#有线网卡#route add default gw 192.168.8.1

因为eth1是dhcp,不一定每次都获取都是同样网段的ip。

后来在某国外网站看到了metric 可以写在配置里,于是:

[root@centos64 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1HWADDR=08:00:27:**:**:**TYPE=EthernetUUID=3024c73c-160c-44f4-81df-fdf734******ONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=dhcpMETRIC=2

这样会优先使用eth0,当eth0无连接或宕掉,再使用eth1。在切换网关的时候会有些卡,不明白为啥。

路由表是这样的:

[root@centos64 ~]# route Kernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.15.0 * 255.255.255.0 U 0 0 0 eth1192.168.8.0 * 255.255.248.0 U 0 0 0 eth0link-local * 255.255.0.0 U 1002 0 0 eth0link-local * 255.255.0.0 U 1003 0 0 eth1default 192.168.8.1 0.0.0.0 UG 0 0 0 eth0default 192.168.15.1 0.0.0.0 UG 2 0 0 eth1



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3