A quick summary on how to fix the most common dns issues when using dhcp behind an inexpensive router and why editing /etc/resolv.conf manually doesn't work for long:
When manually adding a nameserver to /etc/resolv.conf, it is only a temporary solution since dhclient (actually dhclient-script) overwrites this file on re-lease or reboot. This only happens when using dhcp. Thus manually editing resolv.conf might only be useful during a "live-cd" session or when you are running a static ip.
Various tricks like changing the permissions of resolv.conf eventually fail because dhclient runs as root and overwrites it. Other tricks like making the file immutable (using chattr) are also not recommended.
Of course one could always run static where nothing overwrites resolv.conf, but the following is what I recommend for the anyone behind an inexpensive router running dhcp when they only see their router's dns server (actually a dns forwarder masquerading as a dns server in many cases) in resolv.conf
Option 1: place your isp's primary and backup dns server addresses in the router setup page.
Option 2: Uncomment and edit (as root, ie sudo) the PREPEND line of /etc/dhcp3/dhclient.conf and place your isp's dns nameserver(s) there. In case of multiple nameservers, be sure to separate them with a comma and end the line with a semicolon.
Option 3: Edit (as root) dhclient-script and remove all the commands in the mk_resolv.conf{} function so your edited resolv.conf won't be overwritten. Not recommended as option 1 or 2 usually suffices and many of us (myself included) can mess up the edit.
After applying one of these fixes, you should bring your interface down and up again, or maybe the easiest is to just reboot.
IPV6 - even after all this sometimes our inexpensive hardware may have trouble with IPV6. Normally I don't recommend disabling it, but if you feel you should, you can disable it globally by creating a file titled "bad_list" in /etc/modprobe.d directory. bad_list can contain just this line:
alias net-pf-10 off
阅读(3511) | 评论(1) | 转发(0) |