2

Tip #554   Get your machines IP adress

You sometimes need your machines IP adress without relying on external sources; so here is the command to return your IP adress in one neat line.

ifconfig eth0 | grep -o "addr:[0-9.]*" | grep -o "[0-9.]*"


You off course need the necessary rights to us this. If you lack the rights, you might want to prepend it with "sudo" and add the ifconfig to the allowed paswordless commands for the user that needs this..

Ifconfig retrieves the adress; the first grep weeds out the external adress out of the data & the last grep filters out the IP adress.