Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Set the Metricvalue in the centos network card configuration file to realize that both network cards are equipped with gateways.

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Suppose that one of the dual network cards of the centos7 system is called ens192 public network ip as the default gateway, and the other is called ens224 with private network ip. When the public network card down falls off, the ens224 needs to continue to be able to interconnect with the public network.

The two key lines of the configuration file ifcfg-ens192 (other lines, need to write GATEWAY=)

DEFROUTE=yes

IPV4_ROUTE_METRIC=0

The two key lines of the configuration file ifcfg-ens224 (other lines, need to write GATEWAY=)

DEFROUTE=yes

IPV4_ROUTE_METRIC=100

Route-n

You will see that the metricvalue of ens224 is higher, and the tag of both network cards is UG.

If it is a centos6 system, you need to up the corresponding network card before you can add the default gateway of the corresponding network card. So there can be no gateway in the configuration file, but write netmask, ip and dns. Execute the following one and you will have the metricvalue and the UG flag.

Route add default public network gateway ip dev eth0 metric 0

Route add default intranet gateway ip dev eth2 metric 100

Whether it is C7 or C6 system, the penultimate line in / etc/init.d/network, that is, the top line of exit $rc, adds the following rules for insurance, which can solve some very complex situations in the intranet environment. For example, the local area network to local area network of some companies and schools is not intranet ip communication. In this way, it will be very troublesome to pass only through the routing table above.

The advantage added to / etc/init.d/network is that the rule setting is automatically executed each time the network is restarted (the NetworkManager service needs to be disabled, only the network service is in charge of the network).

Ip route flush table 1

Ip route add default via (private network ip gateway) dev (private network ip card name such as ens192) src (ip configured on the network card of intranet ip) table 1

Ip rule add from (ip configured on the Nic of the intranet ip) table 1

Ip route flush table 2

Ip route add default via (public network ip gateway) dev (public network ip card name such as ens224) src (ip configured on the network card of public network ip) table 2

Ip rule add from (ip configured on the network card of the public network ip) table 2

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report