Thanks Ronald,

This is my new method ;-) and I can use ping :-)
If any thinks is ok, I can write it in the wiki.

slds.

- - - - - - - -

Installing Plan9 network for QEMU (Linux)

Do you need:

* Support for tunneling in kernel, with 802.1q:

tun: "Network device support" -> "Universal TUN/TAP device driver support"
bridging: "Networking options" -> "802.1d Ethernet Bridging"

* The bridge-utils package

First, load the Tunneling kernel support as modules

add "tun" to /etc/modules

Load it now (do not reboot ;-)): modprobe tun

* Create this script:

darky:~# cat kixconf
IFACE=eth0
BRIF=br0
IPORIG=`/sbin/ifconfig $IFACE | grep "inet addr" | cut -d: -f2 | cut -d" " -f1`
IPGW=`netstat -nr | grep ^" 0.0.0.0" | awk -F" " '{print $2} '`
IPBCAST=`/sbin/ifconfig $IFACE | grep "Bcast" | cut -d: -f3 | cut -d" " -f1`

echo "Interface = " $IFACE
echo "Bridge if = " $BRIF
echo "IP = " $IPORIG
echo "Gateway = " $IPGW
echo "Broadcast = " $IPBCAST

ifconfig $IFACE down
brctl addbr $BRIF
ifconfig $IFACE 0.0.0.0 promisc up
ifconfig $BRIF $IPORIG netmask 255.255.255.0 broadcast $IPBCAST up
brctl stp $BRIF off
brctl setfd $BRIF 1
brctl sethello $BRIF 1
brctl addif $BRIF $IFACE
route add default gw $IPGW
darky:~#

Now, configure /etc/qemu-ifup, and set the +x bit (chmod 755 /etc/qemu-ifup) like this:

darky:~# ls -l /etc/qemu-ifup
-rwxr-xr-x 1 root root 60 2006-08-19 12:57 /etc/qemu-ifup
darky:~# cat /etc/qemu-ifup
#!/bin/sh
ifconfig $1 0.0.0.0 promisc up
brctl addif br0 $1
darky:~#

Now, you can use your Plan9 as a physical node in your network, then configure the Plan9 scripts as http://plan9.bell-labs.com/wiki/plan9/Network_configuration/index.html

For boot the Plan 9 you shoud use this command:

/usr/bin/qemu -m 128 -hda '' -net nic,vlan=0,macaddr=00:11:22:33:44:55 -net tap,vlan=0,ifname= -localtime &

slds.

2006/8/19, Ronald G Minnich < rminnich@lanl.gov>:
here's how I run qemu so as to get things going. This allows me to
drawterm into it.

qemu qemu.vesaroot &

Gets me a cpu kernel going

sleep 5 && dhcpd -d

gets me the dhcpd

a run looks like this:

[root@q plan9]# qemu qemu.vesaroot & sleep 5&& dhcpd -d
[1] 4674
Connected to host network interface: tun1
Could not open '/dev/kqemu' - QEMU acceleration layer not activated
Internet Systems Consortium DHCP Server V3.0.2-RedHat
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 17 leases to leases file.
Listening on LPF/tun1/46:9c:6d:94:f5:1f/172.20.0/24
Sending on   LPF/tun1/46:9c:6d:94:f5:1f/172.20.0/24

No subnet declaration for ath0 (192.168.0.104).
** Ignoring requests on ath0.  If this is not what
    you want, please write a subnet declaration
    in your dhcpd.conf file for the network segment
    to which interface ath0 is attached. **

Sending on   Socket/fallback/fallback-net
DHCPDISCOVER from 52:54:00:12:34:56 via tun1
DHCPOFFER on 172.20.0.2 to 52:54:00:12:34:56 via tun1
Dynamic and static leases present for 172.20.0.2.
Remove host declaration qemu or remove 172.20.0.2
from the dynamic address pool for 172.20.0/24
DHCPREQUEST for 172.20.0.2 (172.20.0.1) from 52:54:00:12:34:56 via tun1
DHCPACK on 172.20.0.2 to 52:54:00:12:34:56 via tun1


(note the DHCPREQUEST -- that's my plan 9)
(the error message is unimportant)

OK, what's the config look like? dhcpd.conf:
subnet 172.20.0.0 netmask 255.255.255.0 {
               range 172.20.0.2 172.20.0.2 ;
               default-lease-time 600;
                  max-lease-time 7200;
               option subnet-mask 255.255.255.0;
                 option routers 172.20.0.1;
             }
host qemu {
         hardware ethernet 52:54:00:12:34:56;
         fixed-address xtest;
}

xtest is (from /etc/hosts):
172.20.0.2 xtest


ok but how did tun1 get configured? You need to set up /etc/qemu-ifup

[root@q etc]# cat /etc/qemu-ifup
#!/bin/sh
tun=$1
sudo /sbin/ifconfig $1 172.20.0.1
sudo /sbin/iptables -N nat
sudo /sbin/iptables -t nat -F
sudo /sbin/iptables -t nat -A POSTROUTING -s 172.20.0.1 -j MASQUERADE
sudo /sbin/iptables -t nat -A POSTROUTING -d 172.20.0.1 -o $tun
sudo echo 1 > /proc/sys/net/ipv4/ip_forward
[root@q etc]#


this allows me to drawterm into the plan 9 cpu server running on my laptop.

If this all works, then put it in the wiki :-) This is on FC4.

ron



--
Rodolfo García "kix"