<p>The issue was due to the DNS ports not being configured properly. I had to configure port 53 in my security groups to get this to work.</p>

CC BY-SA 4.0
2020-09-18T14:58:52.310Z
2020-09-18T14:58:52.310Z
arunm
<p>Which flavor of Linux are you using? (eg Ubuntu/Debian, RHEL/CentOS etc)
Also which version? (eg Ubuntu started using the &quot;netplan&quot; configuration by default in 20.04)</p>
<p>At first glance, it looks like your DNS nameservers are hosed somehow.</p>
<p>And can you post the results for doing a: <code>netstat -nutpl</code>?</p>
<p>Look at which PID/Program Name is listening on port 53 (systemd-resolve? dnsmasq?) and check its nameserver configuration.</p>
<p>Maybe check here: <code>sudo cat /etc/resolv.conf </code> and make sure the nameserver(s) listed there are what you think you should have them.</p>
<p>or check the DNS-related services are even running with something like:</p>
<p>Ubuntu:  <code>sudo service systemd-resolved status</code> (NOTE BOTH of the 'd' endings)</p>
<p>CentOS/RHEL: <code>sudo service dnsmasq status</code></p>
<p>(or whatever is using port 53, which is the default DNS port on most OSes)</p>

CC BY-SA 4.0
2020-09-11T15:49:12.300Z
2020-09-11T15:49:12.300Z
CoolElectricity
<p>I am trying to automate the creation of an EC2 instance with CloudFormation but am running into issues with DNS.</p>
<p>Once the instance is created it can't seem to resolve any hostnames. I try to ping a hostname, such as google.com, and it can't be resolved. However, it can ping IP addresses.</p>
<p>My template is below and I understand that there are some unused parameters which I intend to use later on:</p>
<pre><code>{  &quot;Description&quot;: &quot;Create an EC2 instance by AWS CloudFormation&quot;,  &quot;Parameters&quot;: {
&quot;KeyName&quot;: {
  &quot;MinLength&quot;: 1,
  &quot;Type&quot;: &quot;AWS::EC2::KeyPair::KeyName&quot;
},
&quot;BaseAmiId&quot;: {
  &quot;Default&quot;: &quot;ami-bd3ba0aa&quot;,
  &quot;Type&quot;: &quot;String&quot;
},
&quot;DomainAdminUser&quot;: {
  &quot;Description&quot;: &quot;User name for the account that will be added as Domain Administrator. This is separate from the default \&quot;Administrator\&quot; account&quot;,
  &quot;Type&quot;: &quot;String&quot;,
  &quot;Default&quot;: &quot;installer&quot;
},
&quot;DomainUserPassword&quot;: {
  &quot;NoEcho&quot;: &quot;true&quot;,
  &quot;Description&quot;: &quot;The Windows administrator account password&quot;,
  &quot;Type&quot;: &quot;String&quot;,
  &quot;MinLength&quot;: &quot;8&quot;,
  &quot;MaxLength&quot;: &quot;41&quot;
},
&quot;DomainDNSName&quot;: {
  &quot;Description&quot;: &quot;Fully qualified domain name (FQDN) of the forest root domain&quot;,
  &quot;Type&quot;: &quot;String&quot;,
  &quot;Default&quot;: &quot;test.com&quot;
},
&quot;DomainNetBiosName&quot;: {
  &quot;Description&quot;: &quot;Netbios name for the domain&quot;,
  &quot;Type&quot;: &quot;String&quot;,
  &quot;Default&quot;: &quot;test&quot;
}  },  &quot;Resources&quot;: {
&quot;SecurityGroupDemoSvrTraffic&quot;: {
  &quot;Type&quot;: &quot;AWS::EC2::SecurityGroup&quot;,
  &quot;Properties&quot;: {
    &quot;GroupName&quot;: &quot;sgDemoSvr&quot;,
    &quot;SecurityGroupIngress&quot;: [
      {
        &quot;IpProtocol&quot;: &quot;tcp&quot;,
        &quot;FromPort&quot;: 3389,
        &quot;ToPort&quot;: 3389,
        &quot;CidrIp&quot;: &quot;0.0.0.0/0&quot;,
        &quot;Description&quot;: &quot;For traffic from Internet&quot;
      }
    ],
    &quot;GroupDescription&quot;: &quot;Security Group for demo server&quot;,
    &quot;VpcId&quot;: &quot;vpc-05eabde4dbadsf09&quot;
  }
},
&quot;EC2Instance&quot;: {
  &quot;Type&quot;: &quot;AWS::EC2::Instance&quot;,
  &quot;Properties&quot;: {
    &quot;AvailabilityZone&quot;: &quot;eu-west-2b&quot;,
    &quot;BlockDeviceMappings&quot;: [
      {
        &quot;DeviceName&quot;: &quot;/dev/sda1&quot;,
        &quot;Ebs&quot;: {
          &quot;DeleteOnTermination&quot;: &quot;true&quot;,
          &quot;VolumeSize&quot;: &quot;32&quot;,
          &quot;VolumeType&quot;: &quot;gp2&quot;
        }
      }
    ],
    &quot;ImageId&quot;: &quot;ami-029c4f36a959979a7&quot;,
    &quot;InstanceType&quot;: &quot;t2.micro&quot;,
    &quot;KeyName&quot;: {
        &quot;Ref&quot;: &quot;KeyName&quot;
    },
    &quot;NetworkInterfaces&quot;: [
      {
        &quot;Description&quot;: &quot;Primary network interface&quot;,
        &quot;DeviceIndex&quot;: &quot;0&quot;,
        &quot;SubnetId&quot;: &quot;subnet-0b3f36d19eb3sdfda&quot;,
        &quot;AssociatePublicIpAddress&quot;: true,
        &quot;GroupSet&quot;: [
          {
            &quot;Ref&quot;: &quot;SecurityGroupDemoSvrTraffic&quot;
          }
        ]
      }
    ]
  }
}  }}
</code></pre>

<amazon-web-services><automation><dns>
DNS Issues with Cloud formation template
arunm
# DNS Issues with Cloud formation template

(Asked by: username_0 on 2020-09-11)

I am trying to automate the creation of an EC2 instance with CloudFormation but am running into issues with DNS.
Once the instance is created it can't seem to resolve any hostnames. I try to ping a hostname, such as google.com, and it can't be resolved. However, it can ping IP addresses.
My template is below and I understand that there are some unused parameters which I intend to use later on:
{  "Description": "Create an EC2 instance by AWS CloudFormation",  "Parameters": {
"KeyName": {
  "MinLength": 1,
  "Type": "AWS::EC2::KeyPair::KeyName"
},
"BaseAmiId": {
  "Default": "ami-bd3ba0aa",
  "Type": "String"
},
"DomainAdminUser": {
  "Description": "User name for the account that will be added as Domain Administrator. This is separate from the default \"Administrator\" account",
  "Type": "String",
  "Default": "installer"
},
"DomainUserPassword": {
  "NoEcho": "true",
  "Description": "The Windows administrator account password",
  "Type": "String",
  "MinLength": "8",
  "MaxLength": "41"
},
"DomainDNSName": {
  "Description": "Fully qualified domain name (FQDN) of the forest root domain",
  "Type": "String",
  "Default": "test.com"
},
"DomainNetBiosName": {
  "Description": "Netbios name for the domain",
  "Type": "String",
  "Default": "test"
}  },  "Resources": {
"SecurityGroupDemoSvrTraffic": {
  "Type": "AWS::EC2::SecurityGroup",
  "Properties": {
    "GroupName": "sgDemoSvr",
    "SecurityGroupIngress": [
      {
        "IpProtocol": "tcp",
        "FromPort": 3389,
        "ToPort": 3389,
        "CidrIp": "0.0.0.0/0",
        "Description": "For traffic from Internet"
      }
    ],
    "GroupDescription": "Security Group for demo server",
    "VpcId": "vpc-05eabde4dbadsf09"
  }
},
"EC2Instance": {
  "Type": "AWS::EC2::Instance",
  "Properties": {
    "AvailabilityZone": "eu-west-2b",
    "BlockDeviceMappings": [
      {
        "DeviceName": "/dev/sda1",
        "Ebs": {
          "DeleteOnTermination": "true",
          "VolumeSize": "32",
          "VolumeType": "gp2"
        }
      }
    ],
    "ImageId": "ami-029c4f36a959979a7",
    "InstanceType": "t2.micro",
    "KeyName": {
        "Ref": "KeyName"
    },
    "NetworkInterfaces": [
      {
        "Description": "Primary network interface",
        "DeviceIndex": "0",
        "SubnetId": "subnet-0b3f36d19eb3sdfda",
        "AssociatePublicIpAddress": true,
        "GroupSet": [
          {
            "Ref": "SecurityGroupDemoSvrTraffic"
          }
        ]
      }
    ]
  }
}  }}

**Tags:** amazon-web-services, automation, dns


---

## 2 answers

### Answer by username_1 on 2020-09-11. Score: 1

Which flavor of Linux are you using? (eg Ubuntu/Debian, RHEL/CentOS etc)
Also which version? (eg Ubuntu started using the "netplan" configuration by default in 20.04)

At first glance, it looks like your DNS nameservers are hosed somehow.

And can you post the results for doing a: `netstat -nutpl`?

Look at which PID/Program Name is listening on port 53 (systemd-resolve? dnsmasq?) and check its nameserver configuration.

Maybe check here: `sudo cat /etc/resolv.conf`  and make sure the nameserver(s) listed there are what you think you should have them.

or check the DNS-related services are even running with something like:

Ubuntu: `sudo service systemd-resolved status` (NOTE BOTH of the 'd' endings)

CentOS/RHEL: `sudo service dnsmasq status`

(or whatever is using port 53, which is the default DNS port on most OSes)


---

### Answer by username_0 on 2020-09-18. Score: 0

The issue was due to the DNS ports not being configured properly. I had to configure port 53 in my security groups to get this to work.


---

