Installing bridge-utils
Adept
Search for bridge-utils and choose the drop-down arrow on the left. Choose "request install".
Konsole:
Enter this into Konsole:
sudo apt-get update sudo apt-get install bridge-utils
If you use sudo -i and
enter your password, then you will not have to use sudo before each
command. It may also save you some typing in the future.
Setting up the Bridge
Ensure that
both (or all) of your interfaces are installed and enabled. If they are
then you may proceed at this point. For a few moments, if your computer
is connected to the internet then it will be disconnected until a
certain point is reached.
Open
Konsole and use the following commands. Note that when interfaces are
referenced, they refer to device names assigned by linux such as "eth0"
and "eth1". Also note that myBridge is the name of the bridge that you
wish to have. This can be anything, but a simple name like bridge0 or
bridge1 is suggested.
ip addr flush dev <interface 1> ip addr flush dev <interface 2> brctl addbr <bridge name> brctl addif <bridge name> <interface 1> <interface 2> ip link set dev <bridge name> up
In lines 1-2 we simply prepared the devices to be bridged. In line 3, we added a new bridge named myBridge (whatever you named your bridge). In lines 4-5, we added interface1 and interface2 to myBridge. In line 6, we made the bridge operational. For more information on commands: use the Konsole command brctl
Create the Bridge at Start-up
The above
setup demonstrated how to create a bridge using the command line,
however when you restart your computer you will lose it. To prevent
this from happening, we need to edit the /etc/network/interfaces file.
This file shows an example of a bridge configure via dhcp.
Sample /etc/network/interfaces file
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # Bridge between eth0 and eth1 auto br0 iface br0 inet dhcp # For static configuration delete or comment out the above line and uncomment the following: # iface br0 inet static # address 192.168.1.10 # netmask 255.255.255.0 # network 192.168.1.0 # gateway 192.168.1.1 # dns-nameservers 192.168.1.5 # dns-search example.com pre-up ip link set eth0 down pre-up ip link set eth1 down pre-up brctl addbr br0 pre-up brctl addif br0 eth0 eth1 pre-up ip addr flush dev eth0 pre-up ip addr flush dev eth1 post-down ip link set eth0 down post-down ip link set eth1 down post-down ip link set br0 down post-down brctl delif br0 eth0 eth1 post-down brctl delbr br0
Restart networking
sudo /etc/init.d/networking restart
Notes about the setup
You have
successfully completed an invisible bridge between your interfaces. If
computer doing the bridging's purpose is simply to act as a switch and
nothing more, then you are done. However, most users will still want to
be able access the internet (and the rest of the network for that matter
from the computer). Please read below to see how to do this.
Enabling Internet Use on the Bridging Computer
It is very simple to setup the internet on the bridging computer.
Finding the Default Gateway
These
directions below attempt to locate your default gateway. They are not
foolproof and if you are not sure what your default gateway is then
contact your Network Administrator or see the Kubuntu IRC channel if the
Administrator is you. If you know your default gateway, then skip to
the
1. If the internet worked on your computer before, then open the KDE Panel and choose system settings. 2. Open System Settings and next click Network Settings. 3. Click the "Administrator Mode..." button at the bottom of the window and enter your password. 4.
Choose the "Route" tab and remember, write down, or copy the address
inside the Default Gateway group box and the "IP Address" text box.
You
now have your default gateway IP address. It is now possible to setup
your computer to access the internet through the bridge.
Konsole Commands
Once you have your default gateway then enter these commands below.
ip route add default via <default gateway ip address> dhclient <bridge name>
If you get a message back from the first command, such as
SIOCADDRT: File exists
or
SIOCADDRT: Network is unreachable
Then skip to the second command.
To ensure that you are connected to the internet, ping the IP address with the command below.
ping 66.94.234.13To ensure that you are connected to the internet, ping the IP address with the command below.
Comments
Post a Comment