LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-28-2009, 11:24 AM   #1
andrewboring
LQ Newbie
 
Registered: Jun 2009
Location: Atlanta
Posts: 10

Rep: Reputation: 1
CentOS/Xen domU reverts to DHCP upon reboot


Hi,

I have a CentOS 5.2 dom0 running several CentOS domU guests with statically assigned IP addresses and LVM for their block devices.

The specific configuration I have for a domU:

name = "zimbra.lireo.net"
memory = "512"
disk = [ 'phy:vg00/lv04,xvda,w', ]
vif = [ 'bridge=xenbr0', ]
vcpus=1
bootloader="/usr/bin/pygrub"
on_reboot = 'restart'
on_crash = 'restart'

The IP address is configured in domU's /etc/sysconfig/network-scripts/ifcfg-eth0 and works properly.

However, if the domU is restarted for any reason, the configuration in domU reverts to DHCP, and is inaccessible from the Internet until I console in from dom0 and reset it.

[root@zimbra ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Xen Virtual Ethernet
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes


I tried changing the vif paramater in the domU's config above to the following:

vif = [ 'bridge=xenbr0', 'ipaddr=75.127.98.92', 'netmask=255.255.255.0' ]

But that gives me Invalid vif upon "xm create" command.


Questions:
1. Can I assign the IP address through Xen config file? If so, what's the correct format? (the Xensource wiki and CentOS/RHEL docs and the xmexamples don't give clear info on this).
2. If I can't, how do I get the IP address configured in the domU to persist across reboots, and NOT be reset to DHCP?


The Googling I've done so far all point to modifying the xen network-bridge script, but they're all mailing list posts from 2005. I suspect I'm missing something quite simple and obvious.

In the future, I'll probably set up DHCP to manage IP address assignments when I have enough Xen domUs to make it worth it. But with one dom0 and two or three personal-use domUs, I don't exactly need that just yet.
 
Old 06-29-2009, 11:58 AM   #2
Matey
Member
 
Registered: Jan 2009
Posts: 114

Rep: Reputation: 17
I use Xen on Ubuntu but I believe the answer is Yes you can and should use the domU's own configuration.(the config it uses AFTER booting) lol it gets confusing.
In Ubuntu the file to edit is /etc/network/interfaces (once you boot the xen domU /guest machine)

and the lines in there goes something like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 123.213.12.23
netmask 255.255.255.0
gateway 123.213.12.1

auto eth1
iface eth1 inet static
address 10.0.50.23
netmask 255.255.255.0

as you can see the # is the remarks and the IP addresses are set manually for eth0 and eth1 (in your case only eth0).

I have only seen DHCP used in the domU config file (The config file you use FOR Booting the xen guest/domU machine and in Ubuntu the xen directory is under /etc/)but I have not seen that for static IP. I guess the static IP should be configured within the xen guest machines.(the configuration it uses After it boots)

dhcp example in xen guest (domU config file):


# Networking
#
dhcp = 'dhcp'
vif = [ 'mac=00:16:3E:1D:24:00' ]

#

Sorry I am not very familiar with CentOS but they should be similar configuration

Last edited by Matey; 06-29-2009 at 12:03 PM.
 
Old 06-29-2009, 06:10 PM   #3
kbgreen72
LQ Newbie
 
Registered: Jan 2009
Posts: 2

Rep: Reputation: 0
You can assign static IP with xen. Try using ip instead of ipaddr. Also, you want to quote the entire string in brackets, not each parameter string. For example try:

vif= ["bridge=xenbr0,ip=75.127.98.92,netmask=255.255.255.0" ] <-- (you should probably add a "gateway=" to this and maybe a "mac=" just to keep everything sorted out)

That way, if you have 2 or more NICs, you add another quoted string separated by a comma for each interface.
 
Old 06-29-2009, 10:42 PM   #4
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 787
Blog Entries: 6

Rep: Reputation: 75
I suggest do all network configuration inside domU itself
dont config network inside xenhost for domU,

inside domU run system-config-network or you can edit this file directly
1) /etc/sysconfig/network
2) /etc/sysconfig/network-scripts/ifcfg-eth0

then reboot from it
 
Old 06-30-2009, 12:31 AM   #5
andrewboring
LQ Newbie
 
Registered: Jun 2009
Location: Atlanta
Posts: 10

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by routers View Post
I suggest do all network configuration inside domU itself
dont config network inside xenhost for domU,

inside domU run system-config-network or you can edit this file directly
1) /etc/sysconfig/network
2) /etc/sysconfig/network-scripts/ifcfg-eth0

then reboot from it
That's the problem. The ifcfg-eth0 file *is* configured inside the domU, but it completely reverts to DHCP on reboot. It's like something in Xen is forcing a DHCP configuration on all domUs.

This happens to all domUs on this box, by the way.
 
Old 06-30-2009, 12:44 AM   #6
andrewboring
LQ Newbie
 
Registered: Jun 2009
Location: Atlanta
Posts: 10

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by kbgreen72 View Post
You can assign static IP with xen. Try using ip instead of ipaddr. Also, you want to quote the entire string in brackets, not each parameter string. For example try:

vif= ["bridge=xenbr0,ip=75.127.98.92,netmask=255.255.255.0" ] <-- (you should probably add a "gateway=" to this and maybe a "mac=" just to keep everything sorted out)
Thanks kbgreen72. Using "ip=" instead of "ipaddr" got rid of that error. Though it didn't like the netmask argument (which I found out below needs to be set elsewhere). I removed the netmask and started the domU (gateway is already set in /etc/sysconfig/network in the domU itself...that at least is not being overwritten).

but again, upon boot, the ifcfg-eth0 file is reverted:

[root@zimbra ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Xen Virtual Ethernet
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=00:16:3e:60:88:65

So, something in Xen is setting this "default" DHCP configuration.
In the xmexample1 file, there is this:

Code:
# Set the kernel command line for the new domain.
# You only need to define the IP parameters and hostname if the domain's
# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
# You can use 'extra' to set the runlevel and custom environment
# variables used by custom rc scripts (e.g. VMID=, usr= ).

# Set if you want dhcp to allocate the IP address.
#dhcp="dhcp"
# Set netmask.
#netmask=
# Set default gateway.
#gateway=
# Set the hostname.
#hostname= "vm%d" % vmid
Since dhcp="dhcp" is NOT set in my domU config, and since the domU's IP address info *is* configured in /etc/sysconfig/network-scripts/ifcfg-eth0, it should work as currently configured. But something in Xen (as best I can tell) is still overwriting that file with a default DHCP configuration from somewhere.
 
Old 06-30-2009, 12:49 AM   #7
andrewboring
LQ Newbie
 
Registered: Jun 2009
Location: Atlanta
Posts: 10

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by Matey View Post
I use Xen on Ubuntu but I believe the answer is

...snip...

Sorry I am not very familiar with CentOS but they should be similar configuration
Thanks Matey. It sounds like your Ubuntu config is similar to my CentOS config (that is, the IP is configured *inside* domU and not in the domU config file residing on dom0).

So my question now is, "why is dom0 overriding domU's statically configured info for network addressing"?

That's the $64,000 question, which I hope will be answered by someone's $0.02 .
 
Old 09-21-2009, 04:01 AM   #8
rbou
LQ Newbie
 
Registered: Sep 2009
Posts: 1

Rep: Reputation: 0
I exactly have the same problem, and same conf as you...
As far as I went on googling this problem I only could guess it comes from CentOS as domU which can't get static ip when rebooting.
I know my answer sounds like a joke but I really can't find anything else,
Did you find any clue or answer to that problem ?
 
Old 09-22-2009, 05:31 AM   #9
Matey
Member
 
Registered: Jan 2009
Posts: 114

Rep: Reputation: 17
Quote:
Originally Posted by andrewboring View Post
Thanks Matey. It sounds like your Ubuntu config is similar to my CentOS config (that is, the IP is configured *inside* domU and not in the domU config file residing on dom0).

So my question now is, "why is dom0 overriding domU's statically configured info for network addressing"?

That's the $64,000 question, which I hope will be answered by someone's $0.02 .
That is a good question, I think the one (configuration) that gets executed Last is the one that sticks!

I think the configurations in the Xen script is necessary for the guest machine to boot (not 100% sure but taking a guess) but once it boots the kernel file takes over and tells it to look under /etc for configurations just like any other machine.

I usually mount the xen guest machine at /mnt/xen/ directory then do a chroot to it then I make changes to configurations (set root password and hostname too) and then exit, umount it then xm create -c it.

regards;

Last edited by Matey; 09-22-2009 at 05:33 AM.
 
Old 09-23-2009, 12:23 PM   #10
andrewboring
LQ Newbie
 
Registered: Jun 2009
Location: Atlanta
Posts: 10

Original Poster
Rep: Reputation: 1
Well, I found a partial solution since then, but never found the exact cause yet.

This install was largely to learn Xen and test for use with certain clients (the people kind, not the network kind). I used a couple of HOWTOforge/Linuxtopia guides for the set up, ,which were based on xm commands to load an installer image rather than using RHEL/CentOS libvirt tools . Since then, I've installed a newer machine that will go into production and used the Red Hat documentation to set up the Xen guests using virt-install/virt-manager.

The guests I configured with virt-install do not suffer from this problem, so it's probably something with the way the network is set up from the various guides I originally followed.

So my original problem is resolved.
 
Old 10-25-2009, 12:04 PM   #11
gjanssens
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 1
Post

I just stumbled on your question.

The problem is most likely that you are not specifying a mac address for the vif in you domU configuration.

Try:
Code:
vif= ["bridge=xenbr0,mac=00:16:3e:xx:xx:xx" ]
Where x can be any hexadecimal digit (0-F).

If you don't specify a mac address explicitly, xen will generate another one each time the domU is created. Since the mac address has changed, CentOS detects the nic as a new nic (and the old one is considered removed from the machine). CentOS will try to autoconfigure this new nic, and for that it chooses dhcp.
This is much the same as would happen with real physical hardware actually. If you swap a network card in an ordinary server, CentOS will remove the configuration for the old nic and create a new configuration for the new one.

So see if setting a fixed mac address for your domU solves the issue. This is what virt-install does as well, by the way.

Hopefully this answers your $64,000 question.
 
Old 10-25-2009, 12:05 PM   #12
gjanssens
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 1
Quote:
Originally Posted by gjanssens View Post
The problem is most likely that you are not specifying a mac address for the vif in you domU configuration.

Try:
Code:
vif= ["bridge=xenbr0,mac=00:16:3e:xx:xx:xx" ]
As a sidenote, the choice of these numbers comes from the xen networking wiki. You could use any mac address, but this series is reserved for xen use.
 
Old 02-01-2011, 12:13 AM   #13
dariusb12
LQ Newbie
 
Registered: Feb 2011
Posts: 9

Rep: Reputation: 1
Old post but you solved the same problem I had with KVM using virt-install (copy and existing image and using --import caused a new ifcfg-eth0 file to be created with DHCP).

Thanks gjanssens!
 
  


Reply

Tags
centos, xen


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Xen CentOS domU / guest on OpenSuSE? jantman Linux - Software 2 01-11-2010 11:01 AM
LXer: Install Fedora 10 PV DomU at Xen 3.3.1 CentOS 5.2 & Xen 3.3.0 Intrepid Server v LXer Syndicated Linux News 0 01-10-2009 11:40 AM
LXer: PV-Grub on CentOS 5.2 PV DomU at Xen 3.3 CentOS 5.2 Dom0 (all 64-bit) LXer Syndicated Linux News 0 10-05-2008 10:12 PM
LXer: PV-Grub on OpenSuse 11 PV DomU at Xen 3.3 CentOS Dom0 (all 64-bit) LXer Syndicated Linux News 0 09-23-2008 09:50 AM
LXer: Vncserver on SNV97 DomU at Xen 3.3 CentOS 5.2 Dom0 (64-bit) LXer Syndicated Linux News 0 09-07-2008 02:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration