Binding to all network interfaces can potentially open up a service to traffic on unintended interfaces.
Acccording to their specifications, the following addresses are "unspecified" addresses:
0.0.0.0
in IPv40:0:0:0:0:0
(or just ::
) in IPv6When you bind a socket to all interfaces using an "unspecified" address as the IP address, you essentially allow it to accept connections from any IP address provided, that can get to the socket via routing. Binding to all interfaces is therefore associated with security risks and is not recommended.
use std::net::TcpListener;
let listener = TcpListener::bind("0.0.0.0:80")?;
use std::net::TcpListener;
let listener = TcpListener::bind("127.0.0.1:80")?;