Add custom items to Ubuntu NM dnsmasq.conf

Dieser Post wurde aus meiner alten WordPress-Installation importiert. Sollte es Darstellungsprobleme, falsche Links oder fehlende Bilder geben, bitte einfach hier einen Kommentar hinterlassen. Danke.

The Ubuntu NetworkManager (NM) is great (exept for servers), it's taking care of all network issues up to VPN. NM supports using multiple network connections with multiple DNS servers and probably multiple private domains by running a local DNSmasq process which will forward all lookup requests to the proper nameserver. But the NM is new and still missing some feature - like additional or custom configuration lines for DNSmasq.

I'm a web developer and while most of my projects use a local webserver like YAWF's or PSGI/Plack's plackup, some projects require special domain names to determine the correct configuration for this zone/installation/whatever. I can't change this for some reasons, but still want to run my local webserver for development without setting up virtual servers on my laptop.

I started adding those names to /etc/hosts and let them point to but it turned out that either /etc/hosts doesn't support wildcards or I am too dump to find out how.

DNSmasq is reading a config file on startup which may easily take my configuration but the NM is writing it's own config file and DNSmasq supports only one. I though about extending it lateron and let DNSmasq reload the file - but reloading config isn't supported my DNSmasq.

Here is a quick-and-dirty walkaround for the the problem. It will stop to work on any OS or DNSmasq update, so you need to redo it after upgrading Ubuntu but it will work in case you can't (or don't want to) wait for a clean solution.

First, open a terminal and go to your /usr/sbin directory, the home of the dnsmasq binary and rename it:

cd /usr/sbinsudo mv dnsmasq dnsmasq.bin
Now create a small wrapper script extending the config file and running the real dnsmasq binary. Use your favorite text editor (like gedit, but not LibreOffice!) to put these two lines into a blank file:
#!/bin/bashexec /usr/sbin/dnsmasq.bin $* --conf-dir=/etc/dnsmasq.d
Save this as /tmp/dnsmasq (without extension) and run these commands to move the new dnsmasq wrapper script to the /usr/sbin, change the owner to root and make it executable:
sudo mv /tmp/dnsmasq .sudo chmod 0755 dnsmasqsudo chown 0.0 dnsmasq
Any additional DNSmasq config files may be placed in /etc/dnsmasq.d and will be used after the next reboot. The NetworkManager will also launch a new DNSmasq process if none is running after any change to your network connections (like connecting/disconnecting any LAN or WLAN or VPN). I wrote one line to the a new file in /etc/dnsmasq.d:



Which will redirect all requests to any domain ending with .dev.internal (like to my local computer.


Noch keine Kommentare. Schreib was dazu

Schreib was dazu

Die folgenden HTML-Tags sind erlaubt:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>