You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I have practised bridge network, connected couple of containers interfaces and bridge, Setting Up Bridge for Private Network.
And I have completed various articles from online which is available at here
Setting Up Bridge for Private Network
Creating a bridge:
Bridge is basically a file configured with essential settings which mentions the bridge name, boot protocol, on boot settings, type and if it is to be network manager controlled. Move to the network-scripts directory in /etc/sysconfig by following command:
cd /etc/sysconfig/network-scripts/
We next step set up a bridge in our private network. Let us call it as br1. To create the bridge, create a file with name ifcfg-br1 in the current directory including the following settings:
Following command can be issued to list all the bridges created and the interfaces they are connected to.
brctl show
The output has to contain the created bridge and any other bridges previously created with connected interfaces.
With current configuration used, a sample output can be seen below:
bridge name bridge id STP enabled interfaces
br1 8000.000000000000 no
Creating private subnet:
To test the settings we can create our own private subnet with three test containers.
Note that ip address is not set for creating the containers.
set the netfilter to full for the containers.
vzctl set 101 --netfilter full --save
vzctl set 102 --netfilter full --save
vzctl set 103 --netfilter full --save
The containers needs to be connected to the bridge br0.This is achieved by connecting with the respective interfaces. This is done by the following commands:
vzctl set 101 --netif_add eth0,,,,br1 --save
vzctl set 102 --netif_add eth1,,,,br1 --save
vzctl set 103 --netif_add eth2,,,,br1 --save
Start the containers and set its status to running.
vzctl start 101
vzctl start 102
vzctl start 103
Configuring Containers:
Enter the contianers
vzctl enter 101
vzctl enter 102
vzctl enter 103
eth0,eth1 and eth2 interfaces of the containers needs to be configured to connect to the bridge. The configuration can set in the directory network-scripts for the files ifcfg-eth0, ifcfg-eth1 and ifcfg-eth2.
cd /etc/sysconfig/network-scripts
ifcfg-eth0 file should contain the following settings:
Restart the network service and check if the eth0, eth1 and eth2 are assigned to ip-address or not (ifconfig command).
The hardware address can be known by the command ifconfig -a.
Note: Hardware address will be only available after adding the configuration files. The process is to first add the configuration without the hardware address,
restart the service and later update it.