qemu in SLIRP mode offers DHCP services to the appliance. We don't
use them, but use a fixed IP address intead. This changes the
appliance to get its IP address using DHCP.
Note: This is only used when the network is enabled. dhclient is
somewhat slower, but the penalty (a few seconds) is only paid for
network users.
On SuSE or other distros, dhcpcd could be used if available.
---
appliance/init | 13 +++++++------
appliance/packagelist.in | 6 ++++++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/appliance/init b/appliance/init
index 6d62338..f719a72 100755
--- a/appliance/init
+++ b/appliance/init
@@ -79,12 +79,13 @@ hwclock -u -s
ip addr add 127.0.0.1/8 brd + dev lo scope host
ip link set dev lo up
-ip addr add 169.254.2.10/16 brd + dev eth0 scope global
-ip link set dev eth0 up
-
-ip route add default via 169.254.2.2
-
-echo nameserver 169.254.2.3 > /etc/resolv.conf
+if grep -sq guestfs_network=1 /proc/cmdline; then
+ if dhclient --version >/dev/null 2>&1; then
+ dhclient
+ else
+ dhcpcd
+ fi
+fi
# Scan for MDs.
mdadm -As --auto=yes --run
diff --git a/appliance/packagelist.in b/appliance/packagelist.in
index 276b4c2..27bcc11 100644
--- a/appliance/packagelist.in
+++ b/appliance/packagelist.in
@@ -27,6 +27,7 @@ ifelse(REDHAT,1,
btrfs-progs
cryptsetup
cryptsetup-luks dnl old name used before Fedora 17
+ dhclient
dnl e4fsprogs only exists on RHEL 5, will be ignored everywhere else.
e4fsprogs
genisoimage
@@ -73,6 +74,7 @@ dnl iproute has been renamed to iproute2
iputils-ping
iputils-arping
iputils-tracepath
+ isc-dhcp-client
libaugeas0
libc-bin
libcap2
@@ -102,6 +104,7 @@ ifelse(ARCHLINUX,1,
btrfs-progs
cdrkit
cryptsetup
+ dhclient
grub
hivex
iproute2
@@ -130,6 +133,7 @@ ifelse(SUSE,1,
augeas-lenses
btrfsprogs
cryptsetup
+ dhcpcd
genisoimage
glibc-locale
gptfdisk
@@ -150,6 +154,7 @@ ifelse(FRUGALWARE,1,
btrfs-progs
cryptsetup-luks
cdrkit
+ dhclient
grub2
hfsplus
iproute2
@@ -177,6 +182,7 @@ ifelse(MAGEIA,1,
chkconfig /* for /etc/init.d */
cdrkit-genisoimage
cdrkit-isotools
+ dhclient
extlinux
gfs2-utils
grub
--
2.0.4