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

Centos7 dual network card configuration

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

Because the network configuration of centos7 is different from that of previous versions, I have taken many detours in the process of configuration, so I can sum up as follows:

There are two network services in centos7: NetworkManger.service and network.service. NetworkManager.service is often called to configure the network information through the interface, but if the two are used at the same time, sometimes there will be conflicts and the network will be blocked.

Therefore, here we first use NetworkManager.service to configure the network card to generate a configuration file, then turn off the NetworkManager.service service and turn on the network.service service, and finally set the former to boot off and the latter to boot startup.

Check the status of the service first

Systemctl status NetworkManager.service

If it is not open, please execute

Systemctl restart NetworkManager.service

In order to facilitate the configuration of network information, we configure the network card information directly through the interface.

The premise is that two network cards have been created, one of which is a 172.16.x.x network segment and is connected to the external network. Another network card is the 192.168.x.x network segment, which connects to the intranet. The following is the network card information that I configured according to my own external network environment.

At this point, we go to the terminal to view the configuration files of these two network cards.

Cd / etc/sysconfig/network-scriptsls

You can see the two files that start with ifcfg-. Of course, ifcfg-ens33 and ifcfg-ens34 are the files I have changed (the original files are ifcfg-Wired_connection_1 and _ 2 in the picture). The name of the file name, which needs to be viewed using ifconfig.

Ifconfig

Once you know the name of the network card, you can change the original file, but you should know which network card corresponds to the internal network or the external network, through the

Cp ifcfg-Wired_connection_1 ifcfg-ens33cp ifcfg-Wired_connection_2 ifcfg-ens34vi / etc/sysconfig/network-scripts/ifcfg-ens34

Change the NAME name to ens34, and then save it by ctrl+c: wq

The other file is changed in the same way, so stop using the NetworkManager.service service with the following command and set it to boot and not start. And restart the network service

Systemctl stop NetworkManager.servicesystemctl disable NetworkManager.servicesystemctl restart network

By using the

Systemctl enable network.service

Will find that it appears.

So we need to reuse it.

/ sbin/chkconfig network on

Set the boot mode for network.service.

Finally, restart the virtual machine.

Reboot

You can see that you can already connect to the network

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

Network Security

Wechat

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

12
Report