Gentoo Archives: gentoo-amd64

From: Jason <gentoo@××××××××××.net>
To: gentoo-amd64@l.g.o
Subject: Re: [gentoo-amd64] Networking bridging
Date: Thu, 21 Feb 2008 15:13:49
Message-Id: 47BD952A.9030707@lakedaemon.net
In Reply to: [gentoo-amd64] Networking bridging by Chris Brennan
1 Chris Brennan wrote:
2 > I am trying to set up a Bridge for Qemu to use. I followed the guide
3 > at
4 > http://gentoo-wiki.com/HOWTO:_Qemu#Using_TUN.2FTAP_interface_as_a_normal_user
5 > but when ever the bridge starts, I loose connectivity outside of my
6 > box :/ ... am I missing something ....
7 >
8 >
9 > I've includes the output of my /etc/conf.d/net file ....
10 ...
11 > ##
12 > # LAN
13 > ##
14 > config_eth0=( "192.168.1.2 netmask 255.255.255.0 brd 192.168.1.255" )
15 > routes_eth0=( "default via 192.168.1.1" )
16 >
17 > ##
18 > # Bridge
19 > ##
20 > bridge_br0="eth0"
21 > config_br0=( "192.168.1.20 netmask 255.255.255.0 brd 192.168.1.255" )
22 > #dhcpcd_br0="-t 10"
23 > RC_NEED_br0="net.eth0"
24 > brctl_br0=( "setfd 0" "sethello 0" "stp off" )
25 > config_tap0=( "10.0.2.1 netmask 255.255.255.0" )
26 >
27
28 Here's my /etc/conf.d/net for bridging.
29
30 # Begin ##############################################################
31 # dynamically add devs to br0 as they are created
32 bridge_add_tap0="br0"
33 bridge_add_tap1="br0"
34 bridge_add_tap2="br0"
35
36 # put devs in promiscuous mode, br0 has config
37 config_eth0=( "0.0.0.0 promisc" )
38 config_tap0=( "0.0.0.0 promisc" )
39 config_tap1=( "0.0.0.0 promisc" )
40 config_tap2=( "0.0.0.0 promisc" )
41
42 config_br0=( "192.168.1.2 netmask 255.255.255.0" )
43 routes_br0=( "default via 192.168.1.1" )
44 bridge_br0="eth0"
45
46 # cascading deps tap* irrelevant w/o br0 and eth0
47 depend_tap0() {
48 need net.br0
49 }
50 depend_tap1() {
51 need net.br0
52 }
53 depend_tap2() {
54 need net.br0
55 }
56 depend_br0() {
57 need net.eth0
58 }
59
60 # enable proxyarping
61 postup() {
62 if [[ ${IFACE} == "tap0" ]] ; then
63 echo " * Enabling Proxy ARP on ${IFACE}..."
64 echo 1 >/proc/sys/net/ipv4/conf/tap0/proxy_arp
65 fi
66 if [[ ${IFACE} == "tap1" ]] ; then
67 echo " * Enabling Proxy ARP on ${IFACE}..."
68 echo 1 >/proc/sys/net/ipv4/conf/tap1/proxy_arp
69 fi
70
71 }
72
73 # remove from bridge
74 postdown() {
75 if [[ ${IFACE} == "tap0" ]] ; then
76 echo " * Removing ${IFACE} from bridge br0..."
77 brctl delif br0 tap0
78 echo " * Disabling Proxy ARP on ${IFACE}..."
79 echo 0 >/proc/sys/net/ipv4/conf/tap0/proxy_arp
80 fi
81 if [[ ${IFACE} == "tap1" ]] ; then
82 echo " * Removing ${IFACE} from bridge br0..."
83 brctl delif br0 tap1
84 echo " * Disabling Proxy ARP on ${IFACE}..."
85 echo 0 >/proc/sys/net/ipv4/conf/tap1/proxy_arp
86 fi
87
88 }
89 # End ################################################################
90
91 The key difference is that the underlying "real" devices in the bridge
92 need to be 0.0.0.0 and in promiscuous mode. The bridge has the ip
93 address.
94
95 If you _need_ two separate subnets, you may want to use a tun and
96 iptables or ip_forward/route. One idea you might try is what I
97 suggested, but with br0 = subnetA, br0:1 = subnetB... Not sure it would
98 work, but worth a try.
99
100 Assuming your tap device is the end of an incoming VPN, the proxy arping
101 is only necessary if you want the VPN client (the above script is for
102 the VPN server) to be able to hit the internet through the server's gateway.
103
104 Yeah, looking at the preup/postdown functions just now made me realize I
105 wrote them a _long_ time ago. rewrite at your leisure... ;-)
106
107 hth,
108
109 Jason.
110 --
111 gentoo-amd64@l.g.o mailing list