Linux ETH bridging

Turn your Linux server into a humble switch… Not so humble though.
Not recommended for desktop distro’s as you will have to turn off the desktop NetworkManager.

What you need:
Kernel Version 2.4 or higher.
Kernel Configuration ‘802.1d Ethernet Bridging’ build in or module.
A working network configuration with atleast 2 Eth’s (nic’s)
Package ‘bridge-utils’ installed.

What you get:
A network switch with a working IP connection for the server it self to use.

Configuration:

# /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
TYPE="Ethernet"
BRIDGE="br0"
HWADDR="00:XX:XX:XX:XX:B0"
ONBOOT="yes"
BOOTPROTO="static"
NM_CONTROLLED="no"
NOZEROCONF="yes"
# /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
TYPE="Ethernet"
BRIDGE="br0"
HWADDR="00:XX:XX:XX:XX:B1"
ONBOOT="yes"
BOOTPROTO="static"
NM_CONTROLLED="no"
NOZEROCONF="yes"
# /etc/sysconfig/network-scripts/ifcfg-ethX
DEVICE="ethX"
TYPE="Ethernet"
BRIDGE="br0"

etc. etc. for all network cards you want to participate in the bridge.

Then setup a virtual device so that the server as an IP address of it’s own.
Like below.

# /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
TYPE="Bridge"
IPADDR="192.168.1.1"
NETMASK="255.255.255.0"
BROADCAST="192.168.1.255"
GATEWAY="192.168.1.254"
ONBOOT="yes"
BOOTPROTO="static"
NM_CONTROLLED="no"
NOZEROCONF="yes"

But I needed 2 nic’s in my server for 2 IP addresses you say ??
No worries… Just alias the br0 device like below.

# /etc/sysconfig/network-scripts/ifcfg-br0:1
DEVICE="br0:1"
TYPE="Bridge"
IPADDR="192.168.2.1"
NETMASK="255.255.255.0"
BROADCAST="192.168.2.255"
GATEWAY="192.168.2.254"
ONBOOT="yes"
BOOTPROTO="static"
NM_CONTROLLED="no"
NOZEROCONF="yes"

Note*
You can’t write iptable rules for eth0 eth1 ethX. You’ll have to write them for br0 instead.
Because all network traffic will pass trough the nic’s transparent at level 2 from the OSI model and iptables packet filtering works at level 3 and 4 from the OSI model.

Note**
The drawback to aliasing is that iptables can’t handle aliased devices.
You’ll have to write iptable rules bound to the ip addresses and not to the devices.

Note***
I read some where that you can not use dhcp client on aliased devices….
I can not confirm or deny that as i don’t use dhcp client on my server.

Note****
Configuring applications and services that (can) bind to hardware devices. The eth0 eth1 ethX are not available to applications and services anymore as they operate now at level 2 data layer (OSI model). You’ll have to modify the configurations to use the bridge devices ‘br0’. Again some applications or services can’t bind to aliases or even virtual devices like the br0. Then you’ll have to bind them to IP address instead.

Note*****
On heavy traffic lan’s cheap ethernet cards won’t cut it.
Low end ethernet devices have a very limited threads capability.
They will start dropping packets… And the whole bridge is as strong as the cheapest card.
because all level 2 traffic from one eth is broadcasted to all other eth devices and that for all eth’s

Note*****
Make sure all eth’s work at the same speed. 1 card at 10Mb half duplex and another at 100Mb full duplex is very very bad. As the slow card now have to buffer traffic from the fast card which it can’t do for long it just don’t have that kind of capabilities. I recon it won’t hold long on even very low traffic lan’s. It’s just bad practice, very bad.

grub4dos and Fedora with GRUB2

Dual booting belly aches 😉

grub4dos does not boot Fedora 17.
This basically goes for all linux distro’s using the grub2 boot loader.
The reason is that GRUB2 does not use the /boot/grub/menu.lst which is required for grub4dos. Instead Fedora 17 with GRUB2 uses /boot/grub2/i386/core.img to load the grub2 boot menu.

Here’s one way of fixing it.
Create a /boot/grub/menu.lst file.
If /boot/grub directory does not exist then you’ll have to create it.
And put the following in it. (between the lines)

default=0
timeout=60
title Fedora (3.6.10-2.fc17.x86_64)
        root (hd0,1)
        kernel /vmlinuz-3.6.10-2.fc17.x86_64 root=/dev/sda3 ro more-boot-options
        initrd /initramfs-3.6.10-2.fc17.x86_64.img

grub4dos will now find the /boot/grub/menu.lst file and will happily boot Fedora 17.

Note*
Kernel version number’s are subject to change. You’ll have to substitute them with your own.
root (hd0,1) means first physical hdd second partition which is referring to the /boot partition. You’ll have to substitute the 0,1 with your own hdd configuration.
root=/dev/sda3 means first physical hdd third partition which is referring to the / partition. You’ll have to substitute the sda3 with your own hdd configuration. (Some older systems use hda instead of sda.)
more-boot-options You have to substitute that with the kernel boot options grub2 would have used. You can find the kernel boot options in /boot/grub2/grub.conf.Search for the vmlinuz-3.6.10-2.fc17.x86_64 line. Replace more-boot-options with every thing behind the ro option. You will also see that it does not use the root=/dev/xxx but it uses a fancy UUID number. Which is not very human readable so I prefer the old fashioned way.
On my system it looks like this /vmlinuz-3.6.10-2.fc17.x86_64 root=/dev/sda3 ro rd.md=0 rd.lvm=0 rd.dm=0 SYSFONT=True KEYTABLE=us rd.luks=0 LANG=en_US.UTF-8 rhgb quiet

Note**
Subsequent automated kernel updates won’t be listed in the menu.lst
You have to make the updates in the menu.lst your self after a kernel update.

Note***
hdd stands for hard disk drive.