Linux

Find The IP Address of Your Computer on the Home or Local Area Network (LAN) -Linux (Debian-Based Systems)


This is a short post on how and where to find the IP address and static/dynamic status for your Linux machine within your Local Area Network (LAN). If you are using a Windows machine, follow this link:

Find The IP Address of Your Computer on the Home or Local Area Network (LAN) -Windows 7

Every now and then, we need to know something trivial, such as the current IP address of the machine at which we sit. Within limits, this is simple enough to do. NOTE: These appear to be mostly universal, but I feel compelled to mention that I am assuming a Debian-based Linux here. I am not widely versed on all the various distributions!).

With a pair of useful Commands at the Bash Terminal, we can find the information we need:

Private (internal to our LAN) IP Address of our current computer, and our router:
$ ifconfig
Static/Dynamic status of IP Addresses within our LAN:
$ cat / etc/network/interfaces

Current LAN IP Address – Linux:

Open the Bash terminal and type ifconfig

Linux-Find-IP-Address-Before-Enter

The hit the Enter Key:

Linux-Find-IP-Address-After-Enter

Note in the above that the section of the terminal output we are interested in is eth0. Within that section, we find the item inetaddr:192.168.0.113. This is the internal IP address assigned to our current machine within the Local Area Network (LAN). This address is private to our LAN, and is not exposed to the internet-at-large. Note this address, as it is how you will address this specific machine within the confines of your Local Area Network.

Static or Dynamic IP Assignment?

Note that this and other IP addresses found on our LAN are not necessarily static (or, permanent). Routers often assign IP Addresses dynamically. While a given dynamic IP address on your home network is unlikely to change very often, it CAN. In order to check out which type of IP Address we are dealing with, we can use the cat command in our Bash terminal to examine the contents of the network interfaces configuration file used by our computer. Under Most Debian-based Linux systems, we can do this as follows:

Use cat to open the network interfaces file:

Linux-Type-Network-Config-Before-Enter

The hit the Enter key:

linux-network-config-after-enter

If what you see is similar to the above, this indicates a dynamic IP assignment (the auto lo is the key phrase here. My Linux box receives a dynamic IP assignment from my home network router, as do most.

If you’re the IP assigned to your machine is static, the output to the terminal window would have looked a little like THIS (I can’t show terminal output here because I do not have a static IP assignment for my Linux Machine):

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
  address 10.1.1.20
  netmask 255.255.255.0
  network 10.1.1.0
  broadcast 10.1.1.255
  gateway 10.1.1.1

CodeProject
Creating A Basic Make File for Compiling C Code
Linux
Setting Up Linux in a Virtual Machine for Windows Users
CodeProject
Install Sublime Text 3 (beta) on Linux Mint or Ubuntu
  • renikat

    renikatrenikat

    Author Reply

    Thanks for your information. Recently i found another site
    http://www.ip-details.com/ through google search for doing iplookup


  • jatten

    jattenjatten

    Author Reply

    Hi!

    Thanks for the info. I am finding my way through Linux now – I really dig it, but there is a lot to learn! Since posting this article, I have learned that ifconfig has in fact been deprecated in favor of the more modern approaches you mention. I will be updating the post later this week.

    Thanks for taking the time to read, and the feedback!


  • Anders

    AndersAnders

    Author Reply

    You should use 'ip' instead of 'ifconfig', as the first is modern and gives you more information. Like 'ip address list', 'ip route list' etc.

    Ethernet devices that are not mentioned in /etc/network/interfaces could be managed by the NetworkManager. If you don't want NetworkManager to handle your network devices, just write a stanza in interfaces.

    # Use dhcp to get this device set up
    allow-hotplug eth1
    iface eth1 inet dhcp

    If you want to configure static IPv6, you just change inet to inet6 (and use static).