rootless-containers / slirp4netns

User-mode networking for unprivileged network namespaces
GNU General Public License v2.0
729 stars 82 forks source link

Can't see client IPs #250

Closed rlpowell closed 3 years ago

rlpowell commented 3 years ago

When I run rootless podman and publish a port and people connect to that port on the host, the apparent IP of the connection from the container's POV is always 127.0.0.1.

Example:

stodi$ podman run -p 9999:9999 --rm -it docker.io/library/ruby:2.7 bash
[just happened to have that image lying around; ran apt-get to get nc]
root@e3c2a335ca40:/# nc -l -p 9999 -vvvv
listening on [any] 9999 ...

Other window:

echo foo | nc stodi 9999

Back on the container:

root@e3c2a335ca40:/# nc -l -p 9999 -vvvv
listening on [any] 9999 ...
connect to [127.0.0.1] from localhost [127.0.0.1] 52748
foo
 sent 0, rcvd 4
root@e3c2a335ca40:/#
AkihiroSuda commented 3 years ago

This is because you are using RootlessKit port forwarder, not using slirp4netns port forwarder. Please see here to change the port forwarder to slirp4netns: https://rootlesscontaine.rs/getting-started/podman/#changing-the-port-forwarder

rlpowell commented 3 years ago

Oh, yay! Thank you!