Difference between revisions of "Bridges with Linux"
From Guifi.net - English Wiki
 (→- Translation until here -)  | 
				m (→language links)  | 
				||
| (4 intermediate revisions by one user not shown) | |||
| Line 84: | Line 84: | ||
| − | We   | + | We restart to initialize the network:  | 
  $ sudo /etc/init.d/networking restart  |   $ sudo /etc/init.d/networking restart  | ||
| Line 111: | Line 111: | ||
| − | + | It is a non configured interface (Dummy). This is normal, check the network if it still works.  | |
| − | + | ==The package uml-utilities==  | |
| − | + | ||
| − | + | ||
| − | = -   | + | |
| − | + | Installation of User Mode Linux utilities package (uml-utilities):  | |
| − | + | ||
| − | + | ||
  $ sudo apt-get install uml-utilities  |   $ sudo apt-get install uml-utilities  | ||
| − | + | The User Mode Linux package contains tools to create [https://en.wikipedia.org/wiki/Network_tap TAP] interfaces.  | |
| − | + | Add permissions to access the user interface:  | |
| − | + | ||
  $ sudo gpasswd -a <user> uml-net  |   $ sudo gpasswd -a <user> uml-net  | ||
| − | + | For example:  | |
  $ sudo gpasswd -a sergi uml-net  |   $ sudo gpasswd -a sergi uml-net  | ||
| − | |||
| − | |||
| − | + | We need to restart to apply the permissions.   | |
| + | |||
| + | We edit the file '''/etc/network/interfaces''' To add the TAP interface by appending:  | ||
  auto tap0  |   auto tap0  | ||
| Line 144: | Line 138: | ||
       tunctl_user <user>  |        tunctl_user <user>  | ||
| − | + | We replace the placeholer ''<user>'' with out username. For example:  | |
  auto tap0  |   auto tap0  | ||
| Line 153: | Line 147: | ||
       bridge_ports eth0 tap0  |        bridge_ports eth0 tap0  | ||
| − | + | Restart to initialize the network:  | |
  $ sudo /etc/init.d/networking restart  |   $ sudo /etc/init.d/networking restart  | ||
| − | =tunctl=  | + | =The command tunctl=  | 
| − | + | Now we create a bridge:  | |
  $ sudo tunctl -t tap1 -u sergi  |   $ sudo tunctl -t tap1 -u sergi  | ||
  $ sudo chmod 666 /dev/net/tun  |   $ sudo chmod 666 /dev/net/tun  | ||
| − | + | And:  | |
  $ sudo brctl addbr br0    |   $ sudo brctl addbr br0    | ||
| Line 175: | Line 169: | ||
  $ sudo brctl addif br0 tap1    |   $ sudo brctl addif br0 tap1    | ||
| − | + | =Resources=  | |
| − | + | ||
| − | + | ||
| − | =  | + | |
| + | *[https://help.ubuntu.com/community/VirtualBox#head-ac88c03223e773c78dbb46b4b13c109de1143a03 Ubuntu VirtualBox]  | ||
*[http://gentoo-wiki.com/HOWTO_setup_a_gentoo_bridge HOWTO_setup_a_gentoo_bridge]  | *[http://gentoo-wiki.com/HOWTO_setup_a_gentoo_bridge HOWTO_setup_a_gentoo_bridge]  | ||
| + | |||
| + | [[ca:Bridges amb Linux]]  | ||
Latest revision as of 12:56, 12 April 2014
Contents
Bridge Utilities in Linux
The bridge-utils package
Installation:
$ sudo apt-get install bridge-utils
Commands:
$ dpkg -L bridge-utils | grep bin /usr/sbin /usr/sbin/brctl
Configuration files:
$ dpkg -L bridge-utils | grep etc /etc /etc/network /etc/network/if-pre-up.d /etc/network/if-pre-up.d/bridge /etc/network/if-post-down.d /etc/network/if-post-down.d/bridge
Resources:
The bridge control command 'brctl'
Show the bridges:
$ brctl show 
 bridge name     bridge id               STP enabled     interfaces
 br0             8000.001601a1a9b7       no              eth0
                                                         wlan0
 br1             8000.000000000000       no              
Create a new bridge:
$ brctl addbr br1
Add/delete interfaces a un bridge:
$ brctl delif
$ brctl addif
Creation of a bridge
We install the package bridge-utils and the file /etc/network/interfaces. Then we create an interface as a bridge from eth0:
$ cat /etc/network/interfaces auto lo iface lo inet loopback auto br0 iface br0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1 bridge_ports eth0 auto eth0 iface eth0 inet manual
We can use DHCP, as well:
$ cat /etc/network/interfaces auto lo iface lo inet loopback auto br0 iface br0 inet dhcp bridge_ports eth0 auto eth0 iface eth0 inet manual
NOTE: Note how the interface eth0 is manually configured and the line bridge_ports eth0.
We restart to initialize the network:
$ sudo /etc/init.d/networking restart
From now on the eth0 interface can be observed by executing ifconfig:
$ ifconfig
br0       Link encap:Ethernet  HWaddr 00:30:1B:B7:CD:B6  
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::230:1bff:feb7:cdb6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:28932 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28277 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:24356075 (23.2 MB)  TX bytes:17213164 (16.4 MB)
eth0      Link encap:Ethernet  HWaddr 00:30:1B:B7:CD:B6  
          inet6 addr: fe80::230:1bff:feb7:cdb6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20788 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14681 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:23664360 (22.5 MB)  TX bytes:1995733 (1.9 MB)
          Interrupt:20 
It is a non configured interface (Dummy). This is normal, check the network if it still works.
The package uml-utilities
Installation of User Mode Linux utilities package (uml-utilities):
$ sudo apt-get install uml-utilities
The User Mode Linux package contains tools to create TAP interfaces. Add permissions to access the user interface:
$ sudo gpasswd -a <user> uml-net
For example:
$ sudo gpasswd -a sergi uml-net
We need to restart to apply the permissions.
We edit the file /etc/network/interfaces To add the TAP interface by appending:
auto tap0
iface tap0 inet manual
     up ifconfig $IFACE 0.0.0.0 up
     down ifconfig $IFACE down
     tunctl_user <user>
We replace the placeholer <user> with out username. For example:
auto tap0
iface tap0 inet manual
     up ifconfig $IFACE 0.0.0.0 up
     down ifconfig $IFACE down
     tunctl_user sergi
     bridge_ports eth0 tap0
Restart to initialize the network:
$ sudo /etc/init.d/networking restart
The command tunctl
Now we create a bridge:
$ sudo tunctl -t tap1 -u sergi $ sudo chmod 666 /dev/net/tun
And:
$ sudo brctl addbr br0
$ sudo ifconfig eth0 0.0.0.0 promisc $ sudo brctl addif br0 eth0 $ dhclient br0
$ sudo brctl addif br0 tap1