Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hosts public ip address in /etc/hosts for rootless containers #12000

Closed
asbachb opened this issue Oct 17, 2021 · 8 comments · Fixed by #12375
Closed

Use hosts public ip address in /etc/hosts for rootless containers #12000

asbachb opened this issue Oct 17, 2021 · 8 comments · Fixed by #12375
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@asbachb
Copy link

asbachb commented Oct 17, 2021

Follow up to #8466

@mheon: Please open a bug about this - we should probably change over to the host's public IP for rootless containers.

root@d9e153cabee0:/# cat /etc/hosts 
127.0.0.1	localhost
127.0.1.1	vm-virtualbox

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
# used by slirp4netns
10.0.2.100	d9e153cabee0 jolly_borg
10.0.2.2 host.containers.internal

But the container does not seem to be able to route to the host:

vm@vm-virtualbox:~$ python3 -m http.server 8000
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
root@d9e153cabee0:/# curl http://127.0.1.1:8000
curl: (7) Failed to connect to 127.0.1.1 port 8000: Connection refused
root@d9e153cabee0:/# curl http://10.0.2.2:8000
curl: (7) Failed to connect to 10.0.2.2 port 8000: Network is unreachable
@rhatdan
Copy link
Member

rhatdan commented Oct 18, 2021

I think the routing problem is a firewall problem.

@asbachb
Copy link
Author

asbachb commented Oct 18, 2021

I think the routing problem is a firewall problem.

These pastes are from a vm without firewall.

@mheon
Copy link
Member

mheon commented Oct 19, 2021

@rhatdan Negative. The host.containers.internal entry is pointing to the internal slirp4netns address, which isn't really the host - you can't access any port opened on the host at that address, for example. I think that, given the intention of host.containers.internal to allow easy access to the host, we should point to a public IP on the host system.

@mheon mheon added the kind/bug Categorizes issue or PR as related to a bug. label Oct 19, 2021
@rhatdan
Copy link
Member

rhatdan commented Oct 19, 2021

The question is how do you discover the public IP of the host?

@Luap99
Copy link
Member

Luap99 commented Oct 20, 2021

Not the public IP. It should be the first non localhost ipv4 of all host interfaces IMO, e.g the same way you did this in buildah.
For bridge networking we can use the bridge gatway.

@mheon
Copy link
Member

mheon commented Oct 20, 2021

Approach from @Luap99 seems correct

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

rhatdan added a commit to rhatdan/podman that referenced this issue Dec 21, 2021
Add first non localhost ipv4 of all host interfaces as destination
for host.contaners.internal for rootless containers.

Fixes: containers#12000

Signed-off-by: Daniel J Walsh <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants