Skip to content

Instantly share code, notes, and snippets.

@JohnnyNiu
Last active June 28, 2016 06:32
Show Gist options
  • Save JohnnyNiu/d22fab91701f4b1485e16643feb2121a to your computer and use it in GitHub Desktop.
Save JohnnyNiu/d22fab91701f4b1485e16643feb2121a to your computer and use it in GitHub Desktop.
Problem that can't find IP of the machine by command in Groupmanagment/MailRouting run script

The script in the run script is using below command to calculate the ip of the localhost:

export HOST_IP=$(ifconfig $(ifconfig | grep ^eth | cut -d' ' -f1 | tail -1) | grep 'inet addr' | cut -d':' -f2 | cut -d' ' -f1)

or

export HOST_IP=$(ifconfig $(ifconfig | grep ^eth | cut -d' ' -f1) | grep 'inet addr' | cut -d':' -f2 | cut -d' ' -f1)

Sometimes, it is working on my machine, sometimes not. when it's not working, it reports error as below:

eth1: Unknown host

or no output.

It turns out there are more than one ethernet interface on my ubuntu: "eth0" and "eth1".

It turns out the second one is only appears after I plugin my iphone, in which "personal hotspot" is turned on.

The solution is either plug out my iphone or run command to remove the ethernet interface:

ifconfig eth1 down

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment