Sometimes when I run the commands:

sudo apk update && sudo apk upgrade

Over Alpine linux fails to update the packages even if connected to internet. But if I do sudo su "echo 'nameserver' > /etc/resolv.conf" I manage to dowload them. But this solution:

  • Causes me frustration I need to set dns all over the time.
  • Sometimes /etc/resolv.conf gets overriden by itself.

How I can have a more permanent solution.


You can solve the problem by installing the dhclient package. For the last time enable Google's DNS servers by runing for the last time:

sudo su "echo 'nameserver' > /etc/resolv.conf"

Then run this cocktail of commands:

sudo apk update && sudo apk upgrade && sudo apk add dhclient

In order to get the fresh packages and install the dhclient. Then configure the /etc/dhcp/dhclient.conf and put the following:

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers;

prepend domain-name-servers,;

And restart the networking:

sudo rc-service networking restart

Optionally you can confirm that works if you run:

sudo reboot

In either case you can confirm that dns is resolved by pinging the google.

ping google.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.