Re: /etc/hosts doesn't work in jails?

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Mon, 08 Jan 2024 03:19:40 UTC

> On Jan 8, 2024, at 4:05 AM, Yuri <yuri@FreeBSD.org> wrote:
> 
> For some mysterious reason github.com can't be connected to from my network because the IP address that DNS returns is unreachable.
> 
> 
> 
> Setting the new resolution rules in /etc/hosts works on the base host:
> 
> 140.82.112.4     github.com 
> 140.82.113.10    codeload.github.com
> 
> 
> But the same doesn't work in the poudriere jail. The same modification in the jail's /etc/hosts didn't take effect.
> 
> /etc/resolve.conf files are identical.
> 
> 
> 
> I am wondering, are /etc/host files supposed to work in jail?
> 
> 

If you mean /etc/hosts , I'd say yes.

```
# jail -ic vnet persist
3
# jexec 3
# truss ping -c1 example.org <http://example.org/>
...

open("/etc/nsswitch.conf",O_RDONLY|O_CLOEXEC,0666) = 3 (0x3)
...
open("/etc/hosts",O_RDONLY|O_CLOEXEC,0666)	 = 3 (0x3)
...
```
> 
> (I solved this problem by adding the same rules for github.com in DNSMasq on the router.)
> 
> 
> 
> 
> 
> Thanks,
> 
> Yuri
> 

Best regards,
Zhenlei