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

What is the configuration of the network and equipment in Centos7?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

What this article shares with you is about the configuration of the network and devices in Centos7. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

In centos7, the use of ifconfig tools is no longer supported and replaced by nmcli tools. Service management has also replaced service with systemctl tools. Although these previous versions of tools can continue to be used in centos7, they are only for version compatibility purposes.

Next, we will introduce and explain the network configuration and management in centos7.

1.nmcli acquires information related to the network card

# nmcli connection show

If the network card is not enabled and the relevant configuration file has not been established, the "-" is displayed in the device field. After the configuration is complete, the corresponding device name will be displayed when the network service is restarted.

Note:

In centos7, the naming rules of the network card have been changed, as follows.

1) eno1: the network card built inside the motherboard BIOS

2) ens1: the network card of the PCI-E interface built by the motherboard BIOS

3) the independent network card of the enp2s0:PCI-E interface, there may be multiple network card interfaces, so there may be s0mems1. Number of, etc.

4) eth0: if the above naming rules are not applicable, return to the original network card naming and numbering rules

2.nmcli manually configures the network card

# nmcli connection modify ens1\

Connection.autoconnect yes\

Ipv4.method manual\

Ipv4.address 192.168.1.21 Compact 24\

Ipv4.gateway 192.168.1.1\

Ipv4.dns 114.114.114.114

-- restart network services

# systemctl restart network.service

Or

# systemctl restart network

3.nmcli View to determine the relevant information of the network card

# nmcli connection show ens1

# nmcli device status

In centos7, ifconfig is no longer used and is replaced by ip addr.

# ip addr

4. Set dual IP for network card

# cd / etc/sysconfig/network-scripts/

# cp ifcfg-enps1 ifcfg-ens1:1

# vi ifcfg-enps1:1

-- modify the following content, save and exit.

NAME=ens1:1

DEVICE=ens1:1

IPADDR=192.168.1.22

PREFIX=24

# nmcli connection show ens1

-- you will see that the Nic has two IP addresses in the output.

-- View all network device information

# ip addr

-- the two inet sections in the output contain two IP addresses.

5. Configure hostname

# hostnamectl set-hostname www.test.com

# cat / etc/hostname

6.nmcli configure the network card to automatically obtain the IP address

# nmcli connection modify eth0\

> connection.autoconnect yes\

> ipv4.method auto

# systemctl restart network

6. Configure the bonding network card

6.1 bonding concept

By binding multiple NICs to the same IP address and providing services, you can achieve both high availability and load balancing. Because two network cards can not be set to the same IP address, through the bonding mechanism, a virtual network card can provide services, and the physical network card is mapped to the same MAC address.

6.2 bonding operating mode

1) Mode 0 (balance-rr and Round-robin)

A poll sends packets on each slave interface. This mode provides load balancing and fault tolerance.

2) Mode 1 (active-backup)

Only one slave is activated at any time, and other slave is activated when and only if the active slave interface fails. To avoid switch confusion, the MAC address bound to this mode is visible only on one external port.

3) Mode 3 (broadcast)

All messages are transmitted on all slave interfaces to provide fault tolerance.

In addition, active-backup, balance-tlb, and balance-alb modes do not require any special configuration of the switch, while other modes require configuration of the switch in order to integrate links.

6.3 add bonding steps

1) add bonding API

# nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup ipv4.method manual ipv4.addresses 192.168.1.66/24 ipv4.dns 114.114.114.114 ipv4.gateway 192.168.1.1

-- Note

1) nmcli connection add: creation command must be

2) type bond: specify the configuration type

3) con-name bond0: specify the name of the profile

4) ifname bond0: specify the interface name

5) mode active-backup: specify the binding mode

6) ipv4.method (manual | auto): specify the ip address mode. Manual corresponds to static address and auto corresponds to dynamic address (ip,dns,gateway does not need to be specified)

7) ipv4.addresses: specify an ipv4 static address

8) ipv4.dns: specify the dns server

9) ipv4.gateway: specify the gateway

10) this command automatically creates a configuration file, and the server restart configuration will not be lost.

2) add slave interface

# nmcli connection add con-name bond-slave0 type bond-slave ifname eth0 master bond0

# nmcli connection add con-name bond-slave1 type bond-slave ifname eth2 master bond0

3) start binding

-- the slave interface must be activated first.

# nmcli connection up bond-slave0

# nmcli connection up bond-slave1

# nmcli connection up bond0

4) View binding Nic information

Cd / etc/sysconfig/network-scripts/

# cat / proc/net/bonding/bond0

6.4 remove bonding steps

1) down drops bonding device

# nmcli connection down bond0

# nmcli connection down bond-slave0

# nmcli connection down bond-slave1

2) Uninstall the bonding driver module

# lsmod | grep bonding

# modprobe-r bonding

3) Delete bonding-related configuration files

# nmcli connection delete bond0

# nmcli connection delete bond-slave0

# nmcli connection delete bond-slave1

4) View the startup network card device

# nmcli device status

# nmcli device show

# nmcli d c eth0

# nmcli d c eth2

The above is what the configuration of the network and equipment in Centos7 is like. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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