]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/initscripts/helper/azure-setup
cloud-init: Disable using ISP nameservers
[people/pmueller/ipfire-2.x.git] / src / initscripts / helper / azure-setup
index 47d1473afca43a5ef37e043f3c687d504178671e..291b8e0a4d9f31853c1fd5906ac400677adee2c9 100644 (file)
@@ -15,7 +15,7 @@ get() {
 format_mac() {
        local mac="${1,,}"
 
-       echo "${mac:0:2}:${mac:2:2}:${mac:4:2}:${mac:6:2}:${mac:8:2}"
+       echo "${mac:0:2}:${mac:2:2}:${mac:4:2}:${mac:6:2}:${mac:8:2}:${mac:10:2}"
 }
 
 to_address() {
@@ -58,6 +58,9 @@ prefix2netmask() {
 
 import_azure_configuration() {
        local instance_id="$(get compute/vmId)"
+       if [ -z "${instance_id}" ]; then
+               return 0
+       fi
 
        boot_mesg "Importing Microsoft Azure configuration for instance ${instance_id}..."
 
@@ -138,9 +141,6 @@ import_azure_configuration() {
                fi
        fi
 
-       # Import any DNS server settings
-       eval $(/usr/local/bin/readhash <(grep -E "^DNS([0-9])=" /var/ipfire/ethernet/settings 2>/dev/null))
-
        # Import network configuration
        # After this, no network connectivity will be available from this script due to the
        # renaming of the network interfaces for which they have to be shut down
@@ -175,11 +175,6 @@ import_azure_configuration() {
                                # The gateway is always the first IP address in the subnet
                                local gateway="$(to_address $(( netaddress_num + 1 )))"
 
-                               # Microsoft uses a special IP address for DNS
-                               # https://blogs.msdn.microsoft.com/mast/2015/05/18/what-is-the-ip-address-168-63-129-16/
-                               local dns1="168.63.129.16"
-                               local dns2=
-
                                (
                                        echo "RED_TYPE=STATIC"
                                        echo "RED_DEV=${interface_name}"
@@ -190,8 +185,6 @@ import_azure_configuration() {
                                        echo "RED_NETADDRESS=${netaddress}"
                                        echo "RED_BROADCAST=${broadcast}"
                                        echo "DEFAULT_GATEWAY=${gateway}"
-                                       echo "DNS1=${DNS1:-${dns1}}"
-                                       echo "DNS2=${DNS2:-${dns2}}"
                                ) >> /var/ipfire/ethernet/settings
 
                                # Import aliases for RED
@@ -247,6 +240,9 @@ import_azure_configuration() {
 
        # Actions performed only on the very first start
        if [ ! -e "/var/ipfire/main/firstsetup_ok" ]; then
+               # Disable using ISP nameservers
+               sed -e "s/^USE_ISP_NAMESERVERS=.*/USE_ISP_NAMESERVERS=off/" -i /var/ipfire/dns/settings
+
                # Enable SSH
                sed -e "s/ENABLE_SSH=.*/ENABLE_SSH=on/g" -i /var/ipfire/remote/settings