DHCP-Abschnitt eingefügt
This commit is contained in:
parent
d1d5cfe315
commit
0b99d005ef
155
aufgabe3.2/30-hostname
Normal file
155
aufgabe3.2/30-hostname
Normal file
@ -0,0 +1,155 @@
|
||||
# Set the hostname from DHCP data if required
|
||||
|
||||
# A hostname can either be a short hostname or a FQDN.
|
||||
# hostname_fqdn=true
|
||||
hostname_fqdn=false
|
||||
# hostname_fqdn=server
|
||||
|
||||
# A value of server means just what the server says, don't manipulate it.
|
||||
# This could lead to an inconsistent hostname on a DHCPv4 and DHCPv6 network
|
||||
# where the DHCPv4 hostname is short and the DHCPv6 has an FQDN.
|
||||
# DHCPv6 has no hostname option.
|
||||
# RFC4702 section 3.1 says FQDN should be prefered over hostname.
|
||||
#
|
||||
# As such, the default is hostname_fqdn=true so that a consistent hostname
|
||||
# is always assigned.
|
||||
: ${hostname_fqdn:=true}
|
||||
|
||||
# Some systems don't have hostname(1)
|
||||
_hostname()
|
||||
{
|
||||
local name=
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
if type hostname >/dev/null 2>&1; then
|
||||
hostname
|
||||
elif [ -r /proc/sys/kernel/hostname ]; then
|
||||
read name </proc/sys/kernel/hostname && echo "$name"
|
||||
elif sysctl kern.hostname >/dev/null 2>&1; then
|
||||
sysctl -n kern.hostname
|
||||
elif sysctl kernel.hostname >/dev/null 2>&1; then
|
||||
sysctl -n kernel.hostname
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Always prefer hostname(1) if we have it
|
||||
if type hostname >/dev/null 2>&1; then
|
||||
#hostname "$1"
|
||||
hostnamectl set-hostname "$1"
|
||||
elif [ -w /proc/sys/kernel/hostname ]; then
|
||||
echo "$1" >/proc/sys/kernel/hostname
|
||||
elif sysctl kern.hostname >/dev/null 2>&1; then
|
||||
sysctl -w "kern.hostname=$1"
|
||||
elif sysctl kernel.hostname >/dev/null 2>&1; then
|
||||
sysctl -w "kernel.hostname=$1"
|
||||
else
|
||||
# We know this will fail, but it will now fail
|
||||
# with an error to stdout
|
||||
hostname "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
need_hostname()
|
||||
{
|
||||
local hostname hfqdn=false hshort=false
|
||||
|
||||
case "$force_hostname" in
|
||||
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;;
|
||||
esac
|
||||
|
||||
hostname="$(_hostname)"
|
||||
case "$hostname" in
|
||||
""|"(none)"|localhost|localhost.localdomain) return 0;;
|
||||
esac
|
||||
|
||||
case "$hostname_fqdn" in
|
||||
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
|
||||
[Ss][Ee][Rr][Vv][Ee][Rr]) ;;
|
||||
*) hshort=true;;
|
||||
esac
|
||||
|
||||
if [ -n "$old_fqdn" ]; then
|
||||
if ${hfqdn} || ! ${hsort}; then
|
||||
[ "$hostname" = "$old_fqdn" ]
|
||||
else
|
||||
[ "$hostname" = "${old_fqdn%%.*}" ]
|
||||
fi
|
||||
elif [ -n "$old_host_name" ]; then
|
||||
if ${hfqdn}; then
|
||||
if [ -n "$old_domain_name" -a \
|
||||
"$old_host_name" = "${old_host_name#*.}" ]
|
||||
then
|
||||
[ "$hostname" = \
|
||||
"$old_host_name.$old_domain_name" ]
|
||||
else
|
||||
[ "$hostname" = "$old_host_name" ]
|
||||
fi
|
||||
elif ${hshort}; then
|
||||
[ "$hostname" = "${old_host_name%%.*}" ]
|
||||
else
|
||||
[ "$hostname" = "$old_host_name" ]
|
||||
fi
|
||||
else
|
||||
# No old hostname
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
try_hostname()
|
||||
{
|
||||
|
||||
if valid_domainname "$1"; then
|
||||
_hostname "$1"
|
||||
else
|
||||
syslog err "Invalid hostname: $1"
|
||||
fi
|
||||
}
|
||||
|
||||
set_hostname()
|
||||
{
|
||||
local hfqdn=false hshort=false
|
||||
|
||||
need_hostname || return
|
||||
|
||||
case "$hostname_fqdn" in
|
||||
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
|
||||
"") ;;
|
||||
*) hshort=true;;
|
||||
esac
|
||||
|
||||
if [ -n "$new_fqdn" ]; then
|
||||
if ${hfqdn} || ! ${hshort}; then
|
||||
try_hostname "$new_fqdn"
|
||||
else
|
||||
try_hostname "${new_fqdn%%.*}"
|
||||
fi
|
||||
elif [ -n "$new_host_name" ]; then
|
||||
if ${hfqdn}; then
|
||||
if [ -n "$new_domain_name" -a \
|
||||
"$new_host_name" = "${new_host_name#*.}" ]
|
||||
then
|
||||
try_hostname "$new_host_name.$new_domain_name"
|
||||
else
|
||||
try_hostname "$new_host_name"
|
||||
fi
|
||||
elif ${hshort}; then
|
||||
try_hostname "${new_host_name%%.*}"
|
||||
else
|
||||
try_hostname "$new_host_name"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# For ease of use, map DHCP6 names onto our DHCP4 names
|
||||
case "$reason" in
|
||||
BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
|
||||
new_fqdn="$new_dhcp6_fqdn"
|
||||
;;
|
||||
esac
|
||||
|
||||
if $if_up; then
|
||||
set_hostname
|
||||
fi
|
112
aufgabe3.2/dhcpd.conf
Normal file
112
aufgabe3.2/dhcpd.conf
Normal file
@ -0,0 +1,112 @@
|
||||
# dhcpd.conf
|
||||
#
|
||||
# Sample configuration file for ISC dhcpd
|
||||
#
|
||||
|
||||
# option definitions common to all supported networks...
|
||||
option domain-name "zotac";
|
||||
option domain-name-servers zotac0.zotac;
|
||||
|
||||
default-lease-time 600;
|
||||
max-lease-time 7200;
|
||||
|
||||
# Use this to enble / disable dynamic dns updates globally.
|
||||
#ddns-update-style none;
|
||||
|
||||
# If this DHCP server is the official DHCP server for the local
|
||||
# network, the authoritative directive should be uncommented.
|
||||
#authoritative;
|
||||
|
||||
# Use this to send dhcp log messages to a different log file (you also
|
||||
# have to hack syslog.conf to complete the redirection).
|
||||
log-facility local7;
|
||||
|
||||
# No service will be given on this subnet, but declaring it helps the
|
||||
# DHCP server to understand the network topology.
|
||||
|
||||
subnet 10.20.0.0 netmask 255.255.255.0 {
|
||||
# range 10.20.0.100 10.20.0.200;
|
||||
option routers zotac0.zotac;
|
||||
}
|
||||
|
||||
# This is a very basic subnet declaration.
|
||||
|
||||
#subnet 10.254.239.0 netmask 255.255.255.224 {
|
||||
# range 10.254.239.10 10.254.239.20;
|
||||
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
|
||||
#}
|
||||
|
||||
# This declaration allows BOOTP clients to get dynamic addresses,
|
||||
# which we don't really recommend.
|
||||
|
||||
#subnet 10.254.239.32 netmask 255.255.255.224 {
|
||||
# range dynamic-bootp 10.254.239.40 10.254.239.60;
|
||||
# option broadcast-address 10.254.239.31;
|
||||
# option routers rtr-239-32-1.example.org;
|
||||
#}
|
||||
|
||||
# A slightly different configuration for an internal subnet.
|
||||
#subnet 10.5.5.0 netmask 255.255.255.224 {
|
||||
# range 10.5.5.26 10.5.5.30;
|
||||
# option domain-name-servers ns1.internal.example.org;
|
||||
# option domain-name "internal.example.org";
|
||||
# option routers 10.5.5.1;
|
||||
# option broadcast-address 10.5.5.31;
|
||||
# default-lease-time 600;
|
||||
# max-lease-time 7200;
|
||||
#}
|
||||
|
||||
# Hosts which require special configuration options can be listed in
|
||||
# host statements. If no address is specified, the address will be
|
||||
# allocated dynamically (if possible), but the host-specific information
|
||||
# will still come from the host declaration.
|
||||
|
||||
host zotac1 {
|
||||
hardware ethernet 00:1c:c0:d5:a9:ee;
|
||||
fixed-address zotac1.zotac;
|
||||
use-host-decl-names true;
|
||||
}
|
||||
|
||||
#host passacaglia {
|
||||
# hardware ethernet 0:0:c0:5d:bd:95;
|
||||
# filename "vmunix.passacaglia";
|
||||
# server-name "toccata.fugue.com";
|
||||
#}
|
||||
|
||||
# Fixed IP addresses can also be specified for hosts. These addresses
|
||||
# should not also be listed as being available for dynamic assignment.
|
||||
# Hosts for which fixed IP addresses have been specified can boot using
|
||||
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
|
||||
# be booted with DHCP, unless there is an address range on the subnet
|
||||
# to which a BOOTP client is connected which has the dynamic-bootp flag
|
||||
# set.
|
||||
#host fantasia {
|
||||
# hardware ethernet 08:00:07:26:c0:a5;
|
||||
# fixed-address fantasia.fugue.com;
|
||||
#}
|
||||
|
||||
# You can declare a class of clients and then do address allocation
|
||||
# based on that. The example below shows a case where all clients
|
||||
# in a certain class get addresses on the 10.17.224/24 subnet, and all
|
||||
# other clients get addresses on the 10.0.29/24 subnet.
|
||||
|
||||
#class "foo" {
|
||||
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
|
||||
#}
|
||||
#
|
||||
#shared-network 224-29 {
|
||||
# subnet 10.17.224.0 netmask 255.255.255.0 {
|
||||
# option routers rtr-224.example.org;
|
||||
# }
|
||||
# subnet 10.0.29.0 netmask 255.255.255.0 {
|
||||
# option routers rtr-29.example.org;
|
||||
# }
|
||||
# pool {
|
||||
# allow members of "foo";
|
||||
# range 10.17.224.10 10.17.224.250;
|
||||
# }
|
||||
# pool {
|
||||
# deny members of "foo";
|
||||
# range 10.0.29.10 10.0.29.230;
|
||||
# }
|
||||
#}
|
12
aufgabe3.2/dhcpd4@.service
Normal file
12
aufgabe3.2/dhcpd4@.service
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=IPv4 DHCP server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile=/run/dhcpd4.pid
|
||||
ExecStart=/usr/sbin/dhcpd -4 -q -pf /run/dhcpd4.pid %I
|
||||
KillSignal=SIGINT
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -94,3 +94,4 @@ Nach dem Burnin sollte der Compute-Node automatisch heruntergefahren werden. Daz
|
||||
|
||||
\shellcmd{shutdown -P 2880}
|
||||
|
||||
\pagebreak
|
@ -1,4 +1,54 @@
|
||||
\subsubsection{DNS}
|
||||
\subsection{DHCP}
|
||||
|
||||
\subsubsection{Server}
|
||||
|
||||
\begin{sloppypar}
|
||||
Wir haben uns für {\tt dhcpd} als DHCP-Server entschieden. Zur Konfiguration haben wir in {\tt /etc/dhcpd.conf} (siehe {\tt aufgabe3.2}) den Domain-Namen {\tt zotac} eintragen und den Headnode als DNS-Server eingestellt.
|
||||
\end{sloppypar}
|
||||
|
||||
Des Weiteren haben wir das Subnet {\tt 10.20.0.0/24} deklariert und wiederum den Headnode als verantwortlichen Router eingetragen.
|
||||
|
||||
Die Pro-Host-Konfiguration sieht bei uns wie folgt aus:
|
||||
|
||||
\begin{lstlisting}
|
||||
host zotac<X> {
|
||||
hardware ethernet <MAC-Adresse>;
|
||||
fixed-address zotac<X>.zotac;
|
||||
use-host-decl-names true;
|
||||
}
|
||||
\end{lstlisting}
|
||||
|
||||
Damit ist sichergestellt, dass die Hosts die im Cluster-Layout spezifizierte IP-Adresse entsprechend ihrer MAC-Adresse zugewiesen bekommen und gleichzeitig ihren Hostnamen gesagt bekommen. (Die IP-Adresse holt sich der DHCP-Server vom lokalen DNS-Server.)
|
||||
|
||||
Zusätzlich haben wir das bereits in der Installation enthaltene {\tt systemd}-Service-File entsprechend so angepasst, dass man beim Starten und Aktivieren des Dienstes spezifizieren kann, auf welchem Netzwerk-Interface der Dienst hören soll. (siehe {\tt aufgabe3.2/dhcpd4@.service})
|
||||
|
||||
Starten kann man den Dienst nun mit:
|
||||
|
||||
\shellcmd{systemctl start dhcpd4@eth1}
|
||||
|
||||
wobei {\tt eth1} das Interface ist, das am internen LAN angeschlossen ist.
|
||||
|
||||
\subsubsection{Client}
|
||||
|
||||
\begin{sloppypar}
|
||||
|
||||
Als Client verwenden wir {\tt dhcpcd}. \\
|
||||
|
||||
Um den Hostnamen richtig vom DHCP-Server abholen zu können, mussten wir in {\tt /usr/lib/dhcpcd/dhcpcd-hooks/30-hostname} (siehe {\tt aufgabe3.2/30-hostname}) noch die Option {\tt hostname\_fqdn=false} setzen, damit der kurze Hostname ({\tt zotac<X>} statt {\tt zotac<X>.zotac}) verwendet wird. \\
|
||||
|
||||
Außerdem haben wir noch die Zeile:
|
||||
\begin{center}
|
||||
{\tt hostname \grqq{\$}1\grqq}
|
||||
\end{center}
|
||||
durch:
|
||||
\begin{center}
|
||||
{\tt hostnamectl set-hostname \grqq{\$}1\grqq}
|
||||
\end{center}
|
||||
ersetzt, damit der bezogene Hostname automatisch persistent ({\tt /etc/hostname}) gesetzt wird.
|
||||
|
||||
\end{sloppypar}
|
||||
|
||||
\subsection{DNS}
|
||||
\label{ssub:dns}
|
||||
|
||||
Als DNS-Server haben wir {\tt Bind} installiert und eingerichtet.
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7abd329ac66148a9b6adcf5c022e84893b72a36b
|
||||
Subproject commit b63daf5cbc2272cd20277a157bf025c695a5bb45
|
2
logs
2
logs
@ -1 +1 @@
|
||||
Subproject commit e67584ad2c8222932e65a5d340e3469780acc3b4
|
||||
Subproject commit 4577c74a7b11d23834a2fd53d0f0646e0d6d0622
|
@ -113,7 +113,7 @@ pre {
|
||||
<section id="bericht">
|
||||
<h2>Bericht</h2>
|
||||
<a href="uploads/bericht.pdf" class="pure-button
|
||||
pure-button-primary">Download</a> <p>Stand: 13:38:39 07.11.2013</p>
|
||||
pure-button-primary">Download</a> <p>Stand: 10:38:02 21.11.2013</p>
|
||||
</section>
|
||||
<section id="git">
|
||||
<h2>Git-Zugriff</h2>
|
||||
|
Loading…
Reference in New Issue
Block a user