Question
How do I add or remove an IP address to/from a VE?
Answer
- For Host-routed mode
To add the IP address 192.168.1.2 to VE 101, run the following command on the Hardware Node:
# vzctl set 101 --ipadd 192.168.1.2 --save
To release an IP address from a VE, use the same command with the --ipdel
option.
- For Bridged mode
First create a new veth virtual network adapter and assigns the name to the Ethernet interface inside the Container:
# vzctl set 101 --netif_add eth0 --save
After this, to add the IP address 192.168.1.2 to VE 101 in bridged mode, run the following command on the Hardware Node:
# vzctl set 101 --ifname eth0 --network Bridged --ipadd 192.168.1.2/24 --gw 192.168.1.1
To remove the bridged adapter from container, use --netif_del
option.
Note
Valid network mask and gateway settings are required in case of Bridged mode.