first commit
This commit is contained in:
38
etc_org/dhcp/debug
Normal file
38
etc_org/dhcp/debug
Normal file
@ -0,0 +1,38 @@
|
||||
#
|
||||
# The purpose of this script is just to show the variables that are
|
||||
# available to all the scripts in this directory. All these scripts are
|
||||
# called from dhclient-script, which exports all the variables shown
|
||||
# before. If you want to debug a problem with your DHCP setup you can
|
||||
# enable this script and take a look at /tmp/dhclient-script.debug.
|
||||
|
||||
# To enable this script set the following variable to "yes"
|
||||
RUN="no"
|
||||
|
||||
if [ "$RUN" = "yes" ]; then
|
||||
echo "$(date): entering ${1%/*}, dumping variables." \
|
||||
>> /tmp/dhclient-script.debug
|
||||
|
||||
# loop over the 4 possible prefixes: (empty), cur_, new_, old_
|
||||
for prefix in '' 'cur_' 'new_' 'old_'; do
|
||||
# loop over the DHCP variables passed to dhclient-script
|
||||
for basevar in reason interface medium alias_ip_address \
|
||||
ip_address host_name network_number subnet_mask \
|
||||
broadcast_address routers static_routes \
|
||||
rfc3442_classless_static_routes \
|
||||
domain_name domain_search domain_name_servers \
|
||||
netbios_name_servers netbios_scope \
|
||||
ntp_servers \
|
||||
ip6_address ip6_prefix ip6_prefixlen \
|
||||
dhcp6_domain_search dhcp6_name_servers ; do
|
||||
var="${prefix}${basevar}"
|
||||
eval "content=\$$var"
|
||||
|
||||
# show only variables with values set
|
||||
if [ -n "${content}" ]; then
|
||||
echo "$var='${content}'" >> /tmp/dhclient-script.debug
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo '--------------------------' >> /tmp/dhclient-script.debug
|
||||
fi
|
31
etc_org/dhcp/dhclient-enter-hooks.d/avahi-autoipd
Executable file
31
etc_org/dhcp/dhclient-enter-hooks.d/avahi-autoipd
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This file is part of avahi.
|
||||
#
|
||||
# avahi is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# avahi is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with avahi; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
# USA.
|
||||
|
||||
case "$reason" in
|
||||
MEDIUM|ARPCHECK|ARPSEND|NBI)
|
||||
;;
|
||||
|
||||
PREINIT|BOUND|RENEW|REBIND|REBOOT|STOP|RELEASE)
|
||||
/usr/sbin/avahi-autoipd -k $interface 2> /dev/null
|
||||
;;
|
||||
|
||||
EXPIRE|FAIL|TIMEOUT)
|
||||
# Starting avahi-autoipd is left for the exit hook
|
||||
;;
|
||||
esac
|
1
etc_org/dhcp/dhclient-enter-hooks.d/debug
Symbolic link
1
etc_org/dhcp/dhclient-enter-hooks.d/debug
Symbolic link
@ -0,0 +1 @@
|
||||
../debug
|
81
etc_org/dhcp/dhclient-enter-hooks.d/resolvconf
Normal file
81
etc_org/dhcp/dhclient-enter-hooks.d/resolvconf
Normal file
@ -0,0 +1,81 @@
|
||||
#
|
||||
# Script fragment to make dhclient supply nameserver information to resolvconf
|
||||
#
|
||||
|
||||
# Tips:
|
||||
# * Be careful about changing the environment since this is sourced
|
||||
# * This script fragment uses bash features
|
||||
# * As of isc-dhcp-client 4.2 the "reason" (for running the script) can be one of the following.
|
||||
# (Listed on man page:) MEDIUM(0) PREINIT(0) BOUND(M) RENEW(M) REBIND(M) REBOOT(M) EXPIRE(D) FAIL(D) RELEASE(D) STOP(D) NBI(-) TIMEOUT(M)
|
||||
# (Also used in master script:) ARPCHECK(0), ARPSEND(0)
|
||||
# (Also used in master script:) PREINIT6(0) BOUND6(M) RENEW6(M) REBIND6(M) DEPREF6(0) EXPIRE6(D) RELEASE6(D) STOP6(D)
|
||||
# (0) = master script does not run make_resolv_conf
|
||||
# (M) = master script runs make_resolv_conf
|
||||
# (D) = master script downs interface
|
||||
# (-) = master script does nothing with this
|
||||
|
||||
if [ -x /sbin/resolvconf ] ; then
|
||||
# For safety, first undefine the nasty default make_resolv_conf()
|
||||
make_resolv_conf() { : ; }
|
||||
case "$reason" in
|
||||
BOUND|RENEW|REBIND|REBOOT|TIMEOUT)
|
||||
# Define a resolvconf-compatible m_r_c() function
|
||||
# It gets run later (or, in the TIMEOUT case, MAY get run later)
|
||||
make_resolv_conf() {
|
||||
local R
|
||||
local N
|
||||
R=""
|
||||
if [ "$new_domain_name_servers" ] && [ "$new_domain_name" ] ; then
|
||||
R="${R}domain $new_domain_name
|
||||
"
|
||||
fi
|
||||
if [ "$new_domain_name_servers" ] && [ "$new_domain_search" ] ; then
|
||||
R="${R}search $new_domain_search
|
||||
"
|
||||
fi
|
||||
for N in $new_domain_name_servers ; do
|
||||
R="${R}nameserver $N
|
||||
"
|
||||
done
|
||||
[ ! "$interface" ] || echo -n "$R" | /sbin/resolvconf -a "${interface}.dhclient"
|
||||
}
|
||||
;;
|
||||
BOUND6|RENEW6|REBIND6)
|
||||
# Define a resolvconf-compatible m_r_c() function
|
||||
# It gets run later (or, in the TIMEOUT case, MAY get run later)
|
||||
make_resolv_conf() {
|
||||
local R
|
||||
local N
|
||||
local N_LOW
|
||||
local ZONE_ID
|
||||
R=""
|
||||
if [ "$new_dhcp6_name_servers" ] && [ "$new_dhcp6_domain_search" ] ; then
|
||||
R="${R}search $new_dhcp6_domain_search
|
||||
"
|
||||
fi
|
||||
for N in $new_dhcp6_name_servers ; do
|
||||
|
||||
# If the nameserver has a link-local address
|
||||
# then add a zone ID (interface name) to it.
|
||||
N_LOW="$(echo "$N" | tr '[:upper:]' '[:lower:]')"
|
||||
if expr "$N_LOW" : ^fe80:: >/dev/null ; then
|
||||
ZONE_ID="%$interface"
|
||||
else
|
||||
ZONE_ID=""
|
||||
fi
|
||||
R="${R}nameserver $N$ZONE_ID
|
||||
"
|
||||
done
|
||||
[ ! "$interface" ] || echo -n "$R" | /sbin/resolvconf -a "${interface}.ip6.dhclient"
|
||||
}
|
||||
;;
|
||||
EXPIRE|FAIL|RELEASE|STOP)
|
||||
# Delete resolv.conf info
|
||||
[ ! "$interface" ] || /sbin/resolvconf -d "${interface}.dhclient"
|
||||
;;
|
||||
EXPIRE6|RELEASE6|STOP6)
|
||||
# Delete resolv.conf info
|
||||
[ ! "$interface" ] || /sbin/resolvconf -d "${interface}.ip6.dhclient"
|
||||
;;
|
||||
esac
|
||||
fi
|
75
etc_org/dhcp/dhclient-enter-hooks.d/samba
Executable file
75
etc_org/dhcp/dhclient-enter-hooks.d/samba
Executable file
@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
|
||||
SAMBA_DHCP_CONF=/etc/samba/dhcp.conf
|
||||
|
||||
netbios_setup() {
|
||||
# No need to continue if we're called with an unsupported option
|
||||
|
||||
case $reason in
|
||||
BOUND|RENEW|REBIND|REBOOT|EXPIRE|FAIL|RELEASE|STOP)
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
umask 022
|
||||
|
||||
local other_servers=""
|
||||
local serverlist=""
|
||||
|
||||
# the destination file won't exist yet on the first run after
|
||||
# installing samba
|
||||
if [ -e $SAMBA_DHCP_CONF ] && [ -s $SAMBA_DHCP_CONF ]
|
||||
then
|
||||
# don't continue if no settings have changed
|
||||
if [ "$new_netbios_name_servers" = "$old_netbios_name_servers" ] \
|
||||
&& [ "$new_netbios_scope" = "$old_netbios_scope" ] \
|
||||
&& [ -n "$new_netbios_name_servers" ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
# reparse our own file
|
||||
other_servers=`sed -n -e"s/[[:space:]]$interface:[^[:space:]]*//g; \
|
||||
s/^[[:space:]]*wins server[[:space:]]*=[[:space:]]*//pi" \
|
||||
$SAMBA_DHCP_CONF`
|
||||
|
||||
serverlist="$other_servers"
|
||||
fi
|
||||
|
||||
for server in $new_netbios_name_servers
|
||||
do
|
||||
serverlist="$serverlist $interface:$server"
|
||||
done
|
||||
|
||||
echo -n > ${SAMBA_DHCP_CONF}.new
|
||||
|
||||
# If we're updating on failure/expire, AND there are no WINS
|
||||
# servers for other interfaces, leave the file empty.
|
||||
if [ -z "$other_servers" ]
|
||||
then
|
||||
if [ "$reason" = FAIL ] || [ "$reason" = EXPIRE ]
|
||||
then
|
||||
mv ${SAMBA_DHCP_CONF}.new $SAMBA_DHCP_CONF
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$serverlist" ]
|
||||
then
|
||||
echo " wins server =$serverlist" >> ${SAMBA_DHCP_CONF}.new
|
||||
fi
|
||||
if [ -n "$new_netbios_scope" ]
|
||||
then
|
||||
echo " netbios scope = $new_netbios_scope" >> ${SAMBA_DHCP_CONF}.new
|
||||
fi
|
||||
mv ${SAMBA_DHCP_CONF}.new $SAMBA_DHCP_CONF
|
||||
|
||||
# reload the samba server
|
||||
# We don't necessarily have the samba package installed. #414841
|
||||
[ -x /etc/init.d/smbd ] && /usr/sbin/invoke-rc.d smbd reload
|
||||
|
||||
}
|
||||
|
||||
netbios_setup
|
1
etc_org/dhcp/dhclient-exit-hooks.d/debug
Symbolic link
1
etc_org/dhcp/dhclient-exit-hooks.d/debug
Symbolic link
@ -0,0 +1 @@
|
||||
../debug
|
64
etc_org/dhcp/dhclient-exit-hooks.d/ntp
Normal file
64
etc_org/dhcp/dhclient-exit-hooks.d/ntp
Normal file
@ -0,0 +1,64 @@
|
||||
NTP_CONF=/etc/ntp.conf
|
||||
NTP_DHCP_CONF=/var/lib/ntp/ntp.conf.dhcp
|
||||
|
||||
|
||||
ntp_server_restart() {
|
||||
invoke-rc.d ntp try-restart
|
||||
}
|
||||
|
||||
|
||||
ntp_servers_setup_remove() {
|
||||
if [ ! -e $NTP_DHCP_CONF ]; then
|
||||
return
|
||||
fi
|
||||
rm -f $NTP_DHCP_CONF
|
||||
ntp_server_restart
|
||||
}
|
||||
|
||||
|
||||
ntp_servers_setup_add() {
|
||||
if [ -e $NTP_DHCP_CONF ] && [ "$new_ntp_servers" = "$old_ntp_servers" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -z "$new_ntp_servers" ]; then
|
||||
ntp_servers_setup_remove
|
||||
return
|
||||
fi
|
||||
|
||||
tmp=$(mktemp "$NTP_DHCP_CONF.XXXXXX") || return
|
||||
chmod --reference=$NTP_CONF $tmp
|
||||
chown --reference=$NTP_CONF $tmp
|
||||
|
||||
(
|
||||
echo "# This file was copied from $NTP_CONF with the server options changed"
|
||||
echo "# to reflect the information sent by the DHCP server. Any changes made"
|
||||
echo "# here will be lost at the next DHCP event. Edit $NTP_CONF instead."
|
||||
echo
|
||||
echo "# NTP server entries received from DHCP server"
|
||||
for server in $new_ntp_servers; do
|
||||
echo "server $server iburst"
|
||||
done
|
||||
echo
|
||||
sed -r -e '/^ *(server|peer).*$/d' $NTP_CONF
|
||||
) >>$tmp
|
||||
|
||||
mv $tmp $NTP_DHCP_CONF
|
||||
|
||||
ntp_server_restart
|
||||
}
|
||||
|
||||
|
||||
ntp_servers_setup() {
|
||||
case $reason in
|
||||
BOUND|RENEW|REBIND|REBOOT)
|
||||
ntp_servers_setup_add
|
||||
;;
|
||||
EXPIRE|FAIL|RELEASE|STOP)
|
||||
ntp_servers_setup_remove
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
ntp_servers_setup
|
78
etc_org/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
Normal file
78
etc_org/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
Normal file
@ -0,0 +1,78 @@
|
||||
# set classless routes based on the format specified in RFC3442
|
||||
# e.g.:
|
||||
# new_rfc3442_classless_static_routes='24 192 168 10 192 168 1 1 8 10 10 17 66 41'
|
||||
# specifies the routes:
|
||||
# 192.168.10.0/24 via 192.168.1.1
|
||||
# 10.0.0.0/8 via 10.10.17.66.41
|
||||
|
||||
RUN="yes"
|
||||
|
||||
|
||||
if [ "$RUN" = "yes" ]; then
|
||||
if [ -n "$new_rfc3442_classless_static_routes" ]; then
|
||||
if [ "$reason" = "BOUND" ] || [ "$reason" = "REBOOT" ]; then
|
||||
|
||||
set -- $new_rfc3442_classless_static_routes
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
net_length=$1
|
||||
via_arg=''
|
||||
|
||||
case $net_length in
|
||||
32|31|30|29|28|27|26|25)
|
||||
if [ $# -lt 9 ]; then
|
||||
return 1
|
||||
fi
|
||||
net_address="${2}.${3}.${4}.${5}"
|
||||
gateway="${6}.${7}.${8}.${9}"
|
||||
shift 9
|
||||
;;
|
||||
24|23|22|21|20|19|18|17)
|
||||
if [ $# -lt 8 ]; then
|
||||
return 1
|
||||
fi
|
||||
net_address="${2}.${3}.${4}.0"
|
||||
gateway="${5}.${6}.${7}.${8}"
|
||||
shift 8
|
||||
;;
|
||||
16|15|14|13|12|11|10|9)
|
||||
if [ $# -lt 7 ]; then
|
||||
return 1
|
||||
fi
|
||||
net_address="${2}.${3}.0.0"
|
||||
gateway="${4}.${5}.${6}.${7}"
|
||||
shift 7
|
||||
;;
|
||||
8|7|6|5|4|3|2|1)
|
||||
if [ $# -lt 6 ]; then
|
||||
return 1
|
||||
fi
|
||||
net_address="${2}.0.0.0"
|
||||
gateway="${3}.${4}.${5}.${6}"
|
||||
shift 6
|
||||
;;
|
||||
0) # default route
|
||||
if [ $# -lt 5 ]; then
|
||||
return 1
|
||||
fi
|
||||
net_address="0.0.0.0"
|
||||
gateway="${2}.${3}.${4}.${5}"
|
||||
shift 5
|
||||
;;
|
||||
*) # error
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# take care of link-local routes
|
||||
if [ "${gateway}" != '0.0.0.0' ]; then
|
||||
via_arg="via ${gateway}"
|
||||
fi
|
||||
|
||||
# set route (ip detects host routes automatically)
|
||||
ip -4 route add "${net_address}/${net_length}" \
|
||||
${via_arg} dev "${interface}" >/dev/null 2>&1
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi
|
42
etc_org/dhcp/dhclient-exit-hooks.d/timesyncd
Normal file
42
etc_org/dhcp/dhclient-exit-hooks.d/timesyncd
Normal file
@ -0,0 +1,42 @@
|
||||
TIMESYNCD_CONF=/run/systemd/timesyncd.conf.d/01-dhclient.conf
|
||||
|
||||
timesyncd_servers_setup_remove() {
|
||||
if [ -e $TIMESYNCD_CONF ]; then
|
||||
rm -f $TIMESYNCD_CONF
|
||||
systemctl try-restart systemd-timesyncd.service || true
|
||||
fi
|
||||
}
|
||||
|
||||
timesyncd_servers_setup_add() {
|
||||
if [ ! -d /run/systemd/system ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -e $TIMESYNCD_CONF ] && [ "$new_ntp_servers" = "$old_ntp_servers" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -z "$new_ntp_servers" ]; then
|
||||
timesyncd_servers_setup_remove
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p $(dirname $TIMESYNCD_CONF)
|
||||
cat <<EOF > ${TIMESYNCD_CONF}.new
|
||||
# NTP server entries received from DHCP server
|
||||
[Time]
|
||||
NTP=$new_ntp_servers
|
||||
EOF
|
||||
mv ${TIMESYNCD_CONF}.new ${TIMESYNCD_CONF}
|
||||
systemctl try-restart systemd-timesyncd.service || true
|
||||
}
|
||||
|
||||
|
||||
case $reason in
|
||||
BOUND|RENEW|REBIND|REBOOT)
|
||||
timesyncd_servers_setup_add
|
||||
;;
|
||||
EXPIRE|FAIL|RELEASE|STOP)
|
||||
timesyncd_servers_setup_remove
|
||||
;;
|
||||
esac
|
31
etc_org/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd
Executable file
31
etc_org/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This file is part of avahi.
|
||||
#
|
||||
# avahi is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# avahi is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with avahi; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
# USA.
|
||||
|
||||
case "$reason" in
|
||||
MEDIUM|ARPCHECK|ARPSEND|NBI)
|
||||
;;
|
||||
|
||||
PREINIT|BOUND|RENEW|REBIND|REBOOT|STOP|RELEASE)
|
||||
# Stopping avahi-autoipd is left for the enter hook
|
||||
;;
|
||||
|
||||
EXPIRE|FAIL|TIMEOUT)
|
||||
/usr/sbin/avahi-autoipd -wD $interface 2> /dev/null
|
||||
;;
|
||||
esac
|
54
etc_org/dhcp/dhclient.conf
Normal file
54
etc_org/dhcp/dhclient.conf
Normal file
@ -0,0 +1,54 @@
|
||||
# Configuration file for /sbin/dhclient.
|
||||
#
|
||||
# This is a sample configuration file for dhclient. See dhclient.conf's
|
||||
# man page for more information about the syntax of this file
|
||||
# and a more comprehensive list of the parameters understood by
|
||||
# dhclient.
|
||||
#
|
||||
# Normally, if the DHCP server provides reasonable information and does
|
||||
# not leave anything out (like the domain name, for example), then
|
||||
# few changes must be made to this file, if any.
|
||||
#
|
||||
|
||||
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
|
||||
|
||||
send host-name = gethostname();
|
||||
request subnet-mask, broadcast-address, time-offset, routers,
|
||||
domain-name, domain-name-servers, domain-search, host-name,
|
||||
dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
|
||||
netbios-name-servers, netbios-scope, interface-mtu,
|
||||
rfc3442-classless-static-routes, ntp-servers;
|
||||
|
||||
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
|
||||
#send dhcp-lease-time 3600;
|
||||
#supersede domain-name "fugue.com home.vix.com";
|
||||
#prepend domain-name-servers 127.0.0.1;
|
||||
#require subnet-mask, domain-name-servers;
|
||||
timeout 300;
|
||||
#retry 60;
|
||||
#reboot 10;
|
||||
#select-timeout 5;
|
||||
#initial-interval 2;
|
||||
#script "/sbin/dhclient-script";
|
||||
#media "-link0 -link1 -link2", "link0 link1";
|
||||
#reject 192.33.137.209;
|
||||
|
||||
#alias {
|
||||
# interface "eth0";
|
||||
# fixed-address 192.5.5.213;
|
||||
# option subnet-mask 255.255.255.255;
|
||||
#}
|
||||
|
||||
#lease {
|
||||
# interface "eth0";
|
||||
# fixed-address 192.33.137.200;
|
||||
# medium "link0 link1";
|
||||
# option host-name "andare.swiftmedia.com";
|
||||
# option subnet-mask 255.255.255.0;
|
||||
# option broadcast-address 192.33.137.255;
|
||||
# option routers 192.33.137.250;
|
||||
# option domain-name-servers 127.0.0.1;
|
||||
# renew 2 2000/1/12 00:00:01;
|
||||
# rebind 2 2000/1/12 00:00:01;
|
||||
# expire 2 2000/1/12 00:00:01;
|
||||
#}
|
Reference in New Issue
Block a user