Icecast: auth to server failed with could not resolve host

in Servers


The problem

Consider this configuration in icecast.xml


    /your-mount
    
        

... resulting in this error:

WARN auth_url/url_add_listener auth to server http://example.com/auth_mount failed with Could not resolve host: example.com

To debug, you wget -O /dev/null http://example.com/auth_mount on the same server and it works file.

That means it's Icecast itself (the daemon) that cannot resolve the hostname. This typically happens because Icecast runs under a different user or chroot environment, or uses a different DNS resolver configuration.

Check if Icecast is chrooted

  • look for <chroot>1</chroot> in icecast.xml
  • run ps aux | grep icecast and look for the -b flag

Solution

Icecast needs /etc/resolv.conf, which when chrooted, would be /${basedir}/etc/resolv.conf, where ${basedir} is the value of paths - basedir in your icecast.xml. Assume it's /home/icecast.

First, ensure /etc folder exist in chroot:

mkdir -p /home/icecast/etc

Then your options are:

  • create a new resolv.conf

    echo "nameserver 1.1.1.1" > /home/icecast/etc/resolv.conf
  • copy (duplicate) existing resolv.conf from your host system

    cp /etc/resolv.conf > /home/icecast/etc/resolv.conf
  • mount (reuse) resolv.conf from your host system

    FreeBSD:

      touch /home/icecast/etc/resolv.conf
      mount -t nullfs /etc/resolv.conf /home/icecast/etc/resolv.conf

    Debian:

    touch /home/icecast/etc/resolv.conf
    mount --bind /etc/resolv.conf /home/icecast/etc/resolv.conf

If you use HTTPs for your authentication URL, next thing you are likely to run into would be:

WARN auth_url/url_add_listener auth to server https://example.com/auth failed with SSL certificate problem: unable to get local issuer certificate

Using plain HTTP endpoint not only solves the above but also comes with much lower overhead on every connection.

Related

#icecast #chroot