All DNS Fails on a New OpenStack VM but TCP Works — the Security Group With No UDP Egress
A field story about a brand-new cloud VM that could not resolve a single name — the outbound rule almost nobody reads — and the two-query test I now run before I touch resolv.conf.
The VM was new. A fresh instance in a customer’s OpenStack project, built to host their mail platform. A clean install, the control panel script ready to run.
“The server is up? Good. Install the panel and we’ll point the domain at it today.”
Before the install, I ran my usual first checks. Name resolution was one of them.
I tried a plain lookup. Nothing. I tried a different name. Nothing. Every DNS lookup on the box failed.
“Is it the server? Do we need to rebuild it?”
I checked the obvious things. The resolver settings looked normal. The server’s own firewall was nftables, and its ruleset accepted everything. There was no local DNS cache doing anything strange.
Then I asked the same question a different way. I sent the same DNS query over TCP instead of UDP.
It answered.
Same server. Same resolver. Same name. UDP: nothing. TCP: an answer.
That’s the trap. A DNS failure on a new cloud VM does not always live on the VM. It can live one layer out, in the cloud firewall that the operating system cannot see.
What Was Actually Happening — DNS Goes Out Over UDP First
Here’s the part that trips people up.
DNS is not “port 53”. DNS is UDP port 53 first, and TCP port 53 only as a fallback. A normal lookup looks like this:
Application → stub resolver → UDP 53 → recursive resolver → UDP reply
The client only switches to TCP when the UDP reply comes back truncated, or when the client is told to use TCP. If the UDP packet never leaves the VM, the client does not “fall back” to TCP. It simply waits, retries, and times out. To the application it looks like DNS is dead.
In OpenStack, every port on a VM sits behind a security group: a stateful, allow-only firewall that Neutron enforces on the hypervisor, outside the guest. It has two directions:
- Ingress rules decide what may reach the VM.
- Egress rules decide what the VM may send out.
Because it is stateful, a reply to traffic you sent is allowed back in automatically. But the first packet out still needs an egress rule. On this project the security group had no rule that let UDP out. TCP out was allowed. So the TCP query worked, and every normal lookup died at the hypervisor before it reached the network.
Where I see this pattern:
- A security group copied from a “locked-down” template where someone removed the default allow-all egress rules and added back only TCP ports.
- A project where the default group was edited by hand during a hardening exercise and nobody wrote down why.
- A new VM attached to a group built for a different role, such as a web tier that only ever needed outbound HTTPS.
Why the Usual Checks Miss It
Every check you run inside the VM says the VM is fine. That is exactly the problem.
resolv.confis correct.nft list rulesetoriptables -Sshows nothing blocking port 53.ip routeshows a default gateway.pingto the resolver may work, because ICMP egress can be allowed while UDP is not.- A TCP test such as
curlto an IP address works, because TCP egress is open.
The operating system has no view of the security group. Neutron drops the packet on the hypervisor side of the VM’s port. From inside the guest, the packet was sent, and nothing came back. That is all it can tell you.
So people do what feels natural. They swap resolvers. They edit resolv.conf. They disable systemd-resolved. Some rebuild the VM. None of that changes anything, because none of it is where the drop happens.
If the only thing that fails is UDP, look outside the VM.
How to Actually Fix This
Step 1: Prove It With Two Queries (Read-Only)
Ask the same resolver the same question twice: once the normal way, once over TCP.
dig example.com @1.1.1.1
dig +tcp example.com @1.1.1.1
If the first one ends with connection timed out; no servers could be reached and the second one returns an ANSWER SECTION with status: NOERROR, you have your answer. The resolver is reachable. The name exists. Only UDP is being dropped.
If both fail, this is not a UDP problem. Check routing and the floating IP or router first.
Plain takeaway: two queries, one difference, one layer to look at.
Step 2: Find the Security Groups on the VM’s Port (Read-Only)
From a machine with the OpenStack CLI and the project’s credentials:
openstack server show <vm-name> -c security_groups
Then list the egress rules of each group it shows:
openstack security group rule list <group-name> --egress
You are looking for a rule with protocol udp (or any) that covers port 53, to 0.0.0.0/0 or to your resolver’s address. In this case there was none. There were egress rules, but not one of them carried UDP.
In Horizon the same view is Project › Network › Security Groups › Manage Rules, filtered by the Egress direction.
Remember: a VM can have more than one group. Rules from all groups are added together. If no group allows UDP out, UDP does not go out.
Step 3: Add the Egress Rule (Changes State)
This step changes the firewall. It is the fix.
openstack security group rule create --egress --protocol udp --dst-port 53 --remote-ip 0.0.0.0/0 <group-name>
Add TCP 53 as well, so large answers and DNSSEC replies can fall back cleanly:
openstack security group rule create --egress --protocol tcp --dst-port 53 --remote-ip 0.0.0.0/0 <group-name>
If your policy allows it, narrow --remote-ip to the resolvers you actually use instead of the whole internet.
The rule takes effect on the running VM. No reboot, no rebuild.
While you are in that list, think about the other UDP the server needs. Time sync uses UDP 123. A server with no UDP egress also has no NTP, and on a mail server or a backup target, a clock that drifts causes its own set of problems.
Step 4: Verify — Where Most Tutorials Stop and Where Mine Starts
Run the normal query again, the one that failed:
dig example.com @1.1.1.1
It must now return status: NOERROR and an answer, without +tcp.
Then test the way the operating system resolves, not just dig:
getent hosts example.com
This goes through the system’s normal resolver path. If dig works and getent does not, the problem is now inside the VM (resolv.conf, nsswitch, a local cache), and that is a different article.
On a mail server, also test the lookup the mail server itself makes. With Exim:
exim -bt [email protected]
A working result shows the remote router and the MX host it found. A DNS failure here shows up as a defer, not a delivery route.
Finally, run whatever first failed for you, such as a package update. If it works now, the build can carry on.
The Same Group Had Two More Problems
Once I was reading that security group line by line, I kept reading. On the same VM, on the same day, I found two more mistakes in it. Neither one was visible from inside the server either, because the server’s own firewall accepted everything and left all control to the security group.
The admin rule had a typo. The ingress rule for the SSH port was meant to allow one admin IP. One octet in it was wrong. The rule looked right at a glance, and it allowed an address nobody used. Plain takeaway: read every IP in an allow rule digit by digit, and test from the real admin network, not from inside the cloud.
The mail ports were missing. The group was built for remote admin, and nobody had added SMTP, submission, IMAP and POP for a server whose whole job was mail. Inbound mail would have timed out at the hypervisor, exactly like the DNS did.
The general lesson is simple. When the cloud firewall holds all the control, the server’s firewall tells you nothing. You have to read the cloud one.
One More Cloud DNS Trap: The Floating IP Is Not on the NIC
The panel I was installing also runs its own authoritative DNS server for hosted domains. That brought up a related trap.
In OpenStack, the public address is usually a floating IP. It is NAT on the router. The VM’s network card only has a private address:
Internet → floating IP on the router → NAT → private IP on the VM's NIC
So the public IP never appears in ip addr inside the VM. If a DNS server is configured to listen on the public IP, it has nothing to bind to. It must listen on the private NIC address, and the router’s NAT takes care of the rest.
Check what the VM really has:
ip -4 addr show
Then check what the DNS service is actually listening on:
ss -lunp | grep ':53 '
If you see only 127.0.0.1:53, or nothing, the service is not reachable from outside no matter how the security group looks. On a cPanel server running PowerDNS, the listen address is set in /etc/pdns/pdns.conf (local-address), and it must be the private NIC address, not the floating IP. And remember the ingress side: an authoritative DNS server needs UDP 53 in as well as TCP 53.
The Checklist I Run on Every New Cloud VM
- UDP DNS out works.
dig example.com @1.1.1.1 - TCP DNS out works.
dig +tcp example.com @1.1.1.1 - The system resolver works.
getent hosts example.com - Time sync can reach its source.
timedatectlshowsSystem clock synchronized: yes - Egress rules are what you think they are.
openstack security group rule list <group-name> --egress - Ingress rules match the server’s role.
openstack security group rule list <group-name> --ingress, read every IP digit by digit - Services listen on the NIC address, not the floating IP.
ss -lntup - The test comes from outside. From the real admin network, not from another VM in the same project.
None of these take more than a minute. All of them catch problems that the guest operating system cannot see.
What I Tell Every Customer Now
When a customer hands me a new cloud VM, I ask one question before I install anything:
“Who owns the security group on this VM, and has anyone removed the default outbound rules?”
If the answer is “it’s the default group, untouched”, they’re in good shape on egress, and I move on to ingress. If the answer is “we hardened it” or “we copied it from another project”, we’re not done yet. We read every rule, both directions, before the first package install.
I write about the questions I ask in real customer rooms — the ones that change architectures and surface the problems no one else noticed. If you found this useful, drop your email below and I’ll send the next one when it’s ready.
FAQs
Why does dig +tcp work when a normal DNS lookup fails?
A normal lookup uses UDP port 53, and only uses TCP when the UDP reply is truncated or TCP is forced. If a firewall drops outbound UDP but allows outbound TCP, the TCP query gets through and the normal one times out. That difference points at a firewall rule, not at the resolver or the name.
Why can’t I see the block in iptables or nftables on the VM?
An OpenStack security group is enforced by Neutron on the hypervisor side of the VM’s port, outside the guest operating system. The guest’s own firewall rules never show it. From inside the VM, the packet is sent and simply never answered.
Does the default OpenStack security group allow DNS out?
The default security group normally includes allow-all egress rules for IPv4 and IPv6, so DNS out works. The problem appears when those rules were removed or the VM uses a custom group that only allows some outbound traffic. Check with openstack security group rule list <group-name> --egress.
Do I need to reboot the VM after adding the egress rule?
No. Security group rules apply to the running port as soon as they are created. Run the failing dig query again right away to confirm.
Why should a DNS server on an OpenStack VM not listen on the floating IP?
A floating IP is NAT on the OpenStack router; it is never assigned to the VM’s network card. The DNS service can only bind to addresses that exist inside the VM, so it must listen on the private NIC address. The router maps the floating IP to that address for incoming queries.