2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 14:25:41 +00:00

- Duplicate dhclient-script updates for DHCPv6 to all provided scripts.

[ISC-Bugs #16875]
This commit is contained in:
David Hankins
2007-05-18 17:18:05 +00:00
parent 727cae264f
commit f66f02cc9c
6 changed files with 406 additions and 100 deletions

View File

@@ -1,101 +1,4 @@
#!/bin/bash
# dhclient-script for Linux. Dan Halbert, March, 1997.
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
# Updated for ipv6 by David W. Hankins, Janurary 2007.
ip=/sbin/ip
make_resolv_conf() {
if [ "x${new_dhcp6_name_servers}" != x ] ; then
cat /dev/null > /etc/resolv.conf.dhclient
chmod 644 /etc/resolv.conf.dhclient
if [ "x${new_dhcp6_domain_search}" != x ] ; then
echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient
fi
for nameserver in ${new_dhcp6_name_servers} ; do
echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
fi
}
# Check for valid constant input values.
if [ x${reason} = x ] || [ x${interface} = x ] ; then
exit 1;
fi
if [ ${reason} = PREINIT6 ] ; then
# Ensure interface is up.
${ip} link set ${interface} up
# Remove any stale addresses.
${ip} -f inet6 addr flush dev ${interface} scope global permanent
exit 0
fi
if [ ${reason} = BOUND6 ] ; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit 2;
fi
${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global
# Check for nameserver options.
make_resolv_conf
exit 0
fi
if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
make_resolv_conf
fi
exit 0
fi
if [ ${reason} = DEPREF6 ] ; then
if [ x${new_ip6_prefixlen} = x ] ; then
exit 2;
fi
# There doesn't appear to be a way to update an addr to indicate
# preference.
# ${ip} -f inet6 addr ??? ${new_ip6_address}/${new_ip6_prefixlen} \
# dev ${interface} scope global deprecated?
exit 0
fi
if [ ${reason} = EXPIRE6 ] ; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
exit 2;
fi
${ip} -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
dev ${interface}
exit 0
fi
# Old DHCPv4 script below, need to review and reintegrate.
exit
# dhclient-script for Linux. Dan Halbert, March, 1997.
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
# No guarantees about this. I'm a novice at the details of Linux
@@ -119,6 +22,9 @@ exit
# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
# of the $1 in its args.
# 'ip' just looks too weird. /sbin/ip looks less weird.
ip=/sbin/ip
make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
cat /dev/null > /etc/resolv.conf.dhclient
@@ -136,6 +42,18 @@ make_resolv_conf() {
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
cat /dev/null > /etc/resolv.conf.dhclient6
chmod 644 /etc/resolv.conf.dhclient6
if [ "x${new_dhcp6_domain_search}" != x ] ; then
echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
fi
for nameserver in ${new_dhcp6_name_servers} ; do
echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6
done
mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
fi
}
@@ -165,6 +83,10 @@ release=`expr $release : '\(.*\)\..*'`
relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
relmajor=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
###
### DHCPv4 Handlers
###
if [ x$new_broadcast_address != x ]; then
new_broadcast_arg="broadcast $new_broadcast_address"
fi
@@ -281,7 +203,6 @@ if [ x$reason = xTIMEOUT ]; then
ifconfig $interface inet $new_ip_address $new_subnet_arg \
$new_broadcast_arg
set $new_routers
############## what is -w in ping?
if ping -q -c 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
@@ -302,4 +223,68 @@ if [ x$reason = xTIMEOUT ]; then
exit_with_hooks 1
fi
###
### DHCPv6 Handlers
###
if [ ${reason} = PREINIT6 ] ; then
# Ensure interface is up.
${ip} link set ${interface} up
# Remove any stale addresses from aborted clients.
${ip} -f inet6 addr flush dev ${interface} scope global permanent
exit_with_hooks 0
fi
if [ ${reason} = BOUND6 ] ; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
make_resolv_conf
fi
exit_with_hooks 0
fi
if [ ${reason} = DEPREF6 ] ; then
if [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
# There doesn't appear to be a way to update an addr to indicate
# preference.
# ${ip} -f inet6 addr ??? ${new_ip6_address}/${new_ip6_prefixlen} \
# dev ${interface} scope global deprecated?
exit_with_hooks 0
fi
if [ ${reason} = EXPIRE6 ] ; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
dev ${interface}
exit_with_hooks 0
fi
exit_with_hooks 0