如何在CentOS中永久更改界面指标

我的configuration:

  1. 客户操作系统 – CentOS7
  2. 主机操作系统 – Windows 7
  3. 接口 – 3( enp0s3enp0s8enp0s9
  4. 安装在Virtual Box中
  5. enp0s8是桥到wlan0 (因特网)
  6. enp0s3enp0s9是仅主机

Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.10.10.1 0.0.0.0 UG 100 0 0 enp0s3 0.0.0.0 192.168.3.1 0.0.0.0 UG 101 0 0 enp0s9 0.0.0.0 192.168.0.1 0.0.0.0 UG 102 0 0 enp0s8 10.10.10.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3 192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s8 192.168.3.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s9

我在/etc/sysconfig/network-scripts/ifcfg-enp0s8添加了METRIC=10 ,然后重新启动。 但是在route -n仍然会显示“ Metric101 (正如您在上面的输出中看到的那样)。 我试过sudo ifconfig enp0s8 metric 10 ,但是没用。 ping 8.8.8.8失败。 如果我把enp0s3enp0s9 ,ping成功。 有没有办法做到这一点?

不要为未连接到Internet的接口设置默认网关。

删除为这些接口定义的默认网关。 也就是说,从ifcfg-enp0s3ifcfg-enp0s9文件中删除GATEWAY=行。

你根本不用担心路由指标。