Català  

Difference between revisions of "Bridges with Linux"

From Guifi.net - English Wiki

(The bridge control command 'brctl')
m (language links)
 
(5 intermediate revisions by one user not shown)
Line 84: Line 84:
  
  
We go on with the restart of the network:
+
We restart to initialize the network:
  
 
  $ sudo /etc/init.d/networking restart
 
  $ sudo /etc/init.d/networking restart
  
= - Translation until here - =
+
From now on the eth0 interface can be observed by executing '''ifconfig''':
 
+
A partir d'ara la interfície eth0, tal i com podem observar a l'executar '''ifconfig''':
+
  
 
  $ ifconfig
 
  $ ifconfig
Line 111: Line 109:
 
           Interrupt:20  
 
           Interrupt:20  
  
És una interfície no configurada ('''TONTA''' o Dummy). Això és normal, comproveu com la xarxa funciona igualment
 
  
==Paquet uml-utilities==
 
  
Instal·lació de User Mode Linux utilities package (uml-utilities):
+
It is a non configured interface (Dummy). This is normal, check the network if it still works.
  
$ sudo apt-get install uml-utilities
+
==The package uml-utilities==
  
Conté eines per crear interfícies TAP.
+
Installation of User Mode Linux utilities package (uml-utilities):
  
Afegir permissos a l'usuari per accedir a la interfície:
+
$ 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
  
Per exemple
+
For example:
  
 
  $ sudo gpasswd -a sergi uml-net
 
  $ sudo gpasswd -a sergi uml-net
 
 
Cal tornar a iniciar per aplicar els permissos
 
  
Per afegir la interfície TAP editem el fitxer '''/etc/network/interfaces''' i afegim:
+
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 139: Line 138:
 
       tunctl_user <user>
 
       tunctl_user <user>
  
On a user posem el nostre usuari. Per exemple:
+
We replace the placeholer ''<user>'' with out username. For example:
  
 
  auto tap0
 
  auto tap0
Line 148: Line 147:
 
       bridge_ports eth0 tap0
 
       bridge_ports eth0 tap0
  
Tornar a iniciar la xarxa:
+
Restart to initialize the network:
  
 
  $ sudo /etc/init.d/networking restart
 
  $ sudo /etc/init.d/networking restart
  
=tunctl=
+
=The command tunctl=
  
Ara creem un bridge:
+
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
  
I:
+
And:
  
 
  $ sudo brctl addbr br0  
 
  $ sudo brctl addbr br0  
Line 170: Line 169:
 
  $ sudo brctl addif br0 tap1  
 
  $ sudo brctl addif br0 tap1  
  
'''Recursos''':
+
=Resources=
*https://help.ubuntu.com/community/VirtualBox#head-ac88c03223e773c78dbb46b4b13c109de1143a03
+
 
+
=Recursos=
+
  
 +
*[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

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 

Resources

Personal tools