Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Startup script doesn't grab IP addresses correctly #273

Closed
2 of 6 tasks
mmcc-xx opened this issue May 20, 2018 · 3 comments
Closed
2 of 6 tasks

Startup script doesn't grab IP addresses correctly #273

mmcc-xx opened this issue May 20, 2018 · 3 comments
Labels

Comments

@mmcc-xx
Copy link

mmcc-xx commented May 20, 2018

This is a...

  • Request for a new or modified feature
  • [X ] Issue trying to run the docker image
  • Issue trying to build / test / develop the docker image

Description

The startup script found here: https://github.com/diginc/docker-pi-hole/blob/master/docker_run.sh
doesn't seem to be able to grab IP addresses correctly

Expected Behavior

Script determines correct current IPv4 and IPv6 addresses

Actual Behavior

When I execute the following command
echo "${IP:-$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')}"
the returned value is "1000"

When I execute the following command from the script
echo "${IPv6:-$(ip -6 route get 2001:4860:4860::8888 | awk '{ print $10; exit }')}"
the returned value is "src"

Possible Fix

I'm using Ubuntu Bionic - perhaps the return format of the route command changed

Steps to Reproduce and debugging done

  1. echo "${IP:-$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')}"
  2. echo "${IPv6:-$(ip -6 route get 2001:4860:4860::8888 | awk '{ print $10; exit }')}"

Debug steps I have tried

  • I have tried destroying my container instance, pulling the newest image version, and re-creating a new container
  • I have tried running the nearly stock docker run example in the readme (removing any customizations I added)
  • I have tried running without my volume data mounts to eliminate volumes as the cause
  • I have searched this repository for existing issues and pull requests that look similar

Context and extra information

Your Environment

  • Docker Host Operating System and OS Version: Ubuntu Bionic
  • Docker Version: 18.05.0-ce
  • Hardware architecture: amd64
@eku
Copy link

eku commented May 22, 2018

Well, output of ip route depends on system and version.
Try

ip route get 8.8.8.8 |sed '/src/!d;s/^.*src \([^ ]*\).*$/\1/'
ip route get 8.8.8.8 |grep -oP 'src \K\S+'

@diginc
Copy link
Collaborator

diginc commented May 24, 2018

When the auto lookup fails please just delete the whole first 4 IP lines and type in your IP to the variables like so:

IP="MyIP"
IPv6="MyIPv6"

The Lookup of IPs is a convenience thing for the majority of users. Like eku said it varies by platform. To make it 100% we'd need to know all the various platforms/network variants' outputs for the route get command.

@mikma
Copy link

mikma commented Oct 7, 2018

Auto detection of the IPv4 address in the script on docker hub didn't work for me, since uid is the field of the ip route result. I solved it by using the same awk program as for IPv6:

$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++) if ($i=="src") print $(i+1)}')

https://hub.docker.com/r/pihole/pihole/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants