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

- A dhclient-script for MacOS X has been included, which enables

'dhclient -6' support. [ISC-Bugs #18204]
This commit is contained in:
David Hankins
2008-11-03 23:32:12 +00:00
parent d8e93d4d97
commit 236d3a996d
3 changed files with 224 additions and 0 deletions

26
README
View File

@@ -33,6 +33,8 @@ the ISC DHCP Distribution.
5.6 FreeBSD
5.7 NeXTSTEP
5.8 SOLARIS
5.9 AIX
5.10 MacOS X
6 SUPPORT
6.1 HOW TO REPORT BUGS
@@ -443,6 +445,30 @@ The ISC DHCP distribution does not include a dhclient-script for AIX--
AIX comes with a DHCP client. Contribution of a working dhclient-script
for AIX would be welcome.
MacOS X
The MacOS X system uses a TCP/IP stack derived from FreeBSD with a
user-friendly interface named the System Configuration Framework.
As it includes a builtin DHCPv4 client (you are better just using that),
this text is only about the DHCPv6 client (``dhclient -6 ...''). The DNS
configuration (domain search list and name servers' addresses) is managed
by a System Configuration agent, not by /etc/resolv.conf (which is a link
to /var/run/resolv.conf, which itself only reflects the internal state;
the System Configuration agent's Dynamic Store).
This means that modifying resolv.conf directly doesn't have the intended
effect, so the macos script sample uses its own resolv.conf.dhclient6 in
/var/run, and inserts the contents of this file into the System
Configuration agent. Because the System Configuration agent expects the
prefix along with the configured address, and a default router, this is
not usable (the DHCPv6 protocol does not today deliver this information).
Instead, ifconfig is directly used for address configuration.
Note the Dynamic Store (from which /var/run/resolv.conf is built) is
recomputed from scratch when the current location/set is changed, for
instance when a laptop is resumed from sleep. In this case running the
dhclient-script could reinstall the resolv.conf.dhclient6 configuration.
SUPPORT
The Internet Systems Consortium DHCP server is developed and distributed

View File

@@ -75,6 +75,9 @@ work on other platforms. Please report any problems and suggested fixes to
- The !inet_pton() call in res_mkupdrec was adjusted to '<= 0' as
inet_pton returns either 1, 0, or -1.
- A dhclient-script for MacOS X has been included, which enables
'dhclient -6' support.
Changes since 4.1.0a1
- Corrected list of failover state values in dhcpd man page.

195
client/scripts/macos Executable file
View File

@@ -0,0 +1,195 @@
#!/bin/sh
#
# $Id: macos,v 1.2 2008/11/03 23:32:12 dhankins Exp $
#
# automous run of this script will commit the DNS setting
#
if [ -x /usr/bin/logger ]; then
LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
else
LOGGER=echo
fi
to_commit="yes"
make_resolv_conf() {
to_commit="no"
if [ "x${new_dhcp6_name_servers}" != x ]; then
( cat /dev/null > /var/run/resolv.conf.dhclient6 )
exit_status=$?
if [ $exit_status -ne 0 ]; then
$LOGGER "Unable to create /var/run/resolv.conf.dhclient6: Error $exit_status"
else
if [ "x${new_dhcp6_domain_search}" != x ]; then
( echo search ${new_dhcp6_domain_search} >> /var/run/resolv.conf.dhclient6 )
exit_status=$?
fi
for nameserver in ${new_dhcp6_name_servers} ; do
if [ $exit_status -ne 0 ]; then
break
fi
( echo nameserver ${nameserver} >> /var/run/resolv.conf.dhclient6 )
exit_status=$?
done
if [ $exit_status -eq 0 ]; then
to_commit="force"
commit_resolv_conf
fi
fi
fi
}
# Try to commit /var/run/resolv.conf.dhclient6 contents to
# SystemConfiguration Dynamic Store
# Note this will be cleared by the next location change
commit_resolv_conf() {
if [ -f /var/run/resolv.conf.dhclient6 ]; then
if [ -x /usr/sbin/scutil ]; then
serviceID=`echo show State:/Network/Global/IPv6 | \
/usr/sbin/scutil | \
awk '/PrimaryService/ { print $3 }'`
echo $serviceID
if [ x$serviceID = x ]; then
$LOGGER "Can't find the primary IPv6 service"
else
tmp=`mktemp SC_dhclient6.XXXXXXXXXX`
echo list | /usr/sbin/scutil > /tmp/$tmp
grep -q State:/Network/Service/$serviceID/DNS /tmp/$tmp
grep_status=$?
if [ $grep_status -eq 0 ]; then
$LOGGER "DNS service already set in primary IPv6 service"
rm /tmp/$tmp
else
res=/var/run/resolv.conf.dhclient6
cp /dev/null /tmp/$tmp
grep -q '^nameserver' $res
grep_status=$?
if [ $grep_status -eq 0 ]; then
echo d.add ServerAddresses '*' \
`awk 'BEGIN { n="" } \
/^nameserver/ { n=n " " $2 } \
END { print n}' < $res` >> /tmp/$tmp
fi
grep -q '^search' $res
grep_status=$?
if [ $grep_status -eq 0 ]; then
echo d.add SearchDomains '*' \
`sed 's/^search//' < $res` >> /tmp/$tmp
fi
echo set State:/Network/Service/$serviceID/DNS >> /tmp/$tmp
echo quit >> /tmp/$tmp
cat /tmp/$tmp
/usr/sbin/scutil < /tmp/$tmp
rm /tmp/$tmp
fi
fi
else
$LOGGER "Can't find SystemConfiguration tools."
fi
else
if [ $to_commit = force ]; then
$LOGGER "Can't find /var/run/resolv.conf.dhclient6"
fi
fi
to_commit="done"
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# allow the local script to abort processing of this state
# local script must set exit_status variable to nonzero.
if [ $exit_status -ne 0 ]; then
exit $exit_status
fi
fi
if [ x$reason = xMEDIUM ]; then
eval "ifconfig $interface $medium"
eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
sleep 1
exit_with_hooks 0
fi
###
### DHCPv6 Handlers
###
if [ x$reason = xPREINIT6 ]; then
# Ensure interface is up.
ifconfig ${interface} up
# XXX: Remove any stale addresses from aborted clients.
exit_with_hooks 0
fi
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ]; then
echo Prefix $reason old=${old_ip6_prefix} new=${new_ip6_prefix}
exit_with_hooks 0
fi
if [ x$reason = xBOUND6 ]; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ]; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xRENEW6 ] || [ x$reason = xREBIND6 ]; 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 [ x$reason = xDEPREF6 ]; then
if [ x${new_ip6_address} = x ]; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${new_ip6_address} deprecated
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE6 -o x$reason = xRELEASE6 -o x$reason = xSTOP6 ]; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ]; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${old_ip6_address}/${old_ip6_prefixlen} -alias
exit_with_hooks 0
fi
if [ $to_commit = yes ]; then
commit_resolv_conf
fi
exit_with_hooks 0