]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
AWS: Use correct IP address for the internal DNS
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 28 Jun 2018 09:55:24 +0000 (10:55 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 28 Jun 2018 09:56:06 +0000 (10:56 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/helper/aws-setup

index db9e1846e71814ddb4c5a2e3eba1f9bbb621e55e..e6e733fb7da5a28e4dcdc3b64445d3c7b2b945c7 100644 (file)
@@ -86,6 +86,11 @@ import_aws_configuration() {
                local ipv4_address="$(get "network/interfaces/macs/${mac}/local-ipv4s" | head -n1)"
                local ipv4_address_num="$(to_integer "${ipv4_address}")"
 
+               # Get VPC subnet
+               local vpc="$(get "network/interfaces/macs/${mac}/vpc-ipv4-cidr-block")"
+               local vpc_netaddress="${vpc%/*}"
+               local vpc_netaddress_num="$(to_integer "${vpc_netaddress}")"
+
                # Get subnet size
                local subnet="$(get "network/interfaces/macs/${mac}/subnet-ipv4-cidr-block")"
 
@@ -101,8 +106,8 @@ import_aws_configuration() {
                # The gateway is always the first IP address in the subnet
                local gateway="$(to_address $(( netaddress_num + 1 )))"
 
-               # The AWS internal DNS service is available on the fourth IP address of each subnet
-               local dns1="$(to_address $(( netaddress_num + 4 )))"
+               # The AWS internal DNS service is available on the second IP address of the VPC
+               local dns1="$(to_address $(( vpc_netaddress_num + 2 )))"
                local dns2=
 
                case "${device_number}" in