Reviewed-by: Pristromskaia, Margarita <margarita.pristromskaia@t-systems.com> Co-authored-by: Zaoxu, Li <lizaoxu@huawei.com> Co-committed-by: Zaoxu, Li <lizaoxu@huawei.com>
26 KiB
Configuring a NIC (Red Hat, CentOS, Oracle Linux, and EulerOS)
This section uses CentOS 6.9 (x86_64) as an example to describe how to configure a NIC added to or deleted from a BMS.
- The configuration methods of Red Hat, Oracle Linux, EulerOS, and CentOS are similar.
- If the network is disconnected after a NIC is added and the BMS is restarted, run the following command:
vlan indicates the VLAN used by the NIC.
If the network is still disconnected, add the NIC again.
Add a NIC
Use a key or password to log in to the BMS as user root. Run the following command:
blkid | grep config-2
If the command output is empty, use Method 2. If the command output shown in the following figure is displayed, use Method 1.
- Obtain information about the NIC to be added.
Table 1 NIC information Parameter
Description
Example Value
VLAN and MAC address
Specifies the VLAN information and MAC address of the NIC. To obtain them, perform the following operations:
2838
fa:16:3e:1a:fd:5d
Gateway
Specifies the gateway address of the NIC. To obtain them, perform the following operations:
192.168.1.1
- Use a key or password to log in to the BMS as user root.
- Run the following command to copy file /etc/sysconfig/network-scripts/ifcfg-bond0 to generate file /etc/sysconfig/network-scripts/ifcfg-bond0.vlan (replace vlan with the VLAN obtained in step 1, such as 2838):
cp -p /etc/sysconfig/network-scripts/ifcfg-bond0 /etc/sysconfig/network-scripts/ifcfg-bond0.2838
- Run the following command to edit /etc/sysconfig/network-scripts/ifcfg-bond0.vlan and configure the network configuration file of the newly added NIC, such as ifcfg-bond0.2838:
vim /etc/sysconfig/network-scripts/ifcfg-bond0.2838
Edit the file as follows:
MACADDR=fa:16:3e:1a:fd:5d USERCTL=no PERSISTENT_DHCLIENT=1 PHYSDEV=bond0 VLAN=yes NM_CONTROLLED=no BOOTPROTO=dhcp DEVICE=bond0.2838 TYPE=Ethernet ONBOOT=yes
Descriptions of the parameters are as follows:
- MACADDR: indicates the MAC address of the NIC to be added. For its value, see step 1.
- DEVICE: Set it to bond0.vlan. vlan is the value obtained from 1, such as 2838.
After the modification, press Esc and enter :wq to save the change and exit.
- Run the following command to start the added NIC:
For example, to start bond0.2838, run the command shown in the following figure.
- Run the following command to check the status of the NIC device:
- Ping the gateway from the new network device to check whether the network connectivity is normal.
Use the gateway address obtained from 1.
- Obtain information about the NIC to be added.
Table 2 NIC information Parameter
Description
Example Value
MAC Address
Specifies the MAC address of the NIC. To obtain them, perform the following operations:
fa:16:3e:4e:f7:ae
Gateway
Specifies the gateway address of the NIC. To obtain them, perform the following operations:
- On the NIC details page in 2, obtain the subnet information.
- On the BMS details page, click the link following VPC to switch to the VPC list.
- Click the name of the VPC to which the BMS belongs to go to the VPC details page.
- Click the Subnets tab and obtain the gateway address of the subnet.
192.168.0.1
- Run the following command to query the name of the NIC whose MAC address is MACADDR:
ifconfig -a | grep MACADDR -B 1
MACADDR: indicates the MAC address of the NIC to be added. For its value, see step 1.
As shown in the preceding figure, the NIC name is eth7.
- Run the following command to edit the /etc/sysconfig/network-scripts/ifcfg-eth7 file and configure the network configuration file of the new NIC:
vim /etc/sysconfig/network-scripts/ifcfg-eth7
Edit the file as follows:
DEVICE=eth7 MACADDR=fa:16:3e:1a:fd:5d BOOTPROTO=dhcp ONBOOT=yes
Where,
- MACADDR: indicates the MAC address of the NIC to be added. For its value, see step 1.
- Set DEVICE to the name of the new NIC. For its value, see step 2.
After the modification, press Esc and enter :wq to save the change and exit.
- Run the following command to start the added NIC:
For example, to start eth7, run the following command:
- Run the following command to check the status of the NIC device:
- Ping the gateway from the new network device to check whether the network connectivity is normal.
Use the gateway address obtained from 1.
Delete a NIC
Use a key or password to log in to the BMS as user root. Run the following command:
blkid | grep config-2
If the command output is empty, use Method 2. If the command output shown in the following figure is displayed, use Method 1.
- Obtain the VLAN and MAC address of the NIC to be deleted.
- Use a key or password to log in to the BMS as user root.
- Locate the network device based on the VLAN information and run the following commands to stop and delete the device:
[root@host-192-168-0-172 ~]# ip link | grep 2838 8: bond0.2838@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP [root@host-192-168-0-172 ~]# ifconfig bond0.2838 down [root@host-192-168-0-172 ~]# [root@host-192-168-0-172 ~]# ip link delete bond0.2838 [root@host-192-168-0-172 ~]#
- Run the following command to delete network configuration file /etc/sysconfig/network-scripts/ifcfg-bond0.vlan (replace vlan with the VLAN obtained from 1, such as 2838):
rm /etc/sysconfig/network-scripts/ifcfg-bond0.2838
- Obtain the VLAN and MAC address of the NIC to be deleted.
- Use a key or password to log in to the BMS as user root.
- Locate the network device based on the VLAN information and run the following commands to stop and delete the device:
[root@bms-197-31 ~]# ip link | grep fa:16:3e:4e:f7:ae -B 1 9: eth7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether fa:16:3e:4e:f7:ae brd ff:ff:ff:ff:ff:ff [root@bms-197-31 ~]# ifconfig eth7 down [52574.065410] hinic 0000:89:00.0 eth7: [NIC]Netdev is down - Run the following command to delete network configuration file /etc/sysconfig/network-scripts/ifcfg-eth7:
rm /etc/sysconfig/network-scripts/ifcfg-eth7










