Friday, February 21, 2014

Creating N/w Bridge on CentOS

Hi,

Simple steps for creating bridge on CentOS.

What is bridge and why to use it : In brief There are two ways for giving n/w access to your VM's
      1. NAT : This is bare minimum default, this allows your VM to use Internet but not n/w in which host is, so good for Home use or single machine not so for Office / mulitple machine.
      2. Bridge: As name suggest this will be link for NAT + Host N/w , allowing VM to have n/w ip in range of host.
       If info is not enough will write another blog for that now how to do it.

   First Setup up Gateway as host  i.e.
[root@centos2 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=centos2
GATEWAY=br0

   Next Step Remove IP details from Eth0 and add another line Bridge=br0
[root@centos2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:22:4d:ab:ee:61
TYPE=Ethernet
UUID=d455705f-633e-4d5f-b78a-1272c8238c66
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
#IPADDR=192.168.32.52
#NETMASK=255.255.252.0
#DNS2=8.8.8.8
#GATEWAY=192.168.35.254
#DNS1=192.168.32.10
IPV6INIT=no
USERCTL=no
BRIDGE=br0
    Now put IP details in ifcfg-bro with Bridge details
root@centos2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
IPADDR=192.168.32.52
NETMASK=255.255.252.0
DNS2=8.8.8.8
GATEWAY=192.168.35.254
DNS1=192.168.32.10
DEVICE="br0"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System br0"

Hold you breath and restart network

If everything is good you should have n/w access back 

Verify same by brctl show
[root@centos2 ~]# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.00224dabee61       no              eth0


That's it your done



No comments:

Post a Comment