-1

I have my company network and my home network configured in linux networking, using an alias interface. (pinging IPs works.)

Now in resolv.conf I have

timeout 1
nameserver 10.1.1.1
nameserver 192.168.1.1

the first representing the company network, the second my private lan.

Being at my company, this works, beeing at home, it does with a huge delay. I have to swap the order of both nameserver entries to get it working without delay. So it looks like there is a timeout in which it tries to access the first nameserver, waits ~3 seconds then goes for the next. Does my timeout 1 not work or can that be shorter?

The problem is the same when I'm at my company's lan with the nameservers swapped like:

timeout 1
nameserver 192.168.1.1
nameserver 10.1.1.1

How does it work without editing the order of the nameservers?

Daniel W.
  • 1,609
  • 4
  • 26
  • 48
  • What exactly doesn't work? – ALex_hha Jul 21 '13 at 10:04
  • @ALex_hha beeing in my lan network with the company's nameserver on top I have a ping saying: `3 packets transmitted, 3 recieved, 0% packet loss, time 10107ms`. When I ping the IP of that same host it sais the same but 10 times faster ping.. – Daniel W. Jul 21 '13 at 10:12
  • Hmm, in your first post you said that at home it doesn't work at all. And now it seems that it work, but with some delay. How is you home pc is connected with you company network? – ALex_hha Jul 21 '13 at 10:51
  • I edited the question. It's not a networking problem (it works fine with ips instead of hostnames). There is some timeout I cannot identify. The same problem is when I'm at my company's network and have my private lan nameserver above the company's one. – Daniel W. Jul 21 '13 at 10:55
  • The easiest way would be in using dhcp server. According to the man page (http://linux.die.net/man/5/resolv.conf), timeout should be written with :. timeout: 1 attempts: 1 – ALex_hha Jul 21 '13 at 11:17

2 Answers2

2

That's perfectly normal. Your machine always tries the first nameserver in resolv.conf first. If it isn't reachable (because it doesn't exist in the network you are), it will wait until timeout before trying the second one.

If you want to avoid editing resolv.conf everytime you change your network, the solution depends on the dhcp-configuration of the network and the configuration of your client.

If your DHCP servers are configured to push nameservers when obtaining an IP, you can just tell NetworkManager (or dhcpcd or whatever you use to get your IP) to automatically rewrite your resolv.conf with the nameservers from DHCP. In NetworkManager, you can also manually configure different nameserver configurations for different connections.

etagenklo
  • 5,834
  • 1
  • 27
  • 32
1

Putting the restriction of not editing the resolv.conf will result in one location always being slower resolving. However, I believe the line you are looking for is

 options timeout:1

There is a package resolvconf that is designed specifically for this situation. It will rewrite your resolv.conf file based on interfaces being up, PPP connections made, and DHCP responses.

BillThor
  • 27,737
  • 3
  • 37
  • 69
  • Ah, I missplaced `options timeout: 1` by `timeout 1`, this in combination with `attempts: 1` runs fine. Don't need the package `resolvconf` package but will have a look at it, thx – Daniel W. Jul 21 '13 at 16:06
  • @DanFromGermany You may want to try `rotate` in place of `attempts:1`. Setting `attempts:` will result in failures if a request gets dropped on the network. – BillThor Jul 23 '13 at 00:11