Date: Sun, 9 Mar 2008 12:46:23 +0100 (CET) From: Per Hedeland <per@hedeland.org> To: sfourman@gmail.com Cc: freebsd-emulation@freebsd.org Subject: Re: Qemu: bridging on FreeBSD 7.0-STABLE Message-ID: <200803091146.m29BkNhk078445@pluto.hedeland.org> In-Reply-To: <11167f520803090103j1dc61e7ap89eb21347e22557e@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
"Sam Fourman Jr." <sfourman@gmail.com> wrote:
>
>I am confused a bit,
>
>so what would I have to put in /etc/sysctl.conf so that qemu would
>have bridging for a user, automatically on bootup
>
>would I have to have a shell script of some sort? and would it not
>have to test if there already is a tap0?
>
>I have been trying to get this to work for awhile, if anyone has
>config files they could post I would very much appreciate it.
>
>esp if you could get multiple qemu's to bridge at once
Here's the setup I use:
0. In /boot/loader.conf:
if_tap_load="YES"
This may actually be redundant though, I haven't tried w/o it.
1. In /etc/sysctl.conf:
# Allow user open of tap device for qemu networking
net.link.tap.user_open=1
2. In /etc/devfs.rules:
[localrules=10]
# devfs starts before NIS, so need numerical uid here (if you use NIS)
add path 'tap*' user 1016
3. In /etc/rc.conf:
devfs_system_ruleset="localrules"
cloned_interfaces="bridge0"
ifconfig_bridge0="addm bge0 up"
I.e. this is one-time stuff, you can of course do it manually instead
when testing:
ifconfig bridge0 create
ifconfig bridge0 addm bge0 up
Use the name of your physical ethernet interface instead of "bge0",
of course.
4. /etc/qemu-ifup:
#!/bin/sh
sudo /sbin/ifconfig $1 up
case "`ifconfig bridge0`" in
*" $1 "*) ;; # already in the bridge
*) sudo /sbin/ifconfig bridge0 addm $1 ;;
esac
Finally, to run multiple qemus with bridged networking you *must* assign
them different MAC addresses via -net nic,macaddr=52:54:00:XX:XX:XX
(well, one of them can have the default of course). I just hardwire
them, but in an earlier discussion here, Bakul Shah posted a nice trick
to auto-generate the MAC address:
Right. I use a shell function to create a macaddress based on
directory of the image file. Something like:
macaddr() {
echo 52:54:0:$(echo $1|md5 |cut -c1-6|sed 's/\(..\)\(..\)/\1:\2:/')
}
qemu -net nic,macaddr=$(macaddr $(dirname $(realpath $1))) -hda $*
And invoke it as, for example,
my-qemu /usr/oszoo/plan9 ...
Incidentally that post can *not* be found by searching the
freebsd-emulation archives at freebsd.org, but there's always google...
--Per
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803091146.m29BkNhk078445>
