You've already forked debian-unattended
fixed dns
This commit is contained in:
@@ -3,12 +3,13 @@
|
||||
# Sometimes the network is slow, wait a bit
|
||||
sleep 10
|
||||
|
||||
# Get the current DHCP network address (and gateway)
|
||||
# Get the current DHCP network address, gateway and DNS servers
|
||||
NIC=$(ip link | grep "^2:" | awk '{print $2}' | tr -d ":")
|
||||
IP_ADDRESS=$(ip address show ${NIC} | grep -E "inet " | awk '{print $2}')
|
||||
NETMASK=$(echo ${IP_ADDRESS} | sed 's/.*\///')
|
||||
IP_ADDRESS=$(echo ${IP_ADDRESS} | sed 's/\/.*//')
|
||||
GATEWAY=$(ip route | grep "default" | awk '{print $3}')
|
||||
DNS_SERVERS=$(awk '/^nameserver/ {print $2}' /etc/resolv.conf)
|
||||
|
||||
# Network interfaces (static address)
|
||||
cat << EOF > /etc/network/interfaces
|
||||
@@ -19,10 +20,16 @@ auto ${NIC}
|
||||
iface ${NIC} inet static
|
||||
address ${IP_ADDRESS}/${NETMASK}
|
||||
gateway ${GATEWAY}
|
||||
dns-nameservers ${DNS_SERVERS}
|
||||
EOF
|
||||
|
||||
# Tabs instead of spaces, neat the file
|
||||
sed -i 's/ /\t/gm' /etc/network/interfaces
|
||||
# write a static resolv.conf
|
||||
rm -f /etc/resolv.conf
|
||||
for ns in ${DNS_SERVERS}; do
|
||||
echo "nameserver ${ns}" >> /etc/resolv.conf
|
||||
done
|
||||
|
||||
# Hosts file
|
||||
cat << EOF > /etc/hosts
|
||||
|
||||
Reference in New Issue
Block a user