On Jan 24, 2012, at 1:49 PM, Nathan Coulson wrote:
> On Tue, Jan 24, 2012 at 1:40 PM, Bruce Dubbs <[email protected]> wrote:
>> Nathan Coulson wrote:
>>
>>> Not any time to proofread this, but this is what I use
>>>
>>> echo > /etc/qemu-ifup << "EOF"
>>> ip addr add 0.0.0.0 dev $1
>>> ip link set $1 up
>>> brctl addif br0 $1
>>> EOF
>>
>> Nathan, this is exactly what I need. In the above, do you need
>>
>> brctl addbr br0
>>
>> or is qemu supposed to do that for you? My client right now is Fedora
>> and there is no br0 present.
>
> It has to exist first. Qemu creates that tap0 [again, I could have
> the name wrong]. It is up to the /etc/qemu-if on what to do with that
> interface. I bridged it into br0 which I setup using the LFS network
> bootscripts. See ifconfig.br0-0
>
>>> I also attached my bridge script, which was upgraded to the new system
>>> (I still had boot_mesg in there though [cosmetic], but I did a quick
>>> fix on that. Untested)
>>>
>>> cat > /etc/sysconfig/ifconfig.br0-0 << "EOF"
>>> IFACE=br0
>>> ONBOOT=yes
>>> CHECK_LINK=no
>>> SERVICE=bridge
>>> INTERFACES=eth0
>>> EOF
>>
>> When I run the following on the host
>>
>> brctl addbr br0
>> ip addr add 0.0.0.0 dev br0
>> ip link set br0 up
>> brctl addif br0 eth0
>>
>> That last command kills my normal eth0 connection. I had to reboot to
>> get it back.
>
> br0, should act like a hardware switch does, where eth0 is one of the
> ports. (Basically, we made a 1 port switch).
>
> After br0 is created, then you can setup an IP Address on br0 (instead of
> eth0).
>
> The ifconfig.br0-1 file, is what I used to give br0 an IP Address.
>
> there is no ifconfig.eth0 file on my computer
I'm also not a bridging expert, but Nathan's explanation sounds very
reasonable: saying "br0 becomes a switch" is a good analogy with a nice visual
image. I don't know the specifics of what's happening in the kernel, but when
you form a bridge, the original hardware interface (e.g., eth0) turns into a
"port", and is no longer a configurable interface.
When you "attached" eth0 to br0 (set eth0 as a port to br0), eth0 is "enslaved"
to the bridge, and loses its connectivity. Traditionally, a bridge spanned two
network endpoints, and gave both endpoints the same address. So, the original
endpoint configuration (e.g., eth0) would "disappear", and the kernel(?) would
treat br0 as the new live interface once eth0 is enslaved to it. That's why,
AFAIK, you would lose your connection if you were SSH'ed in and connected to
eth0, and did your brctl to bring up the br0 interface.
On that note...I think there's a slightly simpler way to configure the bridge.
I've modified Nathan's bridge script (inlined below), which allows your bridge
to be usable without having a second port attached to br0. Here's my
ifconfig.br0:
ONBOOT=yes
IFACE=br0
SERVICE=bridge
INTERFACES="eth0"
IP=192.168.0.250
GATEWAY=192.168.0.1
PREFIX=24
BROADCAST=192.168.0.255
Oh--and, as Nathan pointed out...If you're enslaving eth0 to br0, then you must
not have a ifconfig.eth0 file. I have no idea what will happen other than that
neither interface is likely to work. ;)
>>> qemu-system-x86_64 -net nic -net tap
>>>
>>> will create a new tap0, calls /etc/qemu-ifup tap0, which I proceed
>>> to dump into my br0 (disclaimer: not sure if I mean tun or tap)
I'm close (fingers-crossed) to getting a working Xen configuration. When
that's done, I'll post my notes and scripts if anyone is interested in a
64-bit-only Xen (i.e. no HVM) configuration.
Q
#!/bin/sh
########################################################################
# Begin /lib/services/bridge
#
# Description : Bridge Boot Script
#
# Authors : Nathan Coulson - nathan at linuxfromscratch.org
# Updates : Qrux - qrux dot qed at gmail.com
#
# Version : 00.02
#
########################################################################
. /lib/lsb/init-functions
. ${IFCONFIG}
if [ -n "${INTERFACE}" ]; then
log_failure_msg "INTERFACES variable missing from ${ifconfig},",
${FAILURE}
echo_failure
exit 1
fi
case "${2}" in
up)
log_info_msg "Creating the ${1} interface..."
brctl addbr ${1}
evaluate_retval
for X in ${INTERFACES}; do
log_info_msg "Adding ${X} to ${1}..."
ip addr add 0.0.0.0 dev ${X} &&
ip link set ${X} up &&
brctl addif ${1} ${X}
evaluate_retval
done
log_info_msg "Adding IPv4 address ${IP} to the ${1}
interface..."
ip addr add ${IP}/${PREFIX} dev ${1} &&
ip link set ${1} up
;;
down)
for X in ${INTERFACES}; do
log_info_msg "Removing ${X} from ${1}..."
ip link set ${X} down &&
brctl delif ${1} ${X}
evaluate_retval
done
log_info_msg "Bringing down the ${1} interface..."
ip link set ${1} down
brctl delbr ${1}
evaluate_retval
;;
*)
log_warning_msg "Usage: ${0} [interface] {up|down}"
exit 1
;;
esac
# End /lib/services/bridge
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page