1

I have a problem. So, when I connect to any wi-fi station I can't use google or yandex. I solved that. The thing was in dns. I added google dns servers to 'resolv.conf' and it worked fine. However, after reconnection it does the same thing and I have to write manually or with script to set dns. Is there any way to make this process automatically when the computer connects to the network? I tried to do it through the network/interfaces post-up and if-up.d . But it didn't help. The code is like that.

interfaces:

auto wlan0
    iface wlan0 inet dhcp
    post-up /etc/network/ssh_and_dns_start

ssh_and_dns_start:

#!/bin/sh

add_dns()
{
echo "nameserver 8.8.8.8
nameserver 8.8.4.4" >> /etc/resolv.conf
}

add_dns
exit 0
  • 1
    See askubuntu.com/questions/2321/… – Panther Dec 26 '15 at 14:08
  • @bodhi.zazen Thank you very much! But is there any chance to set default dns settings? Or should I add these dns to every network manually? – Дима Долгополов Dec 26 '15 at 16:00
  • What are you trying to do exactly ? In the link there are several options to set your dns server. And what do you mean by "dns to every network manually"? – Panther Dec 26 '15 at 18:33
  • @bodhi.zazen there is a method for setting dns for one network through Network Settings. But I want these setting for every network that I will connect in the future. Kinda default settings. That is my question. – Дима Долгополов Dec 27 '15 at 14:44
  • Those settings should work on all networks you connect to. – Panther Dec 28 '15 at 16:42
2

Try adding this to /etc/dhcp/dhclient.conf

interface "wlan0"{
  supersede domain-name-servers 8.8.8.8, 8.8.4.4;
}
0

The way I did it was hackish and probably not the way you would want to do it, but if you just need the bleeping thing working...

So I had set up Kali connected to ethernet and when I went to add a wifi connection, no DNS. /etc/resolv.conf pointed to something like /run/resolvconf/... which pointed to yet another thing.

There's not the option to sudo yourself and vim /etc/resolv.conf - for a few reasons. So logout, login as root, delete the symlink /etc/resolvconf/... points to, then vim /etc/resolv.conf and add the nameservers you want, e.g.

nameserver your.gateway.ip

or

nameserver 8.8.8.8
nameserver 8.8.4.4

Before this, you can try

root@kali# dhclient wlan0

to get some information. I didn't find it very helpful. Editing the wireless connection settings with the GUI didn't work for me, even though it picked up on the nameservers. I just went ahead and deleted the symlink for /etc/resolv.conf and created /etc/resolv.conf, and all was fine.

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.