Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Jan 2016 01:45:26 -0800
From:      perryh@pluto.rain.com (Perry Hutchison)
To:        freebsd-questions@freebsd.org
Subject:   resolver not working in a chroot
Message-ID:  <569e05b6.2RStkLc7SZIg/dVM%perryh@pluto.rain.com>

next in thread | raw e-mail | index | archive | help
The resolver is not working in a chroot (to the 10.2 memstick image,
with its /tmp, /var/run, and /var/tmp made writable by mounting tmpfs
on them):
  # chroot -u 0 -g 0 -G 105,0,5,20,25 /mnt ping pkg.FreeBSD.org
  ping: cannot resolve pkg.FreeBSD.org: Host name lookup failure

but it works when not in a chroot:
  # ping pkg.FreeBSD.org
  PING pkg.FreeBSD.org (96.47.72.71): 56 data bytes
  64 bytes from 96.47.72.71: icmp_seq=0 ttl=51 time=97.329 ms
  ...

What would cause this?

So far I have checked:

ping works in the chroot if given the IP address (showing that
the chroot environment does have network access, so the resolver
"should" be able to reach a nameserver):
  # chroot -u 0 -g 0 -G 105,0,5,20,25 /mnt ping 96.47.72.71
  PING 96.47.72.71 (96.47.72.71): 56 data bytes
  64 bytes from 96.47.72.71: icmp_seq=0 ttl=51 time=97.717 ms
  ...

host(1) works, and gives the same result, in both environments:
  # host pkg.FreeBSD.org
  pkg.FreeBSD.org has address 96.47.72.71
  ...

  # chroot -u 0 -g 0 -G 105,0,5,20,25 /mnt host pkg.FreeBSD.org
  pkg.FreeBSD.org has address 96.47.72.71
  ...

Ignoring comments, both /etc/nsswitch.conf are the same:
  # egrep -v '^#' /etc/nsswitch.conf
  group: compat
  group_compat: nis
  hosts: files dns
  networks: files
  passwd: compat
  passwd_compat: nis
  shells: files
  services: compat
  services_compat: nis
  protocols: files
  rpc: files

  # chroot -u 0 -g 0 -G 105,0,5,20,25 /mnt egrep -v '^#' /etc/nsswitch.conf
  group: compat
  group_compat: nis
  hosts: files dns
  networks: files
  passwd: compat
  passwd_compat: nis
  shells: files
  services: compat
  services_compat: nis
  protocols: files
  rpc: files

as are both /etc/resolv.conf:
  # egrep -v '^#' /etc/resolv.conf
  nameserver      192.168.0.1
  nameserver      8.8.8.8
  nameserver      8.8.4.4

  # chroot -u 0 -g 0 -G 105,0,5,20,25 /mnt egrep -v '^#' /etc/resolv.conf
  nameserver      192.168.0.1
  nameserver      8.8.8.8
  nameserver      8.8.4.4

and there is no mention of any freebsd.org host in either
environment's /etc/hosts:
  # egrep 'freebsd\.org' /etc/hosts

  # chroot -u 0 -g 0 -G 105,0,5,20,25 /mnt egrep 'freebsd\.org' /etc/hosts




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?569e05b6.2RStkLc7SZIg/dVM%perryh>