5

I have a fog server set up in work, every now and then our useless internet fails and I have to reset the dnsmasq to get it working again, (don't have a dhcp server set up and can't modify the hubs settings so won't be doing this). Whenever I try sudo dnsmasq restart, I get the message:

junk found in command line.

First of all, can some please explain to me in simple terms what this actually means? As I am no Linux expert and nobody seems to have a simple explanation as to what this is...

Secondly, I have always used the command posted on another the fog forum to correct this error.

sudo /etc/init.d/dnsmasq restart

This always worked perfectly however now when I try to run this command I get the message:

command not found`.

bad_coder
  • 11,289
  • 20
  • 44
  • 72

3 Answers3

14

Edit your /etc/init.d/dnsmasq

My linux distribution is Debian 9 (stretch)

Change this line :

ROOT_DS="/usr/share/dns/root.ds"

if [ -f $ROOT_DS ]; then
   DNSMASQ_OPTS="$DNSMASQ_OPTS `sed -e s/". IN DS "/--trust-anchor=.,/ -e s/" "/,/g $ROOT_DS | tr '\n' ' '`" 
fi

To :

ROOT_DS="/usr/share/dns/root.ds"

if [ -f $ROOT_DS ]; then
   DNSMASQ_OPTS="$DNSMASQ_OPTS `sed -e s/".*IN[[:space:]]DS[[:space:]]"/--trust-anchor=.,/ -e s/"[[:space:]]"/,/g $ROOT_DS | tr '\n' ' '`" 
fi

This problem occurs due to updating the dns-root-data package, more precisely in the file /usr/share/dns/root.ds.

The structure of this file was changed, the fields were separated only by spaces, now they were changed by tabs (\t)

  • 3
    Thanks! This really saved me a lot of time this morning on my Debian 9 machine. – mim.ms Jun 06 '17 at 13:26
  • I just saw this answer, but I had the same issue. I purged then reinstalled dnsmasq and that fixed the issue for me. – DAB Jul 29 '17 at 13:29
  • 1
    Using awk seems to be more clear and is independent of whitespace type: DNSMASQ_OPTS="$DNSMASQ_OPTS `mawk -- '{ printf " --trust-anchor=.,%d,%d,%d,%s", $5, $6, $7, $8 }' $ROOT_DS`" – Gaia Jun 25 '18 at 03:20
  • Thanks Gaia for the "whitespace free" solution! ;) – Steve Lloyd Aug 11 '18 at 18:12
1

sudo service dnsmasq start

That worked for me

user168345
  • 167
  • 2
  • 8
0

Try sudo restart dnsmasq. The /etc/init.d/ directory is the location of System V init scripts. If dnsmasq is not there, it's probably been converted to use upstart and its configuration is in /etc/init/

TeTeT
  • 2,044
  • 20
  • 30
  • Thanks for the quick reply, and the explanation, if I try the command you suggested I get the message unknown job: dnsmasq, also I checked the etc/init.d/ directory and dnsmasq is there if that helps – Stephen Fig Roll Smith Jun 05 '13 at 12:45
  • So dnsmasq is still a System V script. Maybe running the script line by line will show what's wrong: sudo sh -x /etc/init.d/dnsmasq restart – TeTeT Jun 05 '13 at 14:37
  • I figured it out, to run the sudo etc/init.d/dnsmasq restart command I had to navigate from my user back to the top of the file system, simple solution but something I just didn't think of, thanks for the step by step command though, very interesting – Stephen Fig Roll Smith Jun 05 '13 at 15:43
  • add a / before etc and you can use the command from anywhere. Alternatively use 'sudo service dnsmasq restart'. Glad you got it working. – TeTeT Jun 05 '13 at 17:00