1
0
mirror of synced 2026-02-01 14:02:11 +00:00

Use Dom0's resolv.conf unless nameserver is set.

If nameserver config option is not set (default value), copy Dom0's
/etc/resolv.conf on guest.
Provide a role to show how to customize /etc/resolv.conf in guest.
This commit is contained in:
Stéphane Jourdois
2010-07-18 16:12:32 +02:00
committed by Dmitry Nedospasov
parent ec26ac7c9f
commit 2e3924427e
12 changed files with 79 additions and 2 deletions

View File

@@ -237,6 +237,8 @@ xen-create-image - Easily create new Xen instances with networking and OpenSSH.
--nameserver="123.456.789.ABC 123.456.789.DEF"
Setup the nameserver of the machine, multiple space
separated nameservers are allowed.
If not provided, Dom0's /etc/resolv.conf will be copied
to guest.
--bridge=brname
Optionally, set a specific bridge for the new instance.
@@ -377,7 +379,6 @@ Create a Xen configuration file in so that xm can start the new domain.
gateway = 192.168.1.1
broadcast = 192.168.1.255
netmask = 255.255.255.0
nameserver = 192.168.1.1
#
@@ -1407,6 +1408,11 @@ sub setupDefaultOptions
$CONFIG{ 'mount_fs_xfs' } = '-t xfs';
$CONFIG{ 'mount_fs_reiserfs' } = '-t reiserfs';
#
# Network options.
#
$CONFIG{ 'nameserver' } = '';
}

View File

@@ -163,12 +163,21 @@ image = sparse # Specify sparse vs. full disk images.
# gateway = 192.168.1.1
# netmask = 255.255.255.0
# broadcast = 192.168.1.255
# nameserver = 192.168.1.1
#
# Uncomment this if you wish the images to use DHCP
#
# dhcp = 1
#
# Uncomment and adjust this setting if you wish to give your new
# instances a specific nameserver.
#
# By default, nameserver is not set, and Dom0's /etc/resolv.conf will
# be copied to guest.
#
# nameserver = 192.168.1.1
#
#
# Setup bridge name for host vif. Usefull if you use bridged networking
# for guests.

View File

@@ -83,6 +83,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
else
cat <<E_O_DHCP >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0

View File

@@ -83,6 +83,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
else
cat <<E_O_DHCP >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0

View File

@@ -123,6 +123,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -143,6 +143,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -132,6 +132,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -83,6 +83,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
else
cat <<E_O_DHCP >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0

View File

@@ -107,6 +107,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -132,6 +132,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -132,6 +132,8 @@ E_O_STATIC
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

44
roles/resolv Normal file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
#
# This role helps to customize guest's /etc/resolv.conf
#
prefix=$1
#
# Source our common functions - this will let us install a Debian package.
#
if [ -e /usr/lib/xen-tools/common.sh ]; then
. /usr/lib/xen-tools/common.sh
else
echo "Installation problem"
fi
#
# Log our start
#
logMessage Script $0 starting
#
# WARNING :
#
# resolv.conf is backed up as resolv.conf.old during roles execution to
# permit the chrooted guest to be able to resolve during installation.
# Use resolv.conf.old name during hooks, it will be correctly renamed
# after hooks execution
#
#
# Create Guest's resolv.conf as resolv.conf.old (see WARNING before) :
#
cat <<RESOLV_CONF_EOF >${prefix}/etc/resolv.conf.old
nameserver 192.168.1.1
#search domain.tld
RESOLV_CONF_EOF
#
# Log our finish
#
logMessage Script $0 finished