<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi,<br></div><div class="gmail_quote"><div dir="ltr"><div style="font-size:small"><br></div><div style="font-size:small">I am using dnsmasq 2.68 on Ubuntu 14.04 and when I run the following command I get an error:</div>
<div style="font-size:small"><br></div><div><div><font face="courier new, monospace">$ sudo dnsmasq --no-dhcp-interface --bind-interfaces --listen-address=169.254.1.1</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">dnsmasq: failed to create listening socket for port 53: Address already in use</font></div>
<div><br></div><div>Running "sudo netstat -anlp | grep -w LISTEN" shows:</div><div><br></div></div><div><div><font face="courier new, monospace">tcp 0 0 <a href="http://127.0.1.1:53" target="_blank">127.0.1.1:53</a> 0.0.0.0:* LISTEN 1272/dnsmasq </font></div>
<div><font face="courier new, monospace">tcp 0 0 <a href="http://10.0.3.1:53" target="_blank">10.0.3.1:53</a> 0.0.0.0:* LISTEN 1140/dnsmasq </font></div><div><font face="courier new, monospace">tcp 0 0 <a href="http://0.0.0.0:22" target="_blank">0.0.0.0:22</a> 0.0.0.0:* LISTEN 1033/sshd </font></div>
<div><font face="courier new, monospace">tcp 0 0 <a href="http://127.0.0.1:631" target="_blank">127.0.0.1:631</a> 0.0.0.0:* LISTEN 2190/cupsd </font></div><div><font face="courier new, monospace">tcp 0 0 <a href="http://0.0.0.0:17500" target="_blank">0.0.0.0:17500</a> 0.0.0.0:* LISTEN 2484/dropbox </font></div>
<div><font face="courier new, monospace">tcp6 0 0 fe80::1c44:45ff:fec7:53 :::* LISTEN 1140/dnsmasq </font></div><div><font face="courier new, monospace">tcp6 0 0 :::22 :::* LISTEN 1033/sshd </font></div>
<div><font face="courier new, monospace">tcp6 0 0 ::1:631 :::* LISTEN 2190/cupsd </font></div></div><div><br></div><div><div style="font-size:small">
However, if I run the following command there is no error and dnsmasq successfully binds to the specified address:</div><div style="font-size:small"><br></div><div><font face="courier new, monospace">$ sudo dnsmasq --no-dhcp-interface <b>--pid-file</b> --bind-interfaces --listen-address=169.254.1.1<br>
</font></div><div><span style="font-family:'courier new',monospace">$ sudo netstat -anlp | grep -w LISTEN</span><br></div><div><font face="courier new, monospace"><b><div style="font-size:small;display:inline">
</div>tcp 0 0 <a href="http://169.254.1.1:53" target="_blank">169.254.1.1:53</a> 0.0.0.0:* LISTEN 3345/dnsmasq </b></font></div><div><font face="courier new, monospace">tcp 0 0 <a href="http://127.0.1.1:53" target="_blank">127.0.1.1:53</a> 0.0.0.0:* LISTEN 1272/dnsmasq </font></div>
<div><font face="courier new, monospace">tcp 0 0 <a href="http://10.0.3.1:53" target="_blank">10.0.3.1:53</a> 0.0.0.0:* LISTEN 1140/dnsmasq </font></div><div><font face="courier new, monospace">tcp 0 0 <a href="http://0.0.0.0:22" target="_blank">0.0.0.0:22</a> 0.0.0.0:* LISTEN 1033/sshd </font></div>
<div><font face="courier new, monospace">tcp 0 0 <a href="http://127.0.0.1:631" target="_blank">127.0.0.1:631</a> 0.0.0.0:* LISTEN 2190/cupsd </font></div><div><font face="courier new, monospace">tcp 0 0 <a href="http://0.0.0.0:17500" target="_blank">0.0.0.0:17500</a> 0.0.0.0:* LISTEN 2484/dropbox </font></div>
<div><font face="courier new, monospace">tcp6 0 0 fe80::1c44:45ff:fec7:53 :::* LISTEN 1140/dnsmasq </font></div><div><font face="courier new, monospace">tcp6 0 0 :::22 :::* LISTEN 1033/sshd </font></div>
<div><font face="courier new, monospace">tcp6 0 0 ::1:631 :::* LISTEN 2190/cupsd </font></div></div><div><br></div><div><div style="font-size:small">
So somehow when I specify --pid-file option, it works, but not otherwise. Also I noticed that no matter what is specified for the pid-file option, it writes the pid to <font face="courier new, monospace">/var/run/dnsmasq.pid</font> even in the above case when it is supposed to disable pid-file:</div>
<div style="font-size:small"><br></div><div><div><font face="courier new, monospace">$ cat /var/run/dnsmasq.pid </font></div><div>
<font face="courier new, monospace"><b>3345</b></font></div><div style="font-size:small"><br></div></div><div style="font-size:small">If I specify another file to be used for pid-file, it still writes the pid to <font face="courier new, monospace">/var/run/dnsmasq.pid</font>:</div>
<div style="font-size:small"><br></div><div><font face="courier new, monospace">$ sudo kill 3345<br></font></div><div><font face="courier new, monospace">$ sudo netstat -anlp | grep -w LISTEN<br>
</font></div><div><font face="courier new, monospace">tcp 0 0 <a href="http://127.0.1.1:53" target="_blank">127.0.1.1:53</a> 0.0.0.0:* LISTEN 1272/dnsmasq </font></div><div><font face="courier new, monospace">tcp 0 0 <a href="http://10.0.3.1:53" target="_blank">10.0.3.1:53</a> 0.0.0.0:* LISTEN 1140/dnsmasq </font></div>
<div><font face="courier new, monospace">tcp 0 0 <a href="http://0.0.0.0:22" target="_blank">0.0.0.0:22</a> 0.0.0.0:* LISTEN 1033/sshd </font></div><div><font face="courier new, monospace">tcp 0 0 <a href="http://127.0.0.1:631" target="_blank">127.0.0.1:631</a> 0.0.0.0:* LISTEN 2190/cupsd </font></div>
<div><font face="courier new, monospace">tcp 0 0 <a href="http://0.0.0.0:17500" target="_blank">0.0.0.0:17500</a> 0.0.0.0:* LISTEN 2484/dropbox </font></div><div><font face="courier new, monospace">tcp6 0 0 fe80::1c44:45ff:fec7:53 :::* LISTEN 1140/dnsmasq </font></div>
<div><font face="courier new, monospace">tcp6 0 0 :::22 :::* LISTEN 1033/sshd </font></div><div><font face="courier new, monospace">tcp6 0 0 ::1:631 :::* LISTEN 2190/cupsd </font></div>
</div><div><font face="courier new, monospace"><div style="font-size:small;display:inline">$ </div>sudo rm /var/run/dnsmasq.pid<br></font></div><div><font face="courier new, monospace">$ sudo dnsmasq --no-dhcp-interface <b><div style="font-size:small;display:inline">
</div>--pid-file=/tmp/test.pid</b> --bind-interfaces --listen-address=169.254.1.1<br></font></div><div><font face="courier new, monospace"><div>$ sudo netstat -anlp | grep -w LISTEN</div><div><b><div style="font-size:small;display:inline">
</div>tcp 0 0 <a href="http://169.254.1.1:53" target="_blank">169.254.1.1:53</a> 0.0.0.0:* LISTEN 3362/dnsmasq </b></div><div>tcp 0 0 <a href="http://127.0.1.1:53" target="_blank">127.0.1.1:53</a> 0.0.0.0:* LISTEN 1272/dnsmasq </div>
<div>tcp 0 0 <a href="http://10.0.3.1:53" target="_blank">10.0.3.1:53</a> 0.0.0.0:* LISTEN 1140/dnsmasq </div><div>tcp 0 0 <a href="http://0.0.0.0:22" target="_blank">0.0.0.0:22</a> 0.0.0.0:* LISTEN 1033/sshd </div>
<div>tcp 0 0 <a href="http://127.0.0.1:631" target="_blank">127.0.0.1:631</a> 0.0.0.0:* LISTEN 2190/cupsd </div><div>tcp 0 0 <a href="http://0.0.0.0:17500" target="_blank">0.0.0.0:17500</a> 0.0.0.0:* LISTEN 2484/dropbox </div>
<div>tcp6 0 0 fe80::1c44:45ff:fec7:53 :::* LISTEN 1140/dnsmasq </div><div>tcp6 0 0 :::22 :::* LISTEN 1033/sshd </div><div>tcp6 0 0 ::1:631 :::* LISTEN 2190/cupsd </div>
<div><div><b><div style="font-size:small;display:inline"></div>$ cat /var/run/dnsmasq.pid </b></div><div><b><div style="font-size:small;display:inline"></div>3362</b></div></div>
<div><div><b><div style="font-size:small;display:inline"></div>$ cat /tmp/test.pid</b></div><div><b><div style="font-size:small;display:inline"></div>cat: <div style="font-size:small;display:inline">
</div>/tmp/test.pid: No such file or directory</b></div></div><div><br></div></font></div><div><div style="font-size:small">I searched the CHANGELOG in the git repository to see if there was a bug related to this in later versions (I know I don't have the latest version) but I did not find anything.</div>
<div style="font-size:small">The strange thing about this is that I have two other instances of dnsmasq running on my machine and they both have their separate pid files:</div><div style="font-size:small">
<br></div><div><div><font face="courier new, monospace">$ ps ax | grep dnsmasq</font></div><div><font face="courier new, monospace"><b>1140</b> ... dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces <b>--pid-file=/run/lxc/dnsmasq.pid</b> --conf-file= --listen-address 10.0.3.1 --dhcp-range 10.0.3.2,10.0.3.254 --dhcp-lease-max=253 --dhcp-no-override --except-interface=lo --interface=lxcbr0 --dhcp-leasefile=/var/lib/misc/dnsmasq.lxcbr0.leases --dhcp-authoritative</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><b>1272</b> ... /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces <b>--pid-file=/run/sendsigs.omit.d/network-manager.dnsmasq.pid</b> --listen-address=127.0.1.1 --conf-file=/var/run/NetworkManager/dnsmasq.conf --cache-size=0 --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">3362 ... dnsmasq --no-dhcp-interface --pid-file=/tmp/test.pid --bind-interfaces --listen-address=169.254.1.1</font></div>
<div><font face="courier new, monospace"><div>...</div><div><br></div><div>$ cat /run/lxc/dnsmasq.pid</div><div>
<b>1140</b></div><div>$ cat /run/sendsigs.omit.d/network-manager.dnsmasq.pid</div><div><b>1272</b></div><div><br></div></font></div><div style="font-size:small"><br></div></div>
</div><div><div style="font-size:small;display:inline">Thanks,</div><br></div><div dir="ltr"><div style="font-family:arial;font-size:small">Mohsen Zohrevandi</div></div>
</div>
</div><br></div>