Initial commit
This commit is contained in:
38
dhcp/debug
Normal file
38
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
|
||||
1
dhcp/dhclient-enter-hooks.d/debug
Symbolic link
1
dhcp/dhclient-enter-hooks.d/debug
Symbolic link
@@ -0,0 +1 @@
|
||||
../debug
|
||||
50
dhcp/dhclient-enter-hooks.d/resolvconf
Normal file
50
dhcp/dhclient-enter-hooks.d/resolvconf
Normal file
@@ -0,0 +1,50 @@
|
||||
# resolvconf support for dhclient3
|
||||
|
||||
NL="
|
||||
"
|
||||
|
||||
if [ -x /sbin/resolvconf ]; then
|
||||
case "$reason" in
|
||||
BOUND|RENEW|REBIND|REBOOT|TIMEOUT)
|
||||
make_resolv_conf() {
|
||||
local nameserver conf=
|
||||
if [ -n "$new_domain_name" ]; then
|
||||
conf="${conf}domain $new_domain_name$NL"
|
||||
fi
|
||||
if [ -n "$new_domain_search" ]; then
|
||||
conf="${conf}search $new_domain_search$NL"
|
||||
fi
|
||||
for nameserver in $new_domain_name_servers; do
|
||||
conf="${conf}nameserver $nameserver$NL"
|
||||
done
|
||||
if [ -n "$conf" -a -n "$interface" ]; then
|
||||
conf="# resolv.conf for $interface$NL$conf"
|
||||
printf %s "$conf" | \
|
||||
/sbin/resolvconf -a "$interface"
|
||||
fi
|
||||
}
|
||||
;;
|
||||
BOUND6|RENEW6|REBIND6)
|
||||
make_resolv_conf() {
|
||||
local nameserver conf=
|
||||
if [ -n "$new_dhcp6_domain_search" ]; then
|
||||
conf="${conf}search $new_dhcp6_domain_search$NL"
|
||||
fi
|
||||
for nameserver in $new_dhcp6_name_servers; do
|
||||
conf="${conf}nameserver $nameserver$NL"
|
||||
done
|
||||
if [ -n "$conf" -a -n "$interface" ]; then
|
||||
conf="# resolv.conf for $interface$NL$conf"
|
||||
printf %s "$conf" | \
|
||||
/sbin/resolvconf -a "$interface.inet6"
|
||||
fi
|
||||
}
|
||||
;;
|
||||
EXPIRE|FAIL|RELEASE|STOP)
|
||||
[ -z "$interface" ] || /sbin/resolvconf -f -d "$interface"
|
||||
;;
|
||||
EXPIRE6|RELEASE6|STOP6)
|
||||
[ -z "$interface" ] || /sbin/resolvconf -f -d "$interface.inet6"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
1
dhcp/dhclient-exit-hooks.d/debug
Symbolic link
1
dhcp/dhclient-exit-hooks.d/debug
Symbolic link
@@ -0,0 +1 @@
|
||||
../debug
|
||||
78
dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
Normal file
78
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
dhcp/dhclient-exit-hooks.d/timesyncd
Normal file
42
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
|
||||
54
dhcp/dhclient.conf
Normal file
54
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 60;
|
||||
#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