Skip to content

Latest commit

 

History

History
103 lines (103 loc) · 3.95 KB

day28-report.org

File metadata and controls

103 lines (103 loc) · 3.95 KB

2016-Feb-30-wednesday:

From 9:30 AM TO 06:00 PM :

  • 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:
DEVICE=br1
TYPE=Bridge
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
  • Restart network service to effect the changes.
service network restrat
  • 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.
vzctl create 101 --ostemplate centos-6-x86_64 --hostname centos-1
vzctl create 102 --ostemplate centos-6-x86_64 --hostname centos-2
vzctl create 103 --ostemplate centos-6-x86_64 --hostname centos-3
  • 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:
DEVICE=eth0
HWADDR=00:18:51:9A:D8:E5
BOOTPROTO=static
ONBOOT=yes
NM_CONTROLLED=no
IPADDR=10.2.59.101
NETMASK=255.255.255.0
  • ifcfg-eth1 file should contain the following settings:
DEVICE=eth1
HWADDR=00:18:51:97:0D:0C
BOOTPROTO=static
ONBOOT=yes
NM_CONTROLLED=no
IPADDR=10.2.59.102
NETMASK=255.255.255.0
  • ifcfg-eth2 file should contain the following settings:
DEVICE=eth2
HWADDR=00:18:51:86:A8:F3
BOOTPROTO=static
ONBOOT=yes
NM_CONTROLLED=no
IPADDR=10.2.59.103
NETMASK=255.255.255.0
  • 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.