Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Short Answer

0.0.0.0 has no single meaning; it depends on where it appears:

WhereMeaning
A listening serviceEvery IPv4 address here
0.0.0.0/0 in a routeThe default route
0.0.0.0/0 in a ruleAny address
A DHCP requestNo address yet
A hosts fileGo nowhere (block)

When a Service Listens on 0.0.0.0

A program that binds to 0.0.0.0 accepts connections on every IPv4 address the server has: the public address, any private address, and 127.0.0.1. List the listening ports:

sudo ss -tlnp

A typical result, shortened to the address and the process, looks like this:

0.0.0.0:22       users:(("sshd",...))
127.0.0.1:3306   users:(("mysqld",...))
0.0.0.0:80       users:(("nginx",...))
[::]:80          users:(("nginx",...))

SSH on 0.0.0.0:22 is reachable on every IPv4 address. MySQL on 127.0.0.1:3306 is reachable only from the server itself. Nginx holds two sockets for port 80: 0.0.0.0:80 for every IPv4 address and [::]:80 for every IPv6 address. More in how to check open ports in Linux.

0.0.0.0 vs 127.0.0.1

127.0.0.1 is the loopback address: a service bound to it can be reached only by programs on the same machine. 0.0.0.0 opens the service to every network the machine is on. Developers meet this when an application works on the server but not from outside: it is bound to 127.0.0.1 and needs 0.0.0.0, or the server's own address, to be reachable. See what is localhost.

0.0.0.0 is not a destination. A connection to it may happen to reach the local machine on Linux, but that is a side effect, not something to rely on; connect to 127.0.0.1 or to the server's address.

What It Means for Safety

A database, cache, or admin panel that listens on 0.0.0.0 is reachable from the internet unless a firewall stops it, and automated scanners look for exactly that. Bind internal services to 127.0.0.1, or to a private address when other servers need them, and keep a firewall as a second layer. In MySQL and MariaDB the setting is bind-address; how to open it to one other server safely is in MySQL remote access.

0.0.0.0/0 as the Default Route

In routing, 0.0.0.0/0 is a prefix with no fixed bits, so it matches every address. It is the route of last resort: packets that match nothing more specific go to the default gateway. Linux prints it as default:

ip route
default via 203.0.113.1 dev eth0

See what is a default gateway.

0.0.0.0/0 in Firewall Rules

In firewall rules and cloud security groups, 0.0.0.0/0 means "from anywhere". A rule that allows port 22 from 0.0.0.0/0 accepts SSH from every IPv4 address. With ufw, sudo ufw allow 22/tcp does that, while the following limits SSH to one address:

sudo ufw allow from 198.51.100.7 to any port 22 proto tcp

Keep "anywhere" rules for public services such as ports 80 and 443, and use narrower sources for SSH and databases where you can.

The IPv6 Counterpart

In IPv6 the all-zero address is written ::. A service bound to [::] listens on every IPv6 address, and ::/0 is the IPv6 default route and "anywhere" in firewall rules. On Linux, a socket on [::] also accepts IPv4 connections unless the program marks it as IPv6 only (the system default is set by net.ipv6.bindv6only, off unless changed), which is why some services show only [::] and still answer on IPv4. Others, Nginx among them, mark their [::] sockets IPv6 only by default and open a separate 0.0.0.0 socket for IPv4.

Docker Publishes on 0.0.0.0

docker run -p 8080:80 publishes port 8080 on every address of the host, and Docker's own firewall rules let the traffic in even when ufw denies the port. To keep a container private, publish it on loopback:

docker run -d -p 127.0.0.1:8080:80 nginx

Details are in Docker port mapping.

Was this answer helpful?
Loading...