pulling loopback IP from DNS instead of relaying on dhcp and configfile, moving net-interfaces to each own files in interfaces.d, cleaning up the postinst scritp a bit for easier read
This commit is contained in:
parent
2f1a2d497a
commit
37125104c3
|
@ -9,7 +9,7 @@ Vcs-Git: https://git.wit.com/netops/wit-network-config
|
||||||
|
|
||||||
Package: wit-network-config
|
Package: wit-network-config
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: systemd, sed, tcpdump, mtr-tiny, iproute2, ifupdown, ipmitool, iptables, lldpd, strongswan, telnet, netcat, fping, curl, wget, ifstat, rsyslog, ncurses-term, net-tools, bridge-utils, vlan, gnupg, sudo, isc-dhcp-client, frr (>= 5.0.1-wit), frr (<< 5.0.2-wit)
|
Depends: systemd, sed, tcpdump, mtr-tiny, iproute2, ifupdown, ipmitool, iptables, lldpd, strongswan, telnet, netcat, fping, curl, wget, ifstat, rsyslog, ncurses-term, net-tools, bridge-utils, vlan, gnupg, sudo, isc-dhcp-client, bind9-host, dnsutils, frr (>= 5.0.1-wit), frr (<< 5.0.2-wit)
|
||||||
Provides: ${diverted-files}
|
Provides: ${diverted-files}
|
||||||
Conflicts: ${diverted-files}, dhcpcd5
|
Conflicts: ${diverted-files}, dhcpcd5
|
||||||
Description: configure network for a standard wit compute and/or data node
|
Description: configure network for a standard wit compute and/or data node
|
||||||
|
|
|
@ -24,17 +24,16 @@ case "$1" in
|
||||||
|
|
||||||
### START gather all the info from the box and generate the variabels
|
### START gather all the info from the box and generate the variabels
|
||||||
|
|
||||||
source /etc/wit-net.conf
|
#source /etc/wit-net.conf
|
||||||
if [ -z $LOOPBACKv4 ]; then
|
export DOMAINNAME=${HOSTNAME#*.}
|
||||||
echo "LOOPBACK not provided by DHCP"
|
export LOOPBACKv4=$(dig +short ${HOSTNAME%%.*}.loopback.${HOSTNAME#*.})
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
export TIER_ID=$(echo $LOOPBACKv4 | cut -d . -f 3)
|
export TIER_ID=$(echo $LOOPBACKv4 | cut -d . -f 3)
|
||||||
export NODE_ID=$(echo $LOOPBACKv4 | cut -d . -f 4)
|
export NODE_ID=$(echo $LOOPBACKv4 | cut -d . -f 4)
|
||||||
export DOMAINNAME=${HOSTNAME#*.}
|
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z $LOOPBACKv4 ]; then
|
||||||
|
echo "unable to find my LOOPBACK IP"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
if [ -z "$TIER_ID" ]; then
|
if [ -z "$TIER_ID" ]; then
|
||||||
echo "Unable to autodetect TIER_ID, looks like we deal with a special node, please set in environment"
|
echo "Unable to autodetect TIER_ID, looks like we deal with a special node, please set in environment"
|
||||||
exit 2
|
exit 2
|
||||||
|
@ -55,29 +54,67 @@ case "$1" in
|
||||||
|
|
||||||
## START writing config files
|
## START writing config files
|
||||||
|
|
||||||
|
# write hosts file
|
||||||
|
sed -i -e "/debcore1/d" -e "/${HOSTNAME%%.*}/d" -e "/${LOOPBACKv4}/d" /etc/hosts
|
||||||
|
echo -e "${LOOPBACKv4}\t${HOSTNAME}\t${HOSTNAME%%.*}" >>/etc/hosts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# disable password logins on ssh
|
||||||
sed -i -e '/#*\s*PasswordAuthentication /d' /etc/ssh/sshd_config
|
sed -i -e '/#*\s*PasswordAuthentication /d' /etc/ssh/sshd_config
|
||||||
echo "PasswordAuthentication no" >>/etc/ssh/sshd_config
|
echo "PasswordAuthentication no" >>/etc/ssh/sshd_config
|
||||||
|
|
||||||
|
|
||||||
echo "iface lo inet static" > /etc/network/interfaces.d/lo
|
|
||||||
echo " address ${LOOPBACKv4}/32" >> /etc/network/interfaces.d/lo
|
# set network interface configurations
|
||||||
echo "" >> /etc/network/interfaces.d/lo
|
cat <<-EOF >/etc/network/interfaces.d/lo
|
||||||
echo "iface lo inet6 static" >> /etc/network/interfaces.d/lo
|
auto lo
|
||||||
echo " address ${LOOPBACKv6}/128" >> /etc/network/interfaces.d/lo
|
iface lo inet loopback
|
||||||
|
|
||||||
|
iface lo inet static
|
||||||
|
address ${LOOPBACKv4}/32
|
||||||
|
iface lo inet6 static
|
||||||
|
address ${LOOPBACKv6}/128
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<-"EOF" >/etc/network/interfaces.d/mgmt1
|
||||||
|
auto mgmt1
|
||||||
|
iface mgmt1 inet6 auto
|
||||||
|
iface mgmt1 inet dhcp
|
||||||
|
pre-up /bin/ip link add mgmt type vrf table mgmt
|
||||||
|
pre-up /bin/ip link set up dev mgmt
|
||||||
|
pre-up /bin/ip link set master mgmt dev mgmt1
|
||||||
|
post-down /bin/ip link del dev mgmt
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<-"EOF" >/etc/network/interfaces.d/feth
|
||||||
|
auto feth1
|
||||||
|
iface feth1 inet manual
|
||||||
|
mtu 9000
|
||||||
|
|
||||||
|
auto feth2
|
||||||
|
iface feth2 inet manual
|
||||||
|
mtu 9000
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# set frr config
|
||||||
sed -i -e "s/FRRROUTERID/${LOOPBACKv4}/" -e "s/NODEASN/${NODE_ASN}/" /etc/frr/frr.conf.wit
|
sed -i -e "s/FRRROUTERID/${LOOPBACKv4}/" -e "s/NODEASN/${NODE_ASN}/" /etc/frr/frr.conf.wit
|
||||||
chown frr.frr /etc/frr/frr.conf.wit /etc/frr/daemons.wit
|
chown frr.frr /etc/frr/frr.conf.wit /etc/frr/daemons.wit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# set ipsec config
|
||||||
sed -i -e "s/HOSTNAME\.DOMAINNAME/${HOSTNAME}/" /etc/ipsec.conf.wit
|
sed -i -e "s/HOSTNAME\.DOMAINNAME/${HOSTNAME}/" /etc/ipsec.conf.wit
|
||||||
echo ": RSA ${HOSTNAME}.key" >/etc/ipsec.secrets
|
echo ": RSA ${HOSTNAME}.key" >/etc/ipsec.secrets
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# write udev rules for device names
|
||||||
echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$MGMT_MAC'", ATTR{type}=="1", NAME="mgmt1"' >/etc/udev/rules.d/70-persistent-net.rules
|
echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$MGMT_MAC'", ATTR{type}=="1", NAME="mgmt1"' >/etc/udev/rules.d/70-persistent-net.rules
|
||||||
i=0
|
i=0
|
||||||
for nic in $(ip -br link | awk '{ print $1 }'); do
|
for nic in $(ip -br link | awk '{ print $1 }'); do
|
||||||
|
@ -89,12 +126,16 @@ case "$1" in
|
||||||
sed -i "/$MGMT_MAC.*feth./d" /etc/udev/rules.d/70-persistent-net.rules
|
sed -i "/$MGMT_MAC.*feth./d" /etc/udev/rules.d/70-persistent-net.rules
|
||||||
|
|
||||||
|
|
||||||
sed -i -e "/debcore1/d" -e "/${HOSTNAME%%.*}/d" -e "/${LOOPBACKv4}/d" /etc/hosts
|
|
||||||
echo -e "${LOOPBACKv4}\t${HOSTNAME}\t${HOSTNAME%%.*}" >>/etc/hosts
|
|
||||||
|
|
||||||
|
|
||||||
|
# wite grub rules for serial terminal
|
||||||
sed -i -e '/GRUB_CMDLINE_LINUX_DEFAULT=/d' -e '/GRUB_CMDLINE_LINUX=/d' -e '/GRUB_SERIAL_COMMAND=/d' -e '/GRUB_TERMINAL=/d' /etc/default/grub
|
sed -i -e '/GRUB_CMDLINE_LINUX_DEFAULT=/d' -e '/GRUB_CMDLINE_LINUX=/d' -e '/GRUB_SERIAL_COMMAND=/d' -e '/GRUB_TERMINAL=/d' /etc/default/grub
|
||||||
echo -e 'GRUB_CMDLINE_LINUX_DEFAULT=""\nGRUB_CMDLINE_LINUX="console=tty0 console=ttyS1,115200n8"\nGRUB_TERMINAL=serial\nGRUB_SERIAL_COMMAND="serial --speed=115200 --unit=1 --word=8 --parity=no --stop=1"' >>/etc/default/grub
|
cat <<-EOF >>/etc/default/grub
|
||||||
|
GRUB_CMDLINE_LINUX_DEFAULT=""
|
||||||
|
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS1,115200n8"
|
||||||
|
GRUB_TERMINAL=serial
|
||||||
|
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=1 --word=8 --parity=no --stop=1"'
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
## END config file section
|
## END config file section
|
||||||
|
|
|
@ -1,22 +1 @@
|
||||||
auto lo
|
|
||||||
iface lo inet loopback
|
|
||||||
|
|
||||||
auto mgmt1
|
|
||||||
iface mgmt1 inet6 auto
|
|
||||||
iface mgmt1 inet dhcp
|
|
||||||
pre-up /bin/ip link add mgmt type vrf table mgmt
|
|
||||||
pre-up /bin/ip link set up dev mgmt
|
|
||||||
pre-up /bin/ip link set master mgmt dev mgmt1
|
|
||||||
post-down /bin/ip link del dev mgmt
|
|
||||||
|
|
||||||
|
|
||||||
auto feth1
|
|
||||||
iface feth1 inet manual
|
|
||||||
mtu 9000
|
|
||||||
|
|
||||||
auto feth2
|
|
||||||
iface feth2 inet manual
|
|
||||||
mtu 9000
|
|
||||||
|
|
||||||
|
|
||||||
source-directory /etc/network/interfaces.d
|
source-directory /etc/network/interfaces.d
|
||||||
|
|
Loading…
Reference in New Issue