usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / bridge / doc / HOWTO
blob3729618baa2b118839e2a3620cae4e7a80900c3a
1 Hello everybody,
3 Although there is a man page which documents most of the actual
4 commands, there is still a 'gap' concerning what bridges are, and how
5 to set them up. This document attempts to fill this gap.
7 In fact, this document is a 15-min hack, so feel free to {complain
8 about,improve on} it. Especially if this document (or the FAQ) does
9 not tell you what you want to know; I would consider that to be a bug.
12 Have fun!
13 Lennert Buytenhek
16 <================= CUT HERE AND DAMAGE YOUR SCREEN =================>
20 1. The basics
21 -------------
23 What does a bridge actually do? In plain English, a bridge connects
24 two or more different physical ethernets together to form one large
25 (logical) ethernet. The physical ethernets being connected together
26 correspond to network interfaces in your linux box. The bigger
27 (logical) ethernet corresponds to a virtual network interface in linux
28 (often called br0, br1, br2, etc.)
30 Let's say we want to tie eth0 and eth1 together, turning those
31 networks into one larger network. What do we do? Well, we need to
32 create an instance of the bridge first.
34         # brctl addbr br0
36 (You can check that this gives you a network interface called br0.)
37 Now we want to enslave eth0 and eth1 to this bridge.
39         # brctl addif br0 eth0
40         # brctl addif br0 eth1
42 And now... because we connected the two ethernets together, they now
43 form one large subnet. We are actually only on only one subnet, namely
44 br0. We can forget about the fact that br0 is actually eth[01] in
45 disguise; we will only deal with br0 from now on. Because we are only
46 on one subnet, we only need one IP address for the bridge. This
47 address we assign to br0. eth0 and eth1 should not have IP addresses
48 allocated to them.
50         # ifconfig eth0 0.0.0.0
51         # ifconfig eth1 0.0.0.0
52         # ifconfig br0 my.ip.address.here
54 The last command also puts the interface br0 into the 'up' state. This
55 will activate the forwarding of packets, which in plain English means
56 that from that point on, eth0 and eth1 will be 'joined'
57 together. Hosts on eth0 should 'see' hosts on eth1 and vice versa.
59 The bridge will also (automatically) activate the Spanning Tree
60 Protocol: this is a network protocol spoken by switches for (roughly
61 speaking) calculating the shortest distances and eliminating loops in
62 the topology of the network. You can disable the stp if you really
63 want/need to; see brctl(8) for details.
67 2. More complicated setups
68 --------------------------
70 We can create multiple bridge port groups and do filtering/NATting
71 between them, just like we can do that with ordinary network
72 interfaces.
74 For example: on a quadport network card, dedicate two ports to a LAN
75 on which we have IP 10.16.0.254, and the other two ports to a LAN on
76 which we have IP 192.168.10.1    (this is an actual setup)
78         # brctl addbr br_10
79         # brctl addif br_10 eth0
80         # brctl addif br_10 eth1
81         # ifconfig br_10 10.16.0.254
83         # brctl addbr br_192
84         # brctl addif br_192 eth2
85         # brctl addif br_192 eth3
86         # ifconfig br_192 192.168.10.1
88 You now have logical network interfaces br_10 and br_192, which will
89 act just like ordinary interfaces. The only difference is that they
90 each correspond to two physical network interfaces, but nobody cares
91 about that.
93 So.. for example, if 192.168.10.2 is the only host on the 192.*
94 network that is allowed to access the 10.* network, we would do:
96 ipchains -P forward REJECT
97 ipchains -A forward -s 192.168.10.2/32 -d 10.0.0.0/8 -i br_10 -j ACCEPT
99 (just like you were used to).
105 Hope this helped. If not, send a cry for help to the mailing list.