|
|
db449ef |
#!/bin/bash
|
|
|
ee7ca6e |
#
|
|
|
ee7ca6e |
# dhclient-script: Network interface configuration script run by
|
|
|
ee7ca6e |
# dhclient based on DHCP client communication
|
|
|
ee7ca6e |
#
|
|
|
5ec8ece |
# Copyright (C) 2008, 2009, 2010 Red Hat, Inc.
|
|
|
ee7ca6e |
#
|
|
|
ee7ca6e |
# This program is free software; you can redistribute it and/or modify
|
|
|
ee7ca6e |
# it under the terms of the GNU General Public License as published by
|
|
|
ee7ca6e |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
ee7ca6e |
# (at your option) any later version.
|
|
|
ee7ca6e |
#
|
|
|
ee7ca6e |
# This program is distributed in the hope that it will be useful,
|
|
|
ee7ca6e |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ee7ca6e |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
ee7ca6e |
# GNU General Public License for more details.
|
|
|
ee7ca6e |
#
|
|
|
ee7ca6e |
# You should have received a copy of the GNU General Public License
|
|
|
ee7ca6e |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
ee7ca6e |
#
|
|
|
ee7ca6e |
# Author(s): David Cantrell <dcantrell@redhat.com>
|
|
|
ee7ca6e |
#
|
|
|
ee7ca6e |
# ----------
|
|
|
ee7ca6e |
# This script is a rewrite/reworking on dhclient-script originally
|
|
|
ee7ca6e |
# included as part of dhcp-970306:
|
|
|
db449ef |
# dhclient-script for Linux. Dan Halbert, March, 1997.
|
|
|
db449ef |
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
|
|
|
db449ef |
# Modified by David Cantrell <dcantrell@redhat.com> for Fedora and RHEL
|
|
|
ee7ca6e |
# ----------
|
|
|
ee7ca6e |
#
|
|
|
db449ef |
|
|
|
ee7ca6e |
PATH=/bin:/usr/bin:/sbin
|
|
|
ee7ca6e |
SAVEDIR=/var/lib/dhclient
|
|
|
db449ef |
|
|
|
ee7ca6e |
LOGFACILITY="local7"
|
|
|
ee7ca6e |
LOGLEVEL="notice"
|
|
|
db449ef |
|
|
|
580990a |
ETCDIR="/etc/dhcp"
|
|
|
580990a |
|
|
|
ee7ca6e |
logmessage() {
|
|
|
ee7ca6e |
msg="${1}"
|
|
|
ee7ca6e |
logger -p ${LOGFACILITY}.${LOGLEVEL} -t "NET" "dhclient: ${msg}"
|
|
|
ee7ca6e |
}
|
|
|
db449ef |
|
|
|
a2aab09 |
if [ -x /sbin/restorecon ]; then
|
|
|
a2aab09 |
fix_context() {
|
|
|
dbecea2 |
/sbin/restorecon ${1} >/dev/null 2>&1
|
|
|
a2aab09 |
}
|
|
|
a2aab09 |
else
|
|
|
a2aab09 |
fix_context() { :; }
|
|
|
a2aab09 |
fi
|
|
|
dbecea2 |
|
|
|
ee7ca6e |
save_previous() {
|
|
|
ee7ca6e |
origfile="${1}"
|
|
|
ee7ca6e |
savefile="${SAVEDIR}/${origfile##*/}.predhclient.${interface}"
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ ! -d ${SAVEDIR} ]; then
|
|
|
ee7ca6e |
mkdir -p ${SAVEDIR}
|
|
|
ee7ca6e |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -e ${origfile} ]; then
|
|
|
226011d |
contents="$(< ${origfile})"
|
|
|
226011d |
echo "${contents}" > ${savefile}
|
|
|
226011d |
rm -f ${origfile}
|
|
|
db449ef |
else
|
|
|
ee7ca6e |
echo > ${savefile}
|
|
|
db449ef |
fi
|
|
|
6961ce4 |
|
|
|
dbecea2 |
fix_context ${savefile}
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
94ec5da |
eventually_add_hostnames_domain_to_search() {
|
|
|
94ec5da |
# For the case when hostname for this machine has a domain that is not in domain_search list
|
|
|
94ec5da |
# 1) get a hostname with `ipcalc --hostname` or `hostname`
|
|
|
94ec5da |
# 2) get the domain from this hostname
|
|
|
94ec5da |
# 3) add this domain to search line in resolv.conf if it's not already
|
|
|
94ec5da |
# there (domain list that we have recently added there is a parameter of this function)
|
|
|
94ec5da |
# We can't do this directly when generating resolv.conf in make_resolv_conf(), because
|
|
|
94ec5da |
# we need to first save the resolv.conf with obtained values before we can call `ipcalc --hostname`.
|
|
|
94ec5da |
# See bug 637763
|
|
|
94ec5da |
search="${1}"
|
|
|
94ec5da |
if need_hostname; then
|
|
|
94ec5da |
status=1
|
|
|
94ec5da |
if [ -n "${new_ip_address}" ]; then
|
|
|
94ec5da |
eval $(/bin/ipcalc --silent --hostname ${new_ip_address} ; echo "status=$?")
|
|
|
94ec5da |
elif [ -n "${new_ip6_address}" ]; then
|
|
|
94ec5da |
eval $(/bin/ipcalc --silent --hostname ${new_ip6_address} ; echo "status=$?")
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
|
|
|
94ec5da |
if [ ${status} -eq 0 ]; then
|
|
|
94ec5da |
domain=$(echo $HOSTNAME | cut -s -d "." -f 2-)
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
else
|
|
|
94ec5da |
domain=$(hostname 2>/dev/null | cut -s -d "." -f 2-)
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
|
|
|
94ec5da |
if [ -n "${domain}" ] &&
|
|
|
94ec5da |
[ ! "${domain}" = "localdomain" ] &&
|
|
|
94ec5da |
[ ! "${domain}" = "localdomain6" ] &&
|
|
|
94ec5da |
[ ! "${domain}" = "(none)" ] &&
|
|
|
94ec5da |
[[ ! "${domain}" = *\ * ]]; then
|
|
|
94ec5da |
is_in="false"
|
|
|
94ec5da |
for s in ${search}; do
|
|
|
94ec5da |
if [ "${s}" = "${domain}" ] ||
|
|
|
94ec5da |
[ "${s}" = "${domain}." ]; then
|
|
|
94ec5da |
is_in="true"
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
done
|
|
|
94ec5da |
|
|
|
94ec5da |
if [ "${is_in}" = "false" ]; then
|
|
|
94ec5da |
# Add domain name to search list (#637763)
|
|
|
94ec5da |
sed -i -e "s/${search}/${search} ${domain}/" /etc/resolv.conf
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
}
|
|
|
94ec5da |
|
|
|
db449ef |
make_resolv_conf() {
|
|
|
ee7ca6e |
[ "${PEERDNS}" = "no" ] && return
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ "${reason}" = "RENEW" ] &&
|
|
|
ee7ca6e |
[ "${new_domain_name}" = "${old_domain_name}" ] &&
|
|
|
ee7ca6e |
[ "${new_domain_name_servers}" = "${old_domain_name_servers}" ]; then
|
|
|
db449ef |
return
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -n "${new_domain_name}" ] ||
|
|
|
ee7ca6e |
[ -n "${new_domain_name_servers}" ] ||
|
|
|
ee7ca6e |
[ -n "${new_domain_search}" ]; then
|
|
|
6961ce4 |
save_previous /etc/resolv.conf
|
|
|
a2aab09 |
rscf="$(mktemp ${TMPDIR:-/tmp}/XXXXXX)"
|
|
|
ee7ca6e |
echo "; generated by /sbin/dhclient-script" > ${rscf}
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -n "${SEARCH}" ]; then
|
|
|
94ec5da |
search="${SEARCH}"
|
|
|
6961ce4 |
else
|
|
|
ee7ca6e |
if [ -n "${new_domain_search}" ]; then
|
|
|
94ec5da |
# Remove instaces of \032 (#450042)
|
|
|
94ec5da |
search="${new_domain_search//\\032/ }"
|
|
|
ee7ca6e |
elif [ -n "${new_domain_name}" ]; then
|
|
|
2d59159 |
# Note that the DHCP 'Domain Name Option' is really just a domain
|
|
|
2d59159 |
# name, and that this practice of using the domain name option as
|
|
|
2d59159 |
# a search path is both nonstandard and deprecated.
|
|
|
94ec5da |
search="${new_domain_name}"
|
|
|
db449ef |
fi
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
94ec5da |
if [ -n "${search}" ]; then
|
|
|
94ec5da |
echo "search ${search}" >> $rscf
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
|
|
|
ee7ca6e |
if [ -n "${RES_OPTIONS}" ]; then
|
|
|
ee7ca6e |
echo "options ${RES_OPTIONS}" >> ${rscf}
|
|
|
d016d23 |
fi
|
|
|
d016d23 |
|
|
|
ee7ca6e |
for nameserver in ${new_domain_name_servers} ; do
|
|
|
ee7ca6e |
echo "nameserver ${nameserver}" >> ${rscf}
|
|
|
db449ef |
done
|
|
|
db449ef |
|
|
|
ee7ca6e |
change_resolv_conf ${rscf}
|
|
|
ee7ca6e |
rm -f ${rscf}
|
|
|
f1ade68 |
|
|
|
94ec5da |
if [ -n "${search}" ]; then
|
|
|
94ec5da |
eventually_add_hostnames_domain_to_search "${search}"
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
|
|
|
dbecea2 |
fix_context /etc/resolv.conf
|
|
|
f195973 |
elif [ -n "${new_dhcp6_name_servers}" ] ||
|
|
|
f195973 |
[ -n "${new_dhcp6_domain_search}" ]; then
|
|
|
f195973 |
save_previous /etc/resolv.conf
|
|
|
a2aab09 |
rscf="$(mktemp ${TMPDIR:-/tmp}/XXXXXX)"
|
|
|
f195973 |
echo "; generated by /sbin/dhclient-script" > ${rscf}
|
|
|
f195973 |
|
|
|
f195973 |
if [ -n "${SEARCH}" ]; then
|
|
|
94ec5da |
search="${SEARCH}"
|
|
|
f195973 |
else
|
|
|
f195973 |
if [ -n "${new_dhcp6_domain_search}" ]; then
|
|
|
94ec5da |
search="${new_dhcp6_domain_search//\\032/ }"
|
|
|
f195973 |
fi
|
|
|
f195973 |
fi
|
|
|
f195973 |
|
|
|
94ec5da |
if [ -n "${search}" ]; then
|
|
|
94ec5da |
echo "search ${search}" >> $rscf
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
|
|
|
f195973 |
if [ -n "${RES_OPTIONS}" ]; then
|
|
|
f195973 |
echo "options ${RES_OPTIONS}" >> ${rscf}
|
|
|
f195973 |
fi
|
|
|
f195973 |
|
|
|
9b3b260 |
shopt -s nocasematch
|
|
|
f195973 |
for nameserver in ${new_dhcp6_name_servers} ; do
|
|
|
9b3b260 |
# If the nameserver has a link-local address
|
|
|
9b3b260 |
# add a <zone_id> (interface name) to it.
|
|
|
9b3b260 |
if [[ "$nameserver" =~ ^fe80:: ]]
|
|
|
9b3b260 |
then
|
|
|
9b3b260 |
zone_id="%${interface}"
|
|
|
9b3b260 |
else
|
|
|
9b3b260 |
zone_id=
|
|
|
9b3b260 |
fi
|
|
|
9b3b260 |
echo "nameserver ${nameserver}$zone_id" >> ${rscf}
|
|
|
f195973 |
done
|
|
|
9b3b260 |
shopt -u nocasematch
|
|
|
f195973 |
|
|
|
f195973 |
change_resolv_conf ${rscf}
|
|
|
f195973 |
rm -f ${rscf}
|
|
|
f195973 |
|
|
|
94ec5da |
if [ -n "${search}" ]; then
|
|
|
94ec5da |
eventually_add_hostnames_domain_to_search "${search}"
|
|
|
94ec5da |
fi
|
|
|
94ec5da |
|
|
|
f195973 |
fix_context /etc/resolv.conf
|
|
|
db449ef |
fi
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
db449ef |
exit_with_hooks() {
|
|
|
ee7ca6e |
exit_status="${1}"
|
|
|
db449ef |
|
|
|
580990a |
if [ -x ${ETCDIR}/dhclient-exit-hooks ]; then
|
|
|
580990a |
. ${ETCDIR}/dhclient-exit-hooks
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
exit ${exit_status}
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
ee7ca6e |
quad2num() {
|
|
|
db449ef |
if [ $# -eq 4 ]; then
|
|
|
ee7ca6e |
let n="${1} << 24 | ${2} << 16 | ${3} << 8 | ${4}"
|
|
|
ee7ca6e |
echo "${n}"
|
|
|
db449ef |
return 0
|
|
|
ee7ca6e |
else
|
|
|
ee7ca6e |
echo "0"
|
|
|
ee7ca6e |
return 1
|
|
|
db449ef |
fi
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
ee7ca6e |
ip2num() {
|
|
|
ee7ca6e |
IFS="." quad2num ${1}
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
ee7ca6e |
num2ip() {
|
|
|
ee7ca6e |
let n="${1}"
|
|
|
ee7ca6e |
let o1="(n >> 24) & 0xff"
|
|
|
ee7ca6e |
let o2="(n >> 16) & 0xff"
|
|
|
ee7ca6e |
let o3="(n >> 8) & 0xff"
|
|
|
ee7ca6e |
let o4="n & 0xff"
|
|
|
ee7ca6e |
echo "${o1}.${o2}.${o3}.${o4}"
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
a21bc05 |
get_network_address() {
|
|
|
a21bc05 |
# get network address for the given IP address and (netmask or prefix)
|
|
|
ee7ca6e |
ip="${1}"
|
|
|
a21bc05 |
nm="${2}"
|
|
|
a21bc05 |
|
|
|
a21bc05 |
if [ -n "${ip}" -a -n "${nm}" ]; then
|
|
|
a21bc05 |
if [[ "${nm}" = *.* ]]; then
|
|
|
a21bc05 |
ipcalc -s -n ${ip} ${nm} | cut -d '=' -f 2
|
|
|
a21bc05 |
else
|
|
|
a21bc05 |
ipcalc -s -n ${ip}/${nm} | cut -d '=' -f 2
|
|
|
a21bc05 |
fi
|
|
|
a21bc05 |
fi
|
|
|
a21bc05 |
}
|
|
|
a21bc05 |
|
|
|
a21bc05 |
get_prefix() {
|
|
|
a21bc05 |
# get prefix for the given IP address and mask
|
|
|
a21bc05 |
ip="${1}"
|
|
|
a21bc05 |
nm="${2}"
|
|
|
a21bc05 |
|
|
|
a21bc05 |
if [ -n "${ip}" -a -n "${nm}" ]; then
|
|
|
a21bc05 |
ipcalc -s -p ${ip} ${nm} | cut -d '=' -f 2
|
|
|
a21bc05 |
fi
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
ee7ca6e |
class_bits() {
|
|
|
db449ef |
let ip=$(IFS='.' ip2num $1)
|
|
|
db449ef |
let bits=32
|
|
|
db449ef |
let mask='255'
|
|
|
db449ef |
for ((i=0; i <= 3; i++, 'mask<<=8')); do
|
|
|
db449ef |
let v='ip&mask'
|
|
|
db449ef |
if [ "$v" -eq 0 ] ; then
|
|
|
db449ef |
let bits-=8
|
|
|
db449ef |
else
|
|
|
db449ef |
break
|
|
|
db449ef |
fi
|
|
|
db449ef |
done
|
|
|
db449ef |
echo $bits
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
ee7ca6e |
is_router_reachable() {
|
|
|
ee7ca6e |
# handle DHCP servers that give us a router not on our subnet
|
|
|
ee7ca6e |
router="${1}"
|
|
|
a21bc05 |
routersubnet="$(get_network_address ${router} ${new_subnet_mask})"
|
|
|
a21bc05 |
mysubnet="$(get_network_address ${new_ip_address} ${new_subnet_mask})"
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
if [ ! "${routersubnet}" = "${mysubnet}" ]; then
|
|
|
b112ec7 |
ip -4 route add ${router}/32 dev ${interface}
|
|
|
b112ec7 |
if [ $? -eq 0 ]; then
|
|
|
b112ec7 |
if ping -q -c1 -w2 -I ${interface} ${router}; then
|
|
|
b112ec7 |
return 0
|
|
|
ee7ca6e |
else
|
|
|
b112ec7 |
logmessage "DHCP router ${router} is unreachable on DHCP subnet ${mysubnet} router subnet ${routersubnet}"
|
|
|
b112ec7 |
ip route del ${router}/32 dev ${interface}
|
|
|
b112ec7 |
return 1
|
|
|
ee7ca6e |
fi
|
|
|
db449ef |
else
|
|
|
b112ec7 |
logmessage "failed to create host router for unreachable router ${router} not on subnet ${mysubnet}"
|
|
|
b112ec7 |
return 1
|
|
|
db449ef |
fi
|
|
|
db449ef |
fi
|
|
|
ee7ca6e |
|
|
|
b112ec7 |
return 0
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
ee7ca6e |
add_default_gateway() {
|
|
|
ee7ca6e |
router="${1}"
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
if is_router_reachable ${router} ; then
|
|
|
a2aab09 |
metric=""
|
|
|
a2aab09 |
if [ $# -gt 1 ] && [ ${2} -gt 0 ]; then
|
|
|
a2aab09 |
metric="metric ${2}"
|
|
|
a2aab09 |
fi
|
|
|
5ec8ece |
ip -4 route replace default via ${router} dev ${interface} ${metric}
|
|
|
db449ef |
if [ $? -ne 0 ]; then
|
|
|
ee7ca6e |
logmessage "failed to create default route: ${router} dev ${interface} ${metric}"
|
|
|
db449ef |
return 1
|
|
|
db449ef |
else
|
|
|
db449ef |
return 0
|
|
|
db449ef |
fi
|
|
|
db449ef |
fi
|
|
|
ee7ca6e |
|
|
|
db449ef |
return 1
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
a2aab09 |
execute_client_side_configuration_scripts() {
|
|
|
a2aab09 |
# execute any additional client side configuration scripts we have
|
|
|
a2aab09 |
if [ "${1}" == "config" ] || [ "${1}" == "restore" ]; then
|
|
|
a2aab09 |
for f in ${ETCDIR}/dhclient.d/*.sh ; do
|
|
|
a2aab09 |
if [ -x ${f} ]; then
|
|
|
a2aab09 |
subsystem="${f%.sh}"
|
|
|
a2aab09 |
subsystem="${subsystem##*/}"
|
|
|
a2aab09 |
. ${f}
|
|
|
a2aab09 |
"${subsystem}_${1}"
|
|
|
a2aab09 |
fi
|
|
|
a2aab09 |
done
|
|
|
a2aab09 |
fi
|
|
|
a2aab09 |
}
|
|
|
a2aab09 |
|
|
|
d5a4ff8 |
flush_dev() {
|
|
|
d5a4ff8 |
# Instead of bringing the interface down (#574568)
|
|
|
d5a4ff8 |
# explicitly clear the ARP cache and flush all addresses & routes.
|
|
|
d5a4ff8 |
ip -4 addr flush dev ${1} >/dev/null 2>&1
|
|
|
d5a4ff8 |
ip -4 route flush dev ${1} >/dev/null 2>&1
|
|
|
d5a4ff8 |
ip -4 neigh flush dev ${1} >/dev/null 2>&1
|
|
|
d5a4ff8 |
}
|
|
|
d5a4ff8 |
|
|
|
ee7ca6e |
dhconfig() {
|
|
|
ee7ca6e |
if [ -n "${old_ip_address}" ] && [ -n "${alias_ip_address}" ] &&
|
|
|
ee7ca6e |
[ ! "${alias_ip_address}" = "${old_ip_address}" ]; then
|
|
|
ee7ca6e |
# possible new alias, remove old alias first
|
|
|
cd178b9 |
ip -4 addr del ${old_ip_address} dev ${interface} label ${interface}:0
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -n "${old_ip_address}" ] &&
|
|
|
ee7ca6e |
[ ! "${old_ip_address}" = "${new_ip_address}" ]; then
|
|
|
d5a4ff8 |
# IP address changed. Delete all routes, and clear the ARP cache.
|
|
|
d5a4ff8 |
flush_dev ${interface}
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
f7db77f |
if [ "${reason}" = "BOUND" ] || [ "${reason}" = "REBOOT" ] ||
|
|
|
ee7ca6e |
[ ! "${old_ip_address}" = "${new_ip_address}" ] ||
|
|
|
ee7ca6e |
[ ! "${old_subnet_mask}" = "${new_subnet_mask}" ] ||
|
|
|
ee7ca6e |
[ ! "${old_network_number}" = "${new_network_number}" ] ||
|
|
|
ee7ca6e |
[ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] ||
|
|
|
ee7ca6e |
[ ! "${old_routers}" = "${new_routers}" ] ||
|
|
|
ee7ca6e |
[ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
|
|
|
5ec8ece |
ip -4 addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
|
|
|
5ec8ece |
ip link set dev ${interface} up
|
|
|
ee7ca6e |
|
|
|
c402567 |
# The 576 MTU is only used for X.25 and dialup connections
|
|
|
c402567 |
# where the admin wants low latency. Such a low MTU can cause
|
|
|
c402567 |
# problems with UDP traffic, among other things. As such,
|
|
|
c402567 |
# disallow MTUs from 576 and below by default, so that broken
|
|
|
c402567 |
# MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
|
|
|
c402567 |
if [ -n "${new_interface_mtu}" ] && [ ${new_interface_mtu} -gt 576 ]; then
|
|
|
ee7ca6e |
ip link set ${interface} mtu ${new_interface_mtu}
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
580990a |
if [ -x ${ETCDIR}/dhclient-${interface}-up-hooks ]; then
|
|
|
580990a |
. ${ETCDIR}/dhclient-${interface}-up-hooks
|
|
|
580990a |
elif [ -x ${ETCDIR}/dhclient-up-hooks ]; then
|
|
|
580990a |
. ${ETCDIR}/dhclient-up-hooks
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
a21bc05 |
# static routes
|
|
|
a21bc05 |
if [ -n "${new_classless_static_routes}" ] ||
|
|
|
a21bc05 |
[ -n "${new_static_routes}" ]; then
|
|
|
a21bc05 |
if [ -n "${new_classless_static_routes}" ]; then
|
|
|
a21bc05 |
IFS=', |' static_routes=(${new_classless_static_routes})
|
|
|
a21bc05 |
else
|
|
|
a21bc05 |
IFS=', |' static_routes=(${new_static_routes})
|
|
|
a21bc05 |
fi
|
|
|
a21bc05 |
route_targets=()
|
|
|
a21bc05 |
|
|
|
a21bc05 |
for((i=0; i<${#static_routes[@]}; i+=2)); do
|
|
|
a21bc05 |
target=${static_routes[$i]}
|
|
|
a21bc05 |
if [ -n "${new_classless_static_routes}" ]; then
|
|
|
2560aa7 |
if [ ${target} = "0" ]; then
|
|
|
2560aa7 |
# If the DHCP server returns both a Classless Static Routes option and
|
|
|
2560aa7 |
# a Router option, the DHCP client MUST ignore the Router option. (RFC3442)
|
|
|
2560aa7 |
new_routers=""
|
|
|
2560aa7 |
prefix="0"
|
|
|
2560aa7 |
else
|
|
|
a2aab09 |
prefix=${target%%.*}
|
|
|
a2aab09 |
target=${target#*.}
|
|
|
2560aa7 |
IFS="." target_arr=(${target})
|
|
|
2560aa7 |
unset IFS
|
|
|
2560aa7 |
((pads=4-${#target_arr[@]}))
|
|
|
2560aa7 |
for j in $(seq $pads); do
|
|
|
5d3b86d |
target="${target}.0"
|
|
|
2560aa7 |
done
|
|
|
2560aa7 |
|
|
|
2560aa7 |
# Client MUST zero any bits in the subnet number where the corresponding bit in the mask is zero.
|
|
|
2560aa7 |
# In other words, the subnet number installed in the routing table is the logical AND of
|
|
|
2560aa7 |
# the subnet number and subnet mask given in the Classless Static Routes option. (RFC3442)
|
|
|
2560aa7 |
target="$(get_network_address ${target} ${prefix})"
|
|
|
2560aa7 |
fi
|
|
|
a21bc05 |
else
|
|
|
a21bc05 |
prefix=$(class_bits ${target})
|
|
|
a21bc05 |
fi
|
|
|
a21bc05 |
gateway=${static_routes[$i+1]}
|
|
|
a21bc05 |
|
|
|
c13ae11 |
# special case 0.0.0.0 to allow static routing for link-local addresses
|
|
|
4a2e0b7 |
# (including IPv4 multicast) which will not have a next-hop (#769463, #787318)
|
|
|
4a2e0b7 |
if [ "${gateway}" = "0.0.0.0" ]; then
|
|
|
4a2e0b7 |
valid_gateway=0
|
|
|
4a2e0b7 |
scope='scope link'
|
|
|
4a2e0b7 |
else
|
|
|
4a2e0b7 |
is_router_reachable ${gateway}
|
|
|
4a2e0b7 |
valid_gateway=$?
|
|
|
4a2e0b7 |
scope=''
|
|
|
4a2e0b7 |
fi
|
|
|
4a2e0b7 |
if [ ${valid_gateway} -eq 0 ]; then
|
|
|
a2aab09 |
metric=''
|
|
|
a2aab09 |
for t in ${route_targets[@]}; do
|
|
|
a2aab09 |
if [ ${t} = ${target} ]; then
|
|
|
a2aab09 |
if [ -z "${metric}" ]; then
|
|
|
a2aab09 |
metric=1
|
|
|
a2aab09 |
else
|
|
|
a2aab09 |
((metric=metric+1))
|
|
|
a2aab09 |
fi
|
|
|
a21bc05 |
fi
|
|
|
a2aab09 |
done
|
|
|
a21bc05 |
|
|
|
a2aab09 |
if [ -n "${metric}" ]; then
|
|
|
a2aab09 |
metric="metric ${metric}"
|
|
|
a2aab09 |
fi
|
|
|
a21bc05 |
|
|
|
4a2e0b7 |
ip -4 route replace ${target}/${prefix} proto static via ${gateway} dev ${interface} ${metric} ${scope}
|
|
|
a21bc05 |
|
|
|
a21bc05 |
if [ $? -ne 0 ]; then
|
|
|
a21bc05 |
logmessage "failed to create static route: ${target}/${prefix} via ${gateway} dev ${interface} ${metric}"
|
|
|
a21bc05 |
else
|
|
|
a21bc05 |
route_targets=(${route_targets[@]} ${target})
|
|
|
a21bc05 |
fi
|
|
|
a21bc05 |
fi
|
|
|
a21bc05 |
done
|
|
|
a21bc05 |
fi
|
|
|
a21bc05 |
|
|
|
a21bc05 |
# gateways
|
|
|
a2aab09 |
if [[ ( "${DEFROUTE}" != "no" ) &&
|
|
|
c13ae11 |
(( -z "${GATEWAYDEV}" ) || ( "${GATEWAYDEV}" = "${interface}" )) ]]; then
|
|
|
9ca442a |
if [[ ( -z "$GATEWAY" ) ||
|
|
|
c13ae11 |
(( -n "$DHCLIENT_IGNORE_GATEWAY" ) && ( "$DHCLIENT_IGNORE_GATEWAY" = [Yy]* )) ]]; then
|
|
|
9ca442a |
metric="${METRIC:-}"
|
|
|
9ca442a |
let i="${METRIC:-0}"
|
|
|
9ca442a |
default_routers=()
|
|
|
9ca442a |
|
|
|
9ca442a |
for router in ${new_routers} ; do
|
|
|
9ca442a |
added_router=-
|
|
|
9ca442a |
|
|
|
9ca442a |
for r in ${default_routers[@]} ; do
|
|
|
9ca442a |
if [ "${r}" = "${router}" ]; then
|
|
|
9ca442a |
added_router=1
|
|
|
9ca442a |
fi
|
|
|
9ca442a |
done
|
|
|
9ca442a |
|
|
|
9ca442a |
if [ -z "${router}" ] ||
|
|
|
9ca442a |
[ "${added_router}" = "1" ] ||
|
|
|
9ca442a |
[ $(IFS=. ip2num ${router}) -le 0 ] ||
|
|
|
9ca442a |
[[ ( "${router}" = "${new_broadcast_address}" ) &&
|
|
|
9ca442a |
( "${new_subnet_mask}" != "255.255.255.255" ) ]]; then
|
|
|
9ca442a |
continue
|
|
|
db449ef |
fi
|
|
|
9ca442a |
|
|
|
9ca442a |
default_routers=(${default_routers[@]} ${router})
|
|
|
9ca442a |
add_default_gateway ${router} ${metric}
|
|
|
9ca442a |
let i=i+1
|
|
|
9ca442a |
metric=${i}
|
|
|
db449ef |
done
|
|
|
9ca442a |
elif [ -n "${GATEWAY}" ]; then
|
|
|
a21bc05 |
routersubnet=$(get_network_address ${GATEWAY} ${new_subnet_mask})
|
|
|
a21bc05 |
mysubnet=$(get_network_address ${new_ip_address} ${new_subnet_mask})
|
|
|
db449ef |
|
|
|
9ca442a |
if [ "${routersubnet}" = "${mysubnet}" ]; then
|
|
|
5ec8ece |
ip -4 route replace default via ${GATEWAY} dev ${interface}
|
|
|
db449ef |
fi
|
|
|
db449ef |
fi
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ ! "${new_ip_address}" = "${alias_ip_address}" ] &&
|
|
|
ee7ca6e |
[ -n "${alias_ip_address}" ]; then
|
|
|
cd178b9 |
# Reset the alias address (fix: this should really only do this on changes)
|
|
|
cd178b9 |
ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
|
|
|
cd178b9 |
ip -4 addr add ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
|
|
|
cd178b9 |
ip -4 route replace ${alias_ip_address}/32 dev ${interface}
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
db449ef |
make_resolv_conf
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -n "${new_host_name}" ] && need_hostname; then
|
|
|
9115422 |
hostname ${new_host_name} || echo "See -nc option in dhclient(8) man page."
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
a2aab09 |
if [[ ( "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ) &&
|
|
|
a2aab09 |
( -n "${new_time_offset}" ) ]]; then
|
|
|
a2aab09 |
# DHCP option "time-offset" is requested by default and should be
|
|
|
a2aab09 |
# handled. The geographical zone abbreviation cannot be determined
|
|
|
a2aab09 |
# from the GMT offset, but the $ZONEINFO/Etc/GMT$offset file can be
|
|
|
a2aab09 |
# used - note: this disables DST.
|
|
|
a2aab09 |
((z=new_time_offset/3600))
|
|
|
a2aab09 |
((hoursWest=$(printf '%+d' $z)))
|
|
|
a2aab09 |
|
|
|
a2aab09 |
if (( $hoursWest < 0 )); then
|
|
|
a2aab09 |
# tzdata treats negative 'hours west' as positive 'gmtoff'!
|
|
|
a2aab09 |
((hoursWest*=-1))
|
|
|
a2aab09 |
fi
|
|
|
db449ef |
|
|
|
a2aab09 |
tzfile=/usr/share/zoneinfo/Etc/GMT$(printf '%+d' ${hoursWest})
|
|
|
a2aab09 |
if [ -e ${tzfile} ]; then
|
|
|
a2aab09 |
save_previous /etc/localtime
|
|
|
a2aab09 |
cp -fp ${tzfile} /etc/localtime
|
|
|
a2aab09 |
touch /etc/localtime
|
|
|
a2aab09 |
fix_context /etc/localtime
|
|
|
db449ef |
fi
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
a2aab09 |
execute_client_side_configuration_scripts "config"
|
|
|
db449ef |
}
|
|
|
db449ef |
|
|
|
2d59159 |
# Section 18.1.8. (Receipt of Reply Messages) of RFC 3315 says:
|
|
|
2d59159 |
# The client SHOULD perform duplicate address detection on each of
|
|
|
2d59159 |
# the addresses in any IAs it receives in the Reply message before
|
|
|
2d59159 |
# using that address for traffic.
|
|
|
2d59159 |
add_ipv6_addr_with_DAD() {
|
|
|
5ec8ece |
ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
|
|
|
f195973 |
dev ${interface} scope global
|
|
|
21b8c45 |
|
|
|
21b8c45 |
# repeatedly test whether newly added address passed
|
|
|
21b8c45 |
# duplicate address detection (DAD)
|
|
|
21b8c45 |
for i in $(seq 5); do
|
|
|
21b8c45 |
sleep 1 # give the DAD some time
|
|
|
21b8c45 |
|
|
|
21b8c45 |
# tentative flag = DAD is still not complete or failed
|
|
|
21b8c45 |
duplicate=$(ip -6 addr show dev ${interface} tentative \
|
|
|
21b8c45 |
| grep ${new_ip6_address}/${new_ip6_prefixlen})
|
|
|
21b8c45 |
|
|
|
21b8c45 |
# if there's no tentative flag, address passed DAD
|
|
|
21b8c45 |
if [ -z "${duplicate}" ]; then
|
|
|
21b8c45 |
break
|
|
|
21b8c45 |
fi
|
|
|
21b8c45 |
done
|
|
|
21b8c45 |
|
|
|
21b8c45 |
# if there's still tentative flag = address didn't pass DAD =
|
|
|
21b8c45 |
# = it's duplicate = remove it
|
|
|
21b8c45 |
if [ -n "${duplicate}" ]; then
|
|
|
21b8c45 |
ip -6 addr del ${new_ip6_address}/${new_ip6_prefixlen} dev ${interface}
|
|
|
21b8c45 |
exit_with_hooks 3
|
|
|
21b8c45 |
fi
|
|
|
2d59159 |
}
|
|
|
2d59159 |
|
|
|
2d59159 |
dh6config() {
|
|
|
5d3b86d |
if [ -n "${old_ip6_prefix}" ] ||
|
|
|
5d3b86d |
[ -n "${new_ip6_prefix}" ]; then
|
|
|
76c2a1e |
echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
|
|
|
76c2a1e |
exit_with_hooks 0
|
|
|
76c2a1e |
fi
|
|
|
76c2a1e |
|
|
|
2d59159 |
case "${reason}" in
|
|
|
2d59159 |
BOUND6)
|
|
|
b0cb903 |
if [ -z "${new_ip6_address}" ] ||
|
|
|
2d59159 |
[ -z "${new_ip6_prefixlen}" ]; then
|
|
|
2d59159 |
exit_with_hooks 2
|
|
|
2d59159 |
fi
|
|
|
2d59159 |
|
|
|
2d59159 |
add_ipv6_addr_with_DAD
|
|
|
21b8c45 |
|
|
|
f195973 |
make_resolv_conf
|
|
|
f195973 |
;;
|
|
|
f195973 |
|
|
|
f195973 |
RENEW6|REBIND6)
|
|
|
b0cb903 |
if [ -z "${new_ip6_address}" ] ||
|
|
|
b0cb903 |
[ -z "${new_ip6_prefixlen}" ]; then
|
|
|
b0cb903 |
exit_with_hooks 2
|
|
|
b0cb903 |
fi
|
|
|
b0cb903 |
|
|
|
b0cb903 |
if [ ! "${new_ip6_address}" = "${old_ip6_address}" ]; then
|
|
|
2d59159 |
add_ipv6_addr_with_DAD
|
|
|
2d59159 |
fi
|
|
|
2d59159 |
|
|
|
f195973 |
if [ ! "${new_dhcp6_name_servers}" = "${old_dhcp6_name_servers}" ] ||
|
|
|
f195973 |
[ ! "${new_dhcp6_domain_search}" = "${old_dhcp6_domain_search}" ]; then
|
|
|
f195973 |
make_resolv_conf
|
|
|
f195973 |
fi
|
|
|
f195973 |
;;
|
|
|
f195973 |
|
|
|
f195973 |
DEPREF6)
|
|
|
9726e0f |
if [ -z "${new_ip6_prefixlen}" ]; then
|
|
|
f195973 |
exit_with_hooks 2
|
|
|
f195973 |
fi
|
|
|
f195973 |
|
|
|
5ec8ece |
ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \
|
|
|
f195973 |
dev ${interface} scope global preferred_lft 0
|
|
|
f195973 |
;;
|
|
|
f195973 |
esac
|
|
|
f195973 |
|
|
|
a2aab09 |
execute_client_side_configuration_scripts "config"
|
|
|
f195973 |
}
|
|
|
f195973 |
|
|
|
db449ef |
|
|
|
ee7ca6e |
#
|
|
|
ee7ca6e |
# ### MAIN
|
|
|
ee7ca6e |
#
|
|
|
db449ef |
|
|
|
580990a |
if [ -x ${ETCDIR}/dhclient-enter-hooks ]; then
|
|
|
ee7ca6e |
exit_status=0
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
# dhclient-enter-hooks can abort dhclient-script by setting
|
|
|
ee7ca6e |
# the exit_status variable to a non-zero value
|
|
|
580990a |
. ${ETCDIR}/dhclient-enter-hooks
|
|
|
ee7ca6e |
if [ ${exit_status} -ne 0 ]; then
|
|
|
ee7ca6e |
exit ${exit_status}
|
|
|
ee7ca6e |
fi
|
|
|
a51a2cf |
fi
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
if [ ! -r /etc/sysconfig/network-scripts/network-functions ]; then
|
|
|
ee7ca6e |
echo "Missing /etc/sysconfig/network-scripts/network-functions, exiting." >&2
|
|
|
ee7ca6e |
exit 1
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ ! -r /etc/rc.d/init.d/functions ]; then
|
|
|
ee7ca6e |
echo "Missing /etc/rc.d/init.d/functions, exiting." >&2
|
|
|
ee7ca6e |
exit 1
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
. /etc/sysconfig/network-scripts/network-functions
|
|
|
ee7ca6e |
. /etc/rc.d/init.d/functions
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
if [ -f /etc/sysconfig/network ]; then
|
|
|
ee7ca6e |
. /etc/sysconfig/network
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -f /etc/sysconfig/networking/network ]; then
|
|
|
ee7ca6e |
. /etc/sysconfig/networking/network
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
cdcc09a |
cd /etc/sysconfig/network-scripts
|
|
|
cdcc09a |
CONFIG="ifcfg-${interface}"
|
|
|
ee7ca6e |
need_config ${CONFIG}
|
|
|
5c6578c |
source_config >/dev/null 2>&1
|
|
|
db449ef |
|
|
|
5c6578c |
new_prefix="$(get_prefix ${new_ip_address} ${new_subnet_mask})"
|
|
|
5ec8ece |
old_prefix="$(get_prefix ${old_ip_address} ${old_subnet_mask})"
|
|
|
5c6578c |
alias_prefix="$(get_prefix ${alias_ip_address} ${alias_subnet_mask})"
|
|
|
db449ef |
|
|
|
ee7ca6e |
case "${reason}" in
|
|
|
ee7ca6e |
MEDIUM)
|
|
|
ee7ca6e |
# Linux doesn't handle mediums (media)
|
|
|
ee7ca6e |
exit_with_hooks 0
|
|
|
ee7ca6e |
;;
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
PREINIT)
|
|
|
ee7ca6e |
if [ -n "${alias_ip_address}" ]; then
|
|
|
cd178b9 |
# Flush alias, its routes will disappear too.
|
|
|
cd178b9 |
ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
|
|
|
3aac9e5 |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ "${keep_old_ip}" = "yes" ]; then
|
|
|
5ec8ece |
ip link set ${interface} up
|
|
|
ee7ca6e |
else
|
|
|
5ec8ece |
ip -4 addr flush dev ${interface} >/dev/null 2>&1
|
|
|
5ec8ece |
ip link set ${interface} up
|
|
|
db449ef |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -n "${DHCLIENT_DELAY}" ] && [ ${DHCLIENT_DELAY} -gt 0 ]; then
|
|
|
ee7ca6e |
sleep ${DHCLIENT_DELAY}
|
|
|
3aac9e5 |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
exit_with_hooks 0
|
|
|
ee7ca6e |
;;
|
|
|
db449ef |
|
|
|
f195973 |
PREINIT6)
|
|
|
f195973 |
# ensure interface is up
|
|
|
f195973 |
ip link set ${interface} up
|
|
|
f195973 |
|
|
|
f195973 |
# remove any stale addresses from aborted clients
|
|
|
5ec8ece |
ip -6 addr flush dev ${interface} scope global permanent
|
|
|
f195973 |
|
|
|
f195973 |
exit_with_hooks 0
|
|
|
f195973 |
;;
|
|
|
f195973 |
|
|
|
ee7ca6e |
ARPCHECK|ARPSEND)
|
|
|
ee7ca6e |
if [ -z "${new_ip_address}" ] || [ -z "${interface}" ] ||
|
|
|
ee7ca6e |
arping -q -f -c 2 -w 3 -D -I ${interface} ${new_ip_address}; then
|
|
|
ee7ca6e |
exit_with_hooks 0
|
|
|
ee7ca6e |
else
|
|
|
ee7ca6e |
exit_with_hooks 1
|
|
|
db449ef |
fi
|
|
|
ee7ca6e |
;;
|
|
|
db449ef |
|
|
|
ee7ca6e |
BOUND|RENEW|REBIND|REBOOT)
|
|
|
ee7ca6e |
dhconfig
|
|
|
ee7ca6e |
exit_with_hooks 0
|
|
|
ee7ca6e |
;;
|
|
|
ee7ca6e |
|
|
|
f195973 |
BOUND6|RENEW6|REBIND6|DEPREF6)
|
|
|
f195973 |
dh6config
|
|
|
f195973 |
exit_with_hooks 0
|
|
|
f195973 |
;;
|
|
|
f195973 |
|
|
|
f195973 |
EXPIRE6|RELEASE6|STOP6)
|
|
|
152a496 |
if [ -z "${old_ip6_address}" ] || [ -z "${old_ip6_prefixlen}" ]; then
|
|
|
f195973 |
exit_with_hooks 2
|
|
|
f195973 |
fi
|
|
|
f195973 |
|
|
|
5ec8ece |
ip -6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
|
|
|
f195973 |
dev ${interface}
|
|
|
f195973 |
|
|
|
a2aab09 |
execute_client_side_configuration_scripts "restore"
|
|
|
f195973 |
|
|
|
f195973 |
if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
|
|
|
f195973 |
. ${ETCDIR}/dhclient-${interface}-down-hooks
|
|
|
f195973 |
elif [ -x ${ETCDIR}/dhclient-down-hooks ]; then
|
|
|
f195973 |
. ${ETCDIR}/dhclient-down-hooks
|
|
|
f195973 |
fi
|
|
|
f195973 |
|
|
|
f195973 |
exit_with_hooks 0
|
|
|
f195973 |
;;
|
|
|
f195973 |
|
|
|
ee7ca6e |
EXPIRE|FAIL|RELEASE|STOP)
|
|
|
ee7ca6e |
# only restore config files if there are no other dhclient processes
|
|
|
ee7ca6e |
# running (#306381)
|
|
|
c8c18ca |
dhclient_script_PID="$$"
|
|
|
c8c18ca |
dhclient_PID="${PPID}"
|
|
|
c8c18ca |
any_other_clients=$(ps -eo pid,ppid,comm | grep dhclient | grep -v -E "${dhclient_script_PID}|${dhclient_PID}")
|
|
|
b909aab |
if [ -z "${any_other_clients}" ]; then
|
|
|
ee7ca6e |
if [ -f ${SAVEDIR}/resolv.conf.predhclient.${interface} ]; then
|
|
|
ee7ca6e |
change_resolv_conf ${SAVEDIR}/resolv.conf.predhclient.${interface}
|
|
|
ee7ca6e |
rm -f ${SAVEDIR}/resolv.conf.predhclient.${interface}
|
|
|
ee7ca6e |
fi
|
|
|
db449ef |
|
|
|
a2aab09 |
if [[ ( "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ) &&
|
|
|
a2aab09 |
( -e ${SAVEDIR}/localtime.predhclient.${interface} ) ]]; then
|
|
|
a2aab09 |
rm -f /etc/localtime
|
|
|
a2aab09 |
contents="$(< ${SAVEDIR}/localtime.predhclient.${interface})"
|
|
|
a2aab09 |
echo "${contents}" > /etc/localtime
|
|
|
a2aab09 |
rm -f ${SAVEDIR}/localtime.predhclient.${interface}
|
|
|
a2aab09 |
touch /etc/localtime
|
|
|
a2aab09 |
fix_context /etc/localtime
|
|
|
ee7ca6e |
fi
|
|
|
dbecea2 |
fi
|
|
|
db449ef |
|
|
|
a2aab09 |
execute_client_side_configuration_scripts "restore"
|
|
|
db449ef |
|
|
|
580990a |
if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
|
|
|
580990a |
. ${ETCDIR}/dhclient-${interface}-down-hooks
|
|
|
580990a |
elif [ -x ${ETCDIR}/dhclient-down-hooks ]; then
|
|
|
580990a |
. ${ETCDIR}/dhclient-down-hooks
|
|
|
ee7ca6e |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -n "${alias_ip_address}" ]; then
|
|
|
cd178b9 |
# Flush alias
|
|
|
cd178b9 |
ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
|
|
|
ee7ca6e |
fi
|
|
|
db449ef |
|
|
|
ee7ca6e |
if [ -n "${old_ip_address}" ]; then
|
|
|
d5a4ff8 |
# Delete addresses/routes/arp cache.
|
|
|
d5a4ff8 |
flush_dev ${interface}
|
|
|
ee7ca6e |
fi
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
if [ -n "${alias_ip_address}" ]; then
|
|
|
cd178b9 |
ip -4 addr add ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
|
|
|
cd178b9 |
ip -4 route replace ${alias_ip_address}/32 dev ${interface}
|
|
|
ee7ca6e |
fi
|
|
|
db449ef |
|
|
|
db449ef |
exit_with_hooks 0
|
|
|
ee7ca6e |
;;
|
|
|
db449ef |
|
|
|
ee7ca6e |
TIMEOUT)
|
|
|
ee7ca6e |
if [ -n "${new_routers}" ]; then
|
|
|
ee7ca6e |
if [ -n "${alias_ip_address}" ]; then
|
|
|
cd178b9 |
ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
|
|
|
ee7ca6e |
fi
|
|
|
ee7ca6e |
|
|
|
5ec8ece |
ip -4 addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
|
|
|
ee7ca6e |
set ${new_routers}
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
if ping -q -c 1 -w 10 -I ${interface} ${1}; then
|
|
|
ee7ca6e |
dhconfig
|
|
|
ee7ca6e |
exit_with_hooks 0
|
|
|
ee7ca6e |
fi
|
|
|
ee7ca6e |
|
|
|
d5a4ff8 |
flush_dev ${interface}
|
|
|
ee7ca6e |
exit_with_hooks 1
|
|
|
ee7ca6e |
else
|
|
|
ee7ca6e |
exit_with_hooks 1
|
|
|
ee7ca6e |
fi
|
|
|
ee7ca6e |
;;
|
|
|
ee7ca6e |
|
|
|
ee7ca6e |
*)
|
|
|
ee7ca6e |
logmessage "unhandled state: ${reason}"
|
|
|
ee7ca6e |
exit_with_hooks 1
|
|
|
ee7ca6e |
;;
|
|
|
ee7ca6e |
esac
|
|
|
db449ef |
|
|
|
db449ef |
exit_with_hooks 0
|