Must I use DHCP when creating a VM over network using virt-install?

I've just started to use virt-install and I seem to be unable to create a VM over the network when I define a static IP in the configuration file.  It fails to retrieve the install.img file, which is fair enough if it has no route to the file.  Can I define a static IP during this part of configuration?

The post section also fails, again due to routing, I suppose.  I could configure all this stuff later but I'd prefer to automate it during the initial creation.

Here is the command that I am using:

[root@qa-openstack02 ~]# virt-install -n mick-testVm --hvm -r 2048 --vcpus=1 --os-variant=rhel6 -v --disk path=/images/mick-testVm.img,size=20 -l http://10.10.12.254/CENTOS6.4-x86_64-ES -x "ks=http://10.10.12.254/client_files/openstack/image-templates/mick-testVm/mick-testVm.cfg text console=tty0 utf8 console=ttyS0,115200"

Here is the mick-testVm.cfg file:

#Generated by Kickstart Configurator
#platform=x86, AMD64, or Intel EM64T

#Skip Identification Number
key --skip

#Do not install X system
skipx

#System  language
lang en_IE.UTF-8

#System keyboard
keyboard uk

#Sytem timezone
timezone --utc Europe/Dublin

#Root password
rootpw --iscrypted $1$js7Kjkuf$I4pW./OZsqBLBnoAGajeK.

#Reboot after installation
reboot

#Install OS instead of upgrade
install

#Use HTTP installation Media
#http://10.10.12.254/CENTOS6.4-x86_64-ES

#System bootloader configuration
bootloader --location mbr --append "rhgb quiet"

#Clear the Master Boot Record
zerombr yes

#Partition clearing information
clearpart --all --initlabel
#Partioning information
part /boot      --fstype ext4   --size 200
part swap                       --size 2000
part pv.01      --fstype ext4   --size 1 --grow
#LVM information
volgroup sysvg pv.01
# The following line is for TEST only; must NOT be used in live environment!
logvol /        --vgname=sysvg --size=1 --grow --name=lv_root

#System authorization infomation
auth  --useshadow  --enablemd5

#Network information
#network --device eth0 --bootproto static --ip 10.10.12.253 --netmask 255.255.255.0 --gateway 10.10.12.1 --nameserver 10.10.9.6,10.10.9.7 --hostname mick-testVm
#network --device eth0 --bootproto static --ip 192.169.122.2 --netmask 255.255.255.0 --gateway 192.169.122.1 --nameserver 10.10.9.6,10.10.9.7 --hostname mick-testVm
network --device eth0 --bootproto dhcp

#Firewall configuration
firewall --disabled

#SELinux configuration
selinux --disabled

#Package install information
%packages
@arabic-support
@base
@core
@mail-server
@debugging
@development
@nfs-file-server
@network-file-system-client
@perl-runtime
@server-platform
@server-policy
ebtables
glibc
libgcc
libstdc++
nc
dos2unix
apr
apr-util
avahi
bridge-utils
fipscheck
device-mapper-multipath
sgpio
imake
compat-db
net-snmp-utils
sysstat
PyXML
httpd
perl-Compress-Zlib
perl-Convert-ASN1
perl-HTML-Parser
perl-HTML-Tagset
perl-libwww-perl
perl-Crypt-SSLeay
perl-CGI
libpcap
postgresql-libs
dbus-python
libdaemon
e2fsprogs-devel
keyutils-libs-devel
krb5-devel
libselinux-devel
libsepol-devel
openssl-devel
zlib-devel
mlocate
xinetd
tunctl
freetype
fontconfig
xorg-x11-filesystem
libICE
libSM
ncurses-devel
libXdmcp
libXau
libX11
libXrender
libXft
libXext
libXt
libXmu
libXpm
libXtst
libXaw
libtermcap-devel
libxml2
libxml2-devel
tk
ksh
dialog
expect
xterm
readline-devel
numactl
libcgroup
lksctp-tools
screen
-abrt-addon-ccpp
-abrt-addon-kerneloops
-abrt-addon-python
-abrt-cli
-alsa
-acpid
-ksh
-lftp
-aspell-en
-rhn-check
-words
-coolkey
-dhclient
-aspell
-mgetty
-ftp
-fbset
-dosfstools
-mdadm
-nano
-pcmciautils
-redhat-lsb
-pam_smb
-mtools
-pkinit-nss
-dhcpv6-client
-firstboot-tui
-NetworkManager
-mozldap
-rp-pppoe
-unix2dos
-mkbootdisk
-pam_krb5
-irda-utils
-amtu
-rng-utils
-jwhois
-rhn-setup
-system-config-network-tui
-smartmontools
-ccid
-tcsh
-anacron
-bluez-utils
-talk
-splint
-valgrind
-systemtap
-texinfo
-automake15
-python-ldap
-python-devel
-subversion
-byacc
-rcs
-automake16
-automake17
-automake14
-ctags
-dogtail
-dev86
-doxygen
-indent
-cvs
-cscope
-emacs-leim
-psgml
-emacspeak
-dovecot
-spamassassin
-zisofs-tools
-vnc
-xdelta
-OpenIPMI-tools
-samba-client
-bluez-hcidump
-zsh
-bluez-gnome
-automake
-wireless-tools
-newt-python
-newt

I commented this section during my last creation so that it would not stall.  I'd prefer to include it.

#%post
##!/bin/sh

# Disable CPU Scaling
#service cpuspeed stop; chkconfig cpuspeed off

# Copy configureVm.sh Script.
#wget http://10.10.12.254/mnt/scripts/configureVm.sh

# Miscellaneous.
#rpm -e --nodeps --allmatches automake-1.11.1-4.el6.noarch newt-0.52.11-3.el6.x86_64 newt-python-0.52.11-3.el6.x86_64
#yum install http://10.10.12.254/CENTOS6.4-x86_64-ES/Packages/gfs2-utils-*.x86_64.rpm
#yum install http://10.10.12.254/CENTOS6.4-x86_64-ES/Packages/glibc-2.12-1.107.el6.i686.rpm
#yum install http://10.10.12.254/CENTOS6.4-x86_64-ES/Packages/libgcc-4.4.7-3.el6.i686.rpm
#yum install http://10.10.12.254/CENTOS6.4-x86_64-ES/Packages/libstdc++-4.4.7-3.el6.i686.rpm
#yum install http://10.10.12.254/CENTOS6.4-x86_64-ES/Packages/nss-softokn-3.12.9-11.el6.i686.rpm
#yum install http://10.10.12.254/CENTOS6.4-x86_64-ES/Packages/initscripts-9.03.38-1.el6.centos.x86_64.rpm
#yum install http://10.10.12.254/mnt/jdk-7u5-linux-x64.rpm

#%end


Here is the host IP configuration:

[root@qa-openstack02 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1F:29:0A:7C:84
          inet addr:10.10.12.20  Bcast:10.10.12.255  Mask:255.255.255.0
          inet6 addr: fe80::21f:29ff:fe0a:7c84/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1663043 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1014036 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2327498658 (2.1 GiB)  TX bytes:73063196 (69.6 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1028 (1.0 KiB)  TX bytes:1028 (1.0 KiB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:07:3A:48
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:799796 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1301018 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:42171159 (40.2 MiB)  TX bytes:1858052000 (1.7 GiB)

vnet0     Link encap:Ethernet  HWaddr FE:54:00:38:CB:AB
          inet6 addr: fe80::fc54:ff:fe38:cbab/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:217620 errors:0 dropped:0 overruns:0 frame:0
          TX packets:351478 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:14542921 (13.8 MiB)  TX bytes:501125549 (477.9 MiB)

[root@qa-openstack02 ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.10.12.0      0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
0.0.0.0         10.10.12.1      0.0.0.0         UG        0 0          0 eth0

[root@qa-openstack02 ~]# service iptables status
Table: mangle
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination

Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
num  target     prot opt source               destination
1    CHECKSUM   udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:68 CHECKSUM fill

Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:53
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:53
3    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:67
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:67

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  0.0.0.0/0            192.168.122.0/24    state RELATED,ESTABLISHED
2    ACCEPT     all  --  192.168.122.0/24     0.0.0.0/0
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
4    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

Table: nat
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
num  target     prot opt source               destination
1    MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535
2    MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535
3    MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination
micktAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brad GrouxSenior Manager (Wintel Engineering)Commented:
I believe you need something along these lines, call the kickstart file and then set the ksdevice -

-x "ks=http://10.10.10.10/static/ks.cfg ksdevice=eth0 ip=10.10.20.10 

Open in new window

0
micktAuthor Commented:
Didn't work.  As soon as I remove the dhcp reference it is "Unable to download the kickstart file.", I suppose it has no route to it etc.  I can move the network definition from the file to the command but I still must use dhcp, i.e.

virt-install -n mick-testVm --hvm -r 2048 --vcpus=1 --os-variant=rhel6 -v --disk path=/images/mick-testVm.img,size=20 -l http://10.10.12.254/CENTOS6.4-x86_64-ES -x "ks=http://10.10.12.254/client_files/openstack/image-templates/mick-testVm/mick-testVm.cfg ksdevice=eth0         ---> ip=dhcp <---            text console=tty0 utf8 console=ttyS0,115200"

There is no need for ksdevice as I think the default is eth0.

So, I'm wondering what network is valid to use?  Host IPs are:

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1F:29:0A:7C:84
          inet addr:10.10.12.20  Bcast:10.10.12.255  Mask:255.255.255.0
          inet6 addr: fe80::21f:29ff:fe0a:7c84/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3343260 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16365243 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3546908352 (3.3 GiB)  TX bytes:22624041417 (21.0 GiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1180 (1.1 KiB)  TX bytes:1180 (1.1 KiB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:07:3A:48
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1148497 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1867827 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:60504646 (57.7 MiB)  TX bytes:2667736924 (2.4 GiB)

vnet1     Link encap:Ethernet  HWaddr FE:54:00:D3:56:A6
          inet6 addr: fe80::fc54:ff:fed3:56a6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1505 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:648 (648.0 b)  TX bytes:81110 (79.2 KiB)

I have tried IPs on both these networks.
0
Brad GrouxSenior Manager (Wintel Engineering)Commented:
What's in the KS file? I believe it should look something like this:
network --device eth0 --bootproto static --ip 10.10.10.XX --netmask 255.255.255.0 --gateway 10.10.10.1 --nameserver 10.10.10.1

Open in new window


Starting at CentOS 5, there a undocumented option that enable a prompt asking for network configuration during the installation. At the network statement, put the query keyword at the --bootproto= networking configuration, as we see below:

network --device=eth0 --bootproto=query

And a dialog box will appear asking for IP addressing, as well the hostname configuration.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

micktAuthor Commented:
It's at the top of screen, here is the relevant section.  I tried all but only dhcp works.  It's my standard ks file that I've used many times.

#Network information
#network --device eth0 --bootproto static --ip 10.10.12.253 --netmask 255.255.255.0 --gateway 10.10.12.1 --nameserver 10.10.9.6,10.10.9.7 --hostname mick-testVm
#network --device eth0 --bootproto static --ip 192.169.122.2 --netmask 255.255.255.0 --gateway 192.169.122.1 --nameserver 10.10.9.6,10.10.9.7 --hostname mick-testVm
network --device eth0 --bootproto dhcp

It may not be an issue with the definition but rather routing between host and VM etc.
0
micktAuthor Commented:
I've identified the issue.  A typo in the IP address; I typed 192.169.122.2 where I should have typed 192.168.122.2.
0
micktAuthor Commented:
Thanks for the response to Q, Brad.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Virtualization

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.