[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-users] ip autoconfig via DIY script


  • To: "xen-users@xxxxxxxxxxxxx" <xen-users@xxxxxxxxxxxxx>
  • From: Mark Pryor <tlviewer@xxxxxxxxx>
  • Date: Sun, 18 Mar 2012 17:54:01 -0700 (PDT)
  • Delivery-date: Mon, 19 Mar 2012 00:55:17 +0000
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=4o45MuHgleOPlwvx1F0goCIFQmC43zyFhL8DE4KzuEKVZtV3b5dq2tPfAUA+P6agir6rYbitUHwk2NTzYjWEjEX6nJgGRTxFNf9Cahnh1McaXCYK08mi2Ke/KfpuWyQg34WL0MQ35lvthnFqEV3hfRMgcjUOQEdDWZAayDKKSqo=;
  • List-id: Xen user discussion <xen-users.lists.xen.org>

Hello,

Do I really need this hack?

I have a PV xen 4.1 domU. I want to use IP auto config.

In my xm config, I insert
------------------- xm config ----------

ip='10.0.2.5'
gateway='10.0.2.2'
server='127.0.255.255'
netmask='255.255.255.0'
hostname='natmin'
interface='eth0'
dhcp='off'
------------------ snip ---------------

None of the kernels I use have
CONFIG_IP_PNP

however the running domU has proc/cmdline with
   ip=10.0.2.5:127.0.255.255:10.0.2.2:255.255.255.0:natmin:eth0:off

if I have no config for eth0 in /etc/network/interfaces, I can use this script 
in 

domU /etc/rc.local to setup the domU network via domU


-------------------------- /etc/rc.local --------------
SCM=$(cat /proc/cmdline| grep -Po 'ip.*dhcp')
#echo ${#SCM} is len

# try dhcp first

if [ ${#SCM} -gt 0 ]; then
echo launching dhcp
dhclient eth0
fi

echo trying static
SCM=$(cat /proc/cmdline| grep -Po 'ip.*off')

# check cmdline for ip autoconfig
if [ ${#SCM} -gt 0 ]; then

SCM=${SCM#ip\=}
SCM=$(echo  $SCM | sed 's/:/ /g')

#${SCM//\:/\ }
j=0
for i in $SCM; do

echo  $i $j

case $j in
0)
     MIP=$i;;
1)
     echo ;;
2)
    MGATE=$i;;
3)
    MMASK=$i;;
4)
    MHOST=$i;;
5)
    MINT=$i;;

esac
j=$((j+1))
done

/sbin/ifconfig -a $MINT $MIP netmask $MMASK  up

sleep 1
/sbin/route add default gw $MGATE
echo $MHOST > /etc/hostname

fi


sleep 2
wget --spider http://192.168.1.1/favicon.ico?xendomU
exit 0


------------------------- snip ------------

-- 

Mark

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxx
http://lists.xen.org/xen-users


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.