Você está na página 1de 9

[03/09/2012] by Amitabh Roy

How to Create Bridge? Create files ifcfg-br0 & ifcfg-br1 and edit ifcfgeth0 & ifcfg-eth1 files as shown in the following examples.
File: /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=172.27.25.58
NETMASK=255.255.240.0
GATEWAY=172.27.16.254
DNS1=172.27.16.1
DNS2=172.31.1.130
DOMAIN=cse.iitk.ac.in
DEFROUTE=yes
IPV6INIT=no
USERCTL=no
#HWADDR=5c:f3:fc:96:f8:b8
File: /etc/sysconfig/network-scripts/ifcfg-br1
DEVICE=br1
TYPE=Bridge
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.1.58
NETMASK=255.255.255.0
DEFROUTE=yes
IPV6INIT=no
USERCTL=no
#HWADDR=5c:f3:fc:96:f8:ba
File: /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=5c:f3:fc:96:f8:b8
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
BRIDGE=br0
IPV6INIT=no
USERCTL=no
File: /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=5c:f3:fc:96:f8:ba
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
BRIDGE=br1
IPV6INIT=no
USERCTL=no
#ifconfig
br0
Link encap:Ethernet HWaddr 5C:F3:FC:96:F8:B8
inet addr:172.27.25.58 Bcast:172.27.31.255
Mask:255.255.240.0
inet6 addr: fe80::5ef3:fcff:fe96:f8b8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2568 errors:0 dropped:0 overruns:0 frame:0
TX packets:89 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

RX bytes:357773 (349.3 KiB)

TX bytes:10031 (9.7 KiB)

br1

Link encap:Ethernet HWaddr 5C:F3:FC:96:F8:BA


inet addr:192.168.1.58 Bcast:192.168.1.255
Mask:255.255.255.0
inet6 addr: fe80::5ef3:fcff:fe96:f8ba/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:720 (720.0 b)
eth0

Link encap:Ethernet HWaddr 5C:F3:FC:96:F8:B8


inet6 addr: fe80::5ef3:fcff:fe96:f8b8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3120 errors:0 dropped:0 overruns:0 frame:0
TX packets:221 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:469399 (458.3 KiB) TX bytes:24481 (23.9 KiB)
Interrupt:30 Memory:92000000-92012800

eth1

Link encap:Ethernet HWaddr 5C:F3:FC:96:F8:BA


UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:37 Memory:94000000-94012800

lo

Link encap:Local Loopback


inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:438 (438.0 b) TX bytes:438 (438.0 b)

virbr0

Link encap:Ethernet HWaddr 7E:07:5E:7C:96:36


inet addr:192.168.122.1 Bcast:192.168.122.255
Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

Channel Bonding
Network Interfaces (NIC) Into a Single Interface
Step #1: Create a Bond0 Configuration File
Red Hat Enterprise Linux (and its clone such as CentOS) stores network configuration in
/etc/sysconfig/network-scripts/ directory. First, you need to create a bond0 config file as
follows:
# vi /etc/sysconfig/network-scripts/ifcfg-bond0

Append the following linest:


DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

You need to replace IP address with your actual setup. Save and close the file.

Step #2: Modify eth0 and eth1 config files


Open both configuration using a text editor such as vi/vim, and make sure file read as
follows for
eth0 interface
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Modify/append directive as follows:


DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Open eth1 configuration file using vi text editor, enter:


# vi /etc/sysconfig/network-scripts/ifcfg-eth1

Make sure file read as follows for eth1 interface:


DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Save and close the file.

Step # 3: Load bond driver/module


Make sure bonding module is loaded when the channel-bonding interface (bond0) is
brought up.
You need to modify kernel modules configuration file:
# vi /etc/modprobe.conf

Append following two lines:


alias bond0 bonding
options bond0 mode=balance-alb miimon=100

Save file and exit to shell prompt. You can learn more about all bounding options by
clicking
here).

Step # 4: Test configuration


First, load the bonding module, enter:
# modprobe bonding

Restart the networking service in order to bring up bond0 interface, enter:


# service network restart

Make sure everything is working. Type the following cat command to query the current
status of
Linux kernel bounding driver, enter:
# cat /proc/net/bonding/bond0

Sample outputs:
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:59
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:63

To kist all network interfaces, enter:


# ifconfig

Sample outputs:
bond0 Link encap:Ethernet HWaddr 00:0C:29:C6:BE:59
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:2804 errors:0 dropped:0 overruns:0 frame:0
TX packets:1879 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:250825 (244.9 KiB) TX bytes:244683 (238.9 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:C6:BE:59
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:2809 errors:0 dropped:0 overruns:0 frame:0
TX packets:1390 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:251161 (245.2 KiB) TX bytes:180289 (176.0 KiB)
Interrupt:11 Base address:0x1400
eth1 Link encap:Ethernet HWaddr 00:0C:29:C6:BE:59
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:258 (258.0 b) TX bytes:66516 (64.9 KiB)
Interrupt:10 Base address:0x1480

IP Aliasing:
More than one IP can be assigned to an physical interface, bond, virtual interface,
bridges etc. Some examples are given below.
ifconfig eth0:1 172.27.29.102
ifconfig bond0:1 172.27.25.60
ifconfig lo:0 172.27.29.102

 Make an alias of interface eth0


 Make an alias of channel bond interface bond0
 Make an alias of local interface lo

While executing ifconfig output will be something like


bond0

Link encap:Ethernet HWaddr 00:15:17:11:60:DC


inet addr:172.27.21.226 Bcast:172.27.31.255 Mask:255.255.240.0
inet6 addr: fe80::215:17ff:fe11:60dc/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:1569807 errors:0 dropped:0 overruns:0 frame:0
TX packets:793651 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:242400433 (231.1 MiB) TX bytes:93347006 (89.0 MiB)

bond0:1 Link encap:Ethernet HWaddr 00:15:17:11:60:DC


inet addr:172.27.25.60 Bcast:172.27.31.255 Mask:255.255.240.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
A proper file can be made in /etc/sysconfig/network-scripts as ifcfg-bond0:1
File: ifcfg-bond0:1
DEVICE=bond0:1
IPADDR=172.27.25.60
NETWORK=172.27.16.0
NETMASK=255.255.240.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
#GATEWAY=172.27.25.250
#DNS1=172.27.16.1
Reference: ifconfig

Policy Routing
Problem Statement: One server is to be connected to two internet leased lines. If one
leased line is not functional, traffic will go by other leased line.
Fact Known: In one system one can use multiple routing tables. By default single routing
table is in use.
Steps:
[1] Add one new routing table name entry in /etc/iproute2/rt-tables. Entry will look like
252
rttbl2
 Here rttbl2 is table name and 252 is its id
This table will be created inside the kernel. There will be multiple routing tables inside
kernel (local, main & default).
[2] Populate this table with routing like:
ip route add default table rttbl2 via 172.27.25.250
{Here 172.27.25.250 is the default gateway for second leased line}
[3] Assign routing table to one interface/ip like:
ip rule add from 172.27.25.60 table rttbl2
{Here 172.27.25.60 is one of the IP of a server. It can be aliased IP also}
Above two commands can be kept in /etc/rc.local file for automatic boot time execution.
File: /etc/rc.local
#Dual Leased Line Networking Configuration
ip route add default table rttbl2 via 172.27.25.250 &
ip rule add from 172.27.25.60 table rttbl2 &
[4] check table content of rttbl2 using following command.
ip route list table rttbl2
[5] Testing:
traceroute s 172.27.25.60 www.google.com
It will display the following.
1 172.27.25.250 (172.27.25.250) 3.266 ms 1.497 ms 0.785 ms
2 115.248.232.222 (115.248.232.222) 1.974 ms 1.778 ms 1.912 ms
3 220.224.153.54 (220.224.153.54) 33.085 ms 32.265 ms 32.302 ms
4 115.255.239.53 (115.255.239.53) 72.668 ms 69.040 ms 65.283 ms
5 72.14.197.229 (72.14.197.229) 63.163 ms 63.286 ms 63.159 ms
6 72.14.232.202 (72.14.232.202) 63.277 ms 63.269 ms 63.386 ms
7 72.14.232.100 (72.14.232.100) 72.947 ms 72.767 ms 72.764 ms
8 209.85.249.235 (209.85.249.235) 72.886 ms 72.885 ms 72.882 ms
9 maa03s05-in-f16.1e100.net (74.125.236.80) 70.879 ms 70.879 ms 72.997 ms

traceroute s 172.27.21.226 www.google.com


It will display the following.
traceroute to www.google.com (74.125.236.83), 30 hops max, 40 byte packets
1 cserouterin.cse.iitk.ac.in (172.27.16.254) 9.383 ms 7.854 ms 4.089 ms
2 gateway.iitk.ac.in (172.31.1.251) 0.282 ms 0.434 ms 0.305 ms
3 210.212.66.17 (210.212.66.17) 1.367 ms 1.281 ms 1.420 ms
4 59.163.206.189.static.chennai.vsnl.net.in (59.163.206.189) 63.198 ms 63.109 ms 63.358
ms
5 121.240.1.46 (121.240.1.46) 64.232 ms 60.246 ms 56.251 ms
6 72.14.232.110 (72.14.232.110) 63.239 ms 61.347 ms 61.353 ms
7 209.85.249.235 (209.85.249.235) 61.849 ms 61.968 ms 61.969 ms
8 maa03s05-in-f19.1e100.net (74.125.236.83) 63.342 ms 63.587 ms 63.338 ms

References (further reading): man pages of ip, traceroute

Q. I've installed Red Hat Enterprise Linux 5.2 and I see virbr0 network interface along
with my eth0 interface? What it is? How do I disable or remove virbr0?
A. virbr0 is xen interface used by Virtualization guest and host oses for network
communication. Following are the packages under Red Hat / CentOS Linux:
Group: Virtualization
Description: Virtualization Support.
Mandatory Packages:
=> xen
=> kernel-xen
Default Packages:
=> virt-manager
=> Virtualization-en-US
=> gnome-applet-vm
=> libvirt
You can disable virbr0 if you don't need xen Virtualization support, enter:
# yum groupremove "Virtualization"

Sample output:
Loading "rhnplugin" plugin
Loading "security" plugin
Setting up Group Process
rhel-x86_64-server-vt-5
100% |=========================| 1.4 kB
00:00
rhn-tools-rhel-x86_64-ser 100% |=========================| 1.2 kB
00:00
rhel-x86_64-server-5
100% |=========================| 1.4 kB
00:00
No package matched to remove
No package matched to remove
No package matched to remove
No package matched to remove
No package matched to remove
Resolving Dependencies
--> Running transaction check
---> Package libvirt.x86_64 0:0.3.3-7.el5 set to be erased
--> Processing Dependency: libvirt.so.0()(64bit) for package: libvirtpython
--> Processing Dependency: libvirt = 0.3.3 for package: libvirt-python
--> Running transaction check
---> Package libvirt-python.x86_64 0:0.3.3-7.el5 set to be erased
--> Processing Dependency: libvirt-python for package: rhnvirtualization-host
--> Running transaction check
---> Package rhn-virtualization-host.noarch 0:1.0.1-55 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
======
Package
Arch
Version
Repository
Size
=======================================================================
======
Removing:

libvirt
x86_64
0.3.3-7.el5
installed
3.4 M
Removing for dependencies:
libvirt-python
x86_64
0.3.3-7.el5
installed
230 k
rhn-virtualization-host noarch
1.0.1-55
installed
155 k
Transaction Summary
=======================================================================
======
Install
0 Package(s)
Update
0 Package(s)
Remove
3 Package(s)
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing
: libvirt-python
#########################
[1/3]
Erasing
: rhn-virtualization-host
#########################
[2/3]
Stopping crond: [ OK ]
Starting crond: [ OK ]
Erasing
: libvirt
#########################
[3/3]
Removed: libvirt.x86_64 0:0.3.3-7.el5
Dependency Removed: libvirt-python.x86_64 0:0.3.3-7.el5 rhnvirtualization-host.noarch 0:1.0.1-55
Complete!

Você também pode gostar