Difference between revisions of "bridge-utils"

From Noah.org
Jump to: navigation, search
m
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Engineering]]
 
[[Category:Engineering]]
 
[[Category:Networking]]
 
[[Category:Networking]]
 +
 +
Bridge interfaces are virtual bridges. When you add an existing interface to a bridge it's just like patching a network port into a physical bridge. Bridge interfaces are often used on hosts that run virtual machines; when creating VPNs; and when using a Linux box as a real switch.
  
 
When creating a bridge interface, the new bridge interface becomes the primary interface that you talk to. It assumes control of whatever your original physical interface was doing. This is dangerous if you are bridging your primary ethernet interface because if you don't setup the bridge correctly you will be locked out of your machine.
 
When creating a bridge interface, the new bridge interface becomes the primary interface that you talk to. It assumes control of whatever your original physical interface was doing. This is dangerous if you are bridging your primary ethernet interface because if you don't setup the bridge correctly you will be locked out of your machine.
 +
 +
Using '''brctl''' you can add new bridge interfaces and add other interfaces to it.
 +
<pre>
 +
brctl addbr br0
 +
brctl addif br0 eth0
 +
</pre>
 +
 +
== /etc/network/interfaces ==
 +
 +
This replaces '''eth0''' with a bridge interface, '''br0'''. You don't need to use '''brctl''' to add the bridge or add interfaces to it.
 +
 +
Edit '''/etc/network/interfaces'''. Remove any sections like this:
 +
<pre>
 +
auto eth0
 +
iface eth0 inet static
 +
    address 10.10.10.37
 +
    ...
 +
</pre>
 +
Replace it with a section like this:
 +
<pre>
 +
auto br0
 +
iface br0 inet static
 +
    address 10.10.10.37
 +
    netmask 255.255.255.0
 +
    gateway 10.10.10.1
 +
    bridge_ports eth0
 +
    bridge_hello 1
 +
    dns-nameservers 10.10.10.2
 +
    dns-search example.com
 +
</pre>
 +
 +
Restart networking:
 +
<pre>
 +
/etc/init.d/networking restart
 +
</pre>
 +
 +
== misc ==
  
 
Local:
 
Local:
Line 20: Line 59:
 
ip route add 10.10.10.0/24 dev br0
 
ip route add 10.10.10.0/24 dev br0
 
ip route add default via 10.10.10.1
 
ip route add default via 10.10.10.1
</pre>
 
 
== /etc/network/interfaces ==
 
 
First bring down eth0 and remove any existing IP address.
 
<pre>
 
ifconfig eth0 0.0.0.0
 
</pre>
 
 
Edit '''/etc/network/interfaces'''.
 
<pre>
 
iface eth0 inet manual
 
auto br0
 
iface br0 inet static
 
    address 10.10.10.10
 
    netmask 255.255.255.0
 
    gateway 10.10.10.1
 
    bridge_ports eth0
 
    bridge_hello 1
 
 
</pre>
 
</pre>

Latest revision as of 13:13, 8 May 2013


Bridge interfaces are virtual bridges. When you add an existing interface to a bridge it's just like patching a network port into a physical bridge. Bridge interfaces are often used on hosts that run virtual machines; when creating VPNs; and when using a Linux box as a real switch.

When creating a bridge interface, the new bridge interface becomes the primary interface that you talk to. It assumes control of whatever your original physical interface was doing. This is dangerous if you are bridging your primary ethernet interface because if you don't setup the bridge correctly you will be locked out of your machine.

Using brctl you can add new bridge interfaces and add other interfaces to it.

brctl addbr br0
brctl addif br0 eth0

/etc/network/interfaces

This replaces eth0 with a bridge interface, br0. You don't need to use brctl to add the bridge or add interfaces to it.

Edit /etc/network/interfaces. Remove any sections like this:

auto eth0
iface eth0 inet static
    address 10.10.10.37
    ...

Replace it with a section like this:

auto br0
iface br0 inet static
    address 10.10.10.37
    netmask 255.255.255.0
    gateway 10.10.10.1
    bridge_ports eth0
    bridge_hello 1
    dns-nameservers 10.10.10.2
    dns-search example.com

Restart networking:

/etc/init.d/networking restart

misc

Local:

ssh -o Tunnel=ethernet -f -w 0:0 10.10.10.7 true

Remote:


ifconfig tap0 up
brctl addbr br0
brctl stp br0 on
ifconfig br0 up
brctl addif br0 tap0

ip route add 10.10.10.0/24 dev br0
ip route add default via 10.10.10.1