RyanEwen / lan-cache-docker

A super simple docker container to run a LAN cache for steam, origin, etc
78 stars 14 forks source link

dnsmasq unable to get IP, forwards to-be-cached records to nothing (nxdomain). Issue with start-dnsmasq.sh #9

Closed Dizzy611 closed 6 years ago

Dizzy611 commented 6 years ago

At first I had the problem of, when I went to set things up I noticed it seemed to be working but when testing, all queries for things like steamcontent.com etc would show up nonexistent (nxdomain). When I poked about the docker container to see what was going on (I added bash to dnsmasq container and prodded its files to take a look), I noticed that the bit of each entry that's supposed to contain my IP was simply blank.

Looking at start-dnsmasq.sh immediately showed me why:

get_ip() {
  interface=$(ip route | grep default | awk '{print $(NF)}')
  ip addr show dev $interface | grep 'inet ' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | head -n 1
}

If I run ip route | grep default on my system, I get the following output:

default via 192.168.1.1 dev bond0 src 192.168.1.201 metric 2

If I then expand that to ip route | grep default | awk '{print $(NF)}', the result is as follows:

2

which isn't exactly a correct parameter to ip addr show dev (I assume you meant to pull 'bond0')

I think your shell magic may be slightly out of date or something? I admit, I'm not familiar with how AWK works, but it's clearly pulling the wrong part of the output.

For the time being, can I simply edit start-dnsmasq.sh to put HOST_IP=192.168.1.201 and restart docker, or does something else need done?

RyanEwen commented 6 years ago

I've had issues with this myself. The IP detection code is from the project that I forked from so I am not sure exactly how it all works. It does seem to work on Ubuntu but I would like to replace this code with something simpler and more standardized. There must be a better way to do it.

RyanEwen commented 6 years ago

But to answer your other question, yes you can just do what you suggested and it should work fine.