Find my computer local IP in ifconfig

S

Steph

Guest
Hello everybody! :)

I'am running on Ubuntu 12.04.

I have a certificate on my computer that I have installed with OpenVPN, to establish an Internet Connection.
My NETGEAR routeur have to be configured for allow it and I have found all the process BUT for apply it, I need to know my Internal IP Address, that I can't find.

The command ifconfig gives:

eth0 Link encap: Ethernet HWaddr f0:de:f1:ba:a7:da
UP BROADCAST MULTICAST MTU :1500 Metric:1
then all next values: 0 and lg file transmission:1000
, then 0 Octets received or send.

Is it correct to look after that in eth0 ? and not in lo or wlan0?

Have I to modify a file to make that address appears? I have read about /etc/networks/ and
/etc/NetworkManager/NetworkManager.conf ,but it seems for people who are installing a server, and that is not the point for me...

Thanks to any good samaritan for share advice or suggest another way to solve my problem! :)
In fact, I am learning all the Network aspects from the first step, and the way is quite long...

Best regards!

Stephane
 


What happens if you use the command: /sbin/ifconfig

What appears against the line(s): inet addr
 
Hello arochester!

First of all, thanks for your reply!

When I use the command /sbin/ifconfig, absolutely nothing change, including the line adr, that appear just for l0 and wlan0.

The line inet adr for l0 is: 127.0.0.1 and for wlan0: 192.168.0.11

Another suggestion?

Thanks a lot again!
 
Hello arochester!

First of all, thanks for your reply!

When I use the command /sbin/ifconfig, absolutely nothing change, including the line adr, that appear just for l0 and wlan0.

The line inet adr for l0 is: 127.0.0.1 and for wlan0: 192.168.0.11

Another suggestion?

Thanks a lot again!

From the information you provided wlano: 192.168.0.11 is your internal IP address leased from you wireless router. These are leases and sometimes can change when other devices connect to the router.

If you're running an ethernet "physical" line your ip would be found in you etho section proceeding inet.
 
Hello ZZS!

You are definitely right! ( I have tried with a physical connection and looked at the difference in ifconfig with it)
Cause of you, I have made a step forward in Network knowledge!

Thanks a lot and have a nice day!
 
I also sometimes need to find my local IP address on various machines, so I wrote a bash script to find it. Maybe it will be useful to others.

You can save it to a file named localip in a directory on your path.
Code:
#!/bin/sh
error_exit() { echo "ERROR: $*" 1>&2; exit 1; }

SYSTEM="$(uname -s)"
if [ "$OSTYPE" = cygwin ]; then
  ipconfig | sed -n '/Local Area Co/,/Subnet/{s/\r//; s/ *IPv*4* Add.*: //p}'

elif type -p ip >/dev/null 2>&1; then
  # Expect: "default via <ip_address> dev eth0"
  DEVICE="$(ip route show | awk '/default via/{print $NF}')"
  test -z "$DEVICE"  &&  error_exit "There is no default route"
  IP="$(ip address show | awk '/inet [0-9.]+\/.* '$DEVICE/'{print $2}')"
  test -z "$IP"  &&  error_exit "There is no default route"
  echo "${IP%/*}"

elif type netstat >/dev/null 2>&1  &&  test -x /sbin/ifconfig; then
  # Expect: "0.0.0.0 <gateway> 0.0.0.0  <flags>  0 0  0 <device>"
  DEVICE="$(netstat -nr | sed -n '/^0.0/s/.* //p')"
  # Expect: "default  <gateway>  <flags>  <refs> <use> <mtu> <interface>"
  test -z "$DEVICE"  &&  \
  DEVICE="$(netstat -nr | awk '/^default [^:]*$/{print $NF;exit}')"
  test -z "$DEVICE"  &&  error_exit "There is no default route"
  # Expect: "  inet <ip_address> netmask <mask> broadcast <addr>"
  /sbin/ifconfig $DEVICE 2>/dev/null | awk '/inet [1-9]/{print $2}'
 
else
  error_exit "Don't know how to find device for $SYSTEM"
fi
 

Members online


Latest posts

Top