DNS Issues with Cloud formation template 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:
{  &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;
          }
        ]
      }
    ]
  }
}  }}
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)
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)