9

I like Ubuntu's NetworkManager -- it does a great job keeping track of all my WiFi parameters and passwords. However, when I actually plug in an Ethernet cable, the frustration begins.

When hooked up to my work LAN, I'd like to force a particular domain search path. But I can't just edit resolv.conf, since NetworkManager will always overwrite it. And I can't change the settings on the DHCP server.

As a total hack, I set up a script to run whenever the network is brought up. It looks at resolv.conf, and if it's the one from the work LAN, it overwrites it. However, this doesn't work well enough -- it seems that periodically resolv.conf will get overwritten by something that doesn't trigger my script.

Is there a less hacky way to do this? Or even a more hacky way, provided that it actually works?

mike
  • 3,853
  • 11
  • 29
  • 27

4 Answers4

12

Assuming you are using Ubuntu and a connection named "Wired connection"

edit /etc/NetworkManager/system-connections/Wired connection and add the following:

[ipv4]
method=auto
dns-search=a1.domain.com;a2.domain.com;a3.domain.com;
Alex
  • 3,079
  • 20
  • 28
Maoz Zadok
  • 292
  • 4
  • 9
5

I think you can set your "search domain" right in Network Manager.

  1. Right-click on nm-applet
  2. Select Edit Connections
  3. Click on auto eth0 and select Edit
  4. click on the ipv4 Settings tab, and fill in the search domsins line (may have to select automatic (DHCP) addresses only from the dropdown list.)

Hope that helps.

Brent
  • 22,219
  • 19
  • 68
  • 102
2

If you add the proper parameters to your dhclient.conf, they will get put into the resolv.conf when it is rewritten

supersede domain-name "mydomain.com"

might be what you're looking for. Check the man page or online documentation for dhclient for more details.

Kevin Kuphal
  • 9,064
  • 1
  • 34
  • 41
  • Cool! So if I want the line "search local mydomain.com" to always be in /etc/resolv.conf, what's the supersede line for that? – mike Jul 08 '09 at 18:11
-1

https://www.netroby.com/view/3630#.U2mTfHVdUc0 https://unix.stackexchange.com/questions/128220/how-do-i-set-my-dns-when-resolv-conf-is-being-overwritten

You can write nameserver in the config right before the DNS server with nameserver x.x.x.x

vn.
  • 375
  • 2
  • 10