Configuring a NIC (Ubuntu)¶
This section uses Ubuntu 16.04 LTS (Xenial Xerus x86_64) as an example to describe how to configure a NIC added to or deleted from a BMS.
Note
The configuration methods of other Ubuntu OSs are similar to that of Ubuntu 16.04 LTS (Xenial Xerus x86_64).
If the network is disconnected after a NIC is added and the BMS is restarted, run the following command:
ifup bond0.vlan
vlan indicates the VLAN used by the NIC.
If the network is still disconnected, add the NIC again.
Add a NIC¶
Obtain information about the NIC to be added.
¶ 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:
In the BMS list, click the name of the target BMS.
Click the NICs tab, locate the row that contains the NIC to be added, and click to expand details.
Obtain the values of VLAN and MAC Address.
2847
fa:16:3e:a2:aa:65
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.
Check whether the /etc/network/interfaces.d/ directory contains the /etc/network/interfaces.d/70-cloud-init.cfg file.
Run the following commands to generate the /etc/network/interfaces.d/70-cloud-init.cfg file and set the file permissions:
touch /etc/network/interfaces.d/70-cloud-init.cfg
chmod 644 /etc/network/interfaces.d/70-cloud-init.cfg
Run the following command to edit the /etc/network/interfaces.d/70-cloud-init.cfg file and add information about the NIC to be added to the file:
vim /etc/network/interfaces.d/70-cloud-init.cfg
Edit the file as follows:
auto bond0.2847 iface bond0.2847 inet dhcp mtu 8888 hwaddress fa:16:3e:a2:aa:65 vlan-raw-device bond0
The required information has been obtained in step 1.
bond0.2847: indicates the name of the NIC to be added. bond0 is a fixed value and the number following it is the VLAN information of the NIC.
hwaddress: indicates the MAC address of the NIC to be added.
vlan-raw-device: The default value bond0 is used.
After the modification, press Esc, enter :wq, save the configuration, and exit.
Run the following command to start the added NIC:
ifup bond0.vlan
For example, to start bond0.2847, run the ifup bond0.2847 command.
Run the following command to check the status of the NIC device:
ip link
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¶
Obtain the VLAN and MAC address of the VPC 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@ubuntu:~# ip link | grep 2847 9: bond0.2847@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP mode DEFAULT group default qlen 1000 root@ubuntu:~# ifconfig bond0.2847 down root@ubuntu:~# ip link delete bond0.2847
Check whether the BMS OS has been reinstalled after the NIC is added to the BMS.
Run the following command to copy the /etc/network/interfaces.d/70-cloud-init.cfg file to generate the /etc/network/interfaces.d/70-cloud-init.cfg.bak file to back up the network configuration:
cp -p /etc/network/interfaces.d/70-cloud-init.cfg /etc/network/interfaces.d/70-cloud-init.cfg.bak
Run the following command to edit /etc/network/interfaces.d/70-cloud-init.cfg, locate the NIC to be deleted based on the VLAN and MAC address obtained from 1, and delete the NIC information from the file:
vim /etc/network/interfaces.d/70-cloud-init.cfg
# The following information needs to be deleted: auto bond0.2847 iface bond0.2847 inet dhcp mtu 8888 hwaddress fa:16:3e:a2:aa:65 vlan-raw-device bond0
After the modification, press Esc, enter :wq, save the configuration, and exit.
After the NIC is deleted, if the /etc/network/interfaces.d/70-cloud-init.cfg file contains no NIC information, run the following command to delete the /etc/network/interfaces.d/70-cloud-init.cfg file:
rm /etc/network/interfaces.d/70-cloud-init.cfg
Check whether other NICs run properly. If they run properly, run the following command to delete the /etc/network/interfaces.d/70-cloud-init.cfg.bak file:
rm /etc/network/interfaces.d/70-cloud-init.cfg.bak
Run the following command to copy the /etc/network/interfaces.d/50-cloud-init.cfg file to generate the /etc/network/interfaces.d/50-cloud-init.cfg.bak file to back up the network configuration:
cp -p /etc/network/interfaces.d/50-cloud-init.cfg /etc/network/interfaces.d/50-cloud-init.cfg.bak
Run the following command to edit /etc/network/interfaces.d/50-cloud-init.cfg, locate the NIC to be deleted based on the VLAN and MAC address obtained from 1, and delete the NIC information from the file:
vim /etc/network/interfaces.d/50-cloud-init.cfg
# The following information needs to be deleted: auto bond0.2847 iface bond0.2847 inet dhcp mtu 8888 hwaddress fa:16:3e:a2:aa:65 vlan-raw-device bond0
After the modification, press Esc, enter :wq, save the configuration, and exit.
Check whether other NICs run properly. If they run properly, run the following command to delete the /etc/network/interfaces.d/50-cloud-init.cfg.bak file:
rm /etc/network/interfaces.d/50-cloud-init.cfg.bak