Difference between revisions of "Bridges with Linux"

From Guifi.net - English Wiki

(The bridge control command 'brctl')
(- Translation until here -)
Line 88: Line 88:
 
  $ 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
+
 
 +
 
 +
This is a non configured interface (Dummy). Això és normal, comproveu com la xarxa funciona igualment
 +
 
 +
 +
 
 +
This is normal, check how the network works similarly
 +
= - Translation until here - =
  
 
==Paquet uml-utilities==
 
==Paquet uml-utilities==

Revision as of 17:56, 29 March 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 go on with the restart of 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 


This is a non configured interface (Dummy). Això és normal, comproveu com la xarxa funciona igualment


This is normal, check how the network works similarly

- Translation until here -

Paquet uml-utilities

Instal·lació de User Mode Linux utilities package (uml-utilities):

$ sudo apt-get install uml-utilities

Conté eines per crear interfícies TAP.

Afegir permissos a l'usuari per accedir a la interfície:

$ sudo gpasswd -a <user> uml-net

Per exemple

$ 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:

auto tap0
iface tap0 inet manual
     up ifconfig $IFACE 0.0.0.0 up
     down ifconfig $IFACE down
     tunctl_user <user>

On a user posem el nostre usuari. Per exemple:

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

Tornar a iniciar la xarxa:

$ sudo /etc/init.d/networking restart

tunctl

Ara creem un bridge:

$ sudo tunctl -t tap1 -u sergi
$ sudo chmod 666 /dev/net/tun

I:

$ sudo brctl addbr br0 
$ sudo ifconfig eth0 0.0.0.0 promisc 
$ sudo brctl addif br0 eth0
$ dhclient br0


$ sudo brctl addif br0 tap1 

Recursos:

Recursos

Personal tools