Introduction
For enterprises, the design and implementation of the network architecture directly affects the operation stability of the private cloud. Hosts, which provide virtualization and storage resources for VM instances, are core resources on the Cloud. ZStack Cloud provides convenient tools for rapid network configuration on hosts.
| Command | Description |
|---|---|
| zs-show-network | Display the status of the current network |
| zs-network-setting | Configure the network and network bridge for the physical NIC |
| zs-change-nic | Modify the physical NIC name |
| zs-vlan | Configure the VLAN interface for the physical NIC |
| zs-bond-lacp | Create a link aggregation virtual interface in LACP mode |
| zs-bond-ab | Create a link aggregation virtual interface in active-backup mode |
| zs-nic-to-bond | Attach the physical NIC to the specified link aggregation interface/Detach the physical NIC from the specified link aggregation interface |
| zs-restore-network-setting | Restore the physical NIC network configuration |
Note: The scripts of the commands above are stored in the
/usr/local/bin/ directory.Display the Network Status
You can use the zs-show-network command to view the network
status.
zs-show-network response
sample:[root@localhost ~]# zs-show-network
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: vmnic0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:84:ba:34:92:00 brd ff:ff:ff:ff:ff:ff
inet 172.20.54.194/16 brd 172.20.255.255 scope global vmnic0
valid_lft forever preferred_lft forever
inet6 fe80::f884:baff:fe34:9200/64 scope link
valid_lft forever preferred_lft forever
----------------------------------------------------------------
| Bond Name | SLAVE(s) | BONDING_OPTS |
----------------------------------------------------------------
Note: The
response results display the network status and link aggregation status of the host.
Configure the Network Address
You can use the zs-network-setting command to configure the network
address.
zs-network-setting are as
follows:- -i Configure the network
address.
zs-network-setting -i interface ipaddress netmask [gateway] zs-network-setting -i eth0 192.168.1.10 255.255.255.0 192.168.1.1 zs-network-setting -i eth0.10 192.168.1.10 255.255.255.0 192.168.1.1 - -b Create a network bridge and configure the network
address based on the
interface.
zs-network-setting -b interface ipaddress netmask [gateway] zs-network-setting -b eth0 192.168.1.10 255.255.255.0 192.168.1.1 zs-network-setting -b eth0.10 192.168.1.10 255.255.255.0 192.168.1.1
Note: This command takes effect on the physical interface. The gateway parameter is
optional. ZStack Cloud identifies the network bridge name as
br_ prefixed, and does not require a name change.Modify the NIC Name
You can use the zs-change-nic command to modify the NIC
name.
The parameter of zs-change-nic is as follows:
-c Modify the physical NIC name.
Syntax:
zs-change-nic -c OLD_NICNAME NEW_NICNAME
zs-change-nic -c eno1 zsnic0
Note: After you modify the NIC name, the modification is saved in the
/etc/udev/rules.d/70-persistent-net.rules directory. The
NIC name updates after the host restarts.Configure a VLAN Interface
You can use the zs-vlan command to configure a VLAN
interface.
zs-vlan are as follows:- -c Create a VLAN interface.
Syntax:
zs-vlan -c NICNAME VLANID static|dhcp|noneSample:zs-vlan -c zsnic0 10 dhcp - -d Delete a VLAN interface.
Syntax:
zs-vlan -d NICNAME VLANIDSample:zs-vlan -d zsnic0 10
Note:
- When you use zs-vlan command to create a VLAN interface, you can configure the BOOTPROTO parameter. Valid values: static, dhcp, and none. The value static indicates specifying a static IP address for the interface. The value dhcp indicates using the DHCP service to assign a dynamic IP address for the interface. The value none indicates specifying no IP address for the interface.
- After you create a VLAN interface, the corresponding network configuration file will be created in the /etc/sysconfig/network-scripts/ directory. The VLAN interface takes effect after the host restarts. Deleting a VLAN interface also deletes the corresponding network configuration.
If you want to use the created VLAN interface to communicate with other devices, you can refer to the VLAN configuration manual of the network device vendor to allow the VLAN interface traffic transmission.
Create a Link Aggregation
You can use the zs-bond-lacp and zs-bond-ab
commands to create a link aggregation.
zs-bond-lacp
zs-bond-lacp are as follows:- -c Create a link aggregation interface.
Syntax:
zs-bond-lacp -c BOND_NAMESample:zs-bond-lacp -c bond0 - -d Delete a link aggregation interface.Syntax:
zs-bond-lacp -d BOND_NAMESample:zs-bond-lacp -d bond0
Note: The interface created by this command is based on IEEE 802.3ad Link
Aggregation Control Protocol (LACP). The interface requires the admin to
configure the Port-Group on the access layer switch. zs-bond-ab
zs-bond-ab are as follows:- -c Create a link aggregation
interface.
Syntax:
zs-bond-ab -c BOND_NAMESample:zs-bond-ab -c bond0 - -d Delete a link aggregation
interface.
Syntax:
zs-bond-ab -d BOND_NAMESample:zs-bond-ab -d bond0
Note: The interface created by this command is in active-backup
mode, which does not require switch configuration.
Configure a Link Aggregation
You can use the zs-nic-to-bond command to configure a link
aggregation.
zs-nic-to-bond are as follows:- -a Attach a physical interface to a link
aggregation interface.
Syntax:
zs-nic-to-bond -a BOND_NAME NIC_NAMESample:zs-nic-to-bond -a bond0 em1 - -d Detach a physical interface from a link
aggregation interface.
Syntax:
zs-nic-to-bond -d BOND_NAME NIC_NAMESample:zs-nic-to-bond -d bond0 em1
Note: After you run this command, you will see the response result and the relationship between the
physical interface and the link aggregation interface. For example:
---------------------------------------------------------
| Bond Name| SLAVE(s)| BONDING_OPTS |
--------------------------------------------------------------------
| bond0 | enp1s0f1| miimon=100 mode=4 xmit_hash_policy=layer2+3|
| | enp1s0f0| |
--------------------------------------------------------------------- bond0 is the link aggregation interface. The enp1s0f0 and enp1s0f1 are the physical interfaces. This shows their binding relationship.
- In addition, Port-Group consists of the physical interfaces of the access network devices corresponding to enp1s0f0 and enp1s0f1. The admin needs to configure the port-group according to the network device model.
Restore Network Configuration
You can use the zs-restore-network-setting command to restore
network configuration.
The parameter of zs-restore-network-setting is as follows:
-i Restore the network configuration of the physical NIC to default.
Syntax:
zs-restore-network-setting -i interface
zs-restore-network-setting -i eth0
zs-restore-network-setting -i eth0.10
Note:
- This command takes effect on the physical NIC, restores the
if-cfgfile of the physical NIC to default, and restarts the NIC. The response sample is as follows:TYPE=Ethernet BOOTPROTO=none NAME=$NICNAME DEVICE=$NICNAME - If the NIC has been configured with the corresponding network bridge, this command will first delete the network bridge and then perform the above restore operation.
