Running 20.04 I am trying to figure out what my LAN IP is on my laptop. If I run ifconfig I get (trimmed down):

$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet  netmask  broadcast

enp0s31f6: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet  netmask

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet  netmask  broadcast

virbr1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet  netmask  broadcast

wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet  netmask  broadcast

Which one of the above is my IP - e.g. the one I would use when SSH'ing to this latop from another PC on my LAN?

Also in the "old" days I always looked for eth0 (also on ubuntu) but seems that is no longer used:


  • What's your LAN network address? Apr 18, 2022 at 11:18
  • Does this answer your question? Creating eth0 with consistent network device naming
    – cas
    Apr 18, 2022 at 12:45
  • enp0s31f6 is the device name for your LAN. try ip addr show dev enp0s31f6 to see the IP addresses associated with it. The link above provides both another link to the wikipedia article about consistent device naming, but also some details on how to rename it back to eth0 if that's what you prefer.
    – cas
    Apr 18, 2022 at 12:47
  • Are you perchance using your laptop from home? If so, then you will need to know your "external IP", and additionally you will need to configure the firewall in your router at home to allow traffic. For instance whatismyipaddress.com will tell you what your external IP is. Apr 18, 2022 at 22:15
  • I'm going to be a meme SE user and say ifconfig is deprecated
    – jaskij
    Apr 18, 2022 at 22:42

2 Answers 2


enp0s31f6 shows the flag UP but not RUNNING: this typically means it does not have a valid link at the moment.

On the other hand, wlp0s20f3 has both UP and RUNNING flags present. The name prefix wl indicates this is a wireless interface, which makes sense as you said this is a laptop. An en prefix would indicate a wired interface.

So, the IP address of the wlp0s20f3 interface (i.e. would be the one to use for inbound SSH connections from other physical hosts.

The interfaces docker0, virbr0 and virbr1 are for facilitating networking between Docker containers and/or virtual machines running on this system: depending on other settings, they might allow containers/VMs communicate only with the host OS, or they might allow NAT-based access to the world outside this physical host. To understand their exact purpose, it might be necessary to study the iptables NAT and forward filtering rules (i.e. sudo iptables -Lvn -t NAT and sudo iptables -Lvn).

If your laptop had the appropriate data records embedded in its firmware, its integrated wired network interface should get identified as eno1 and the wireless one as wlo1. But apparently your laptop's firmware does not include those records. If you wish, you could change the interface names by creating two simple /etc/systemd/network/*.link files.

First, you would need to use e.g. sudo udevadm info -q all -p /sys/class/net/enp0s31f6 | grep -e ID_NET_NAME -e ID_PATH to identify the hardware path and the autodetected name candidates for your network interface. The output might look something like this:

# udevadm info -q all -p /sys/class/net/enp0s31f6 | grep -e ID_NET_NAME -e ID_PATH
E: ID_NET_NAME_MAC=enx0123456789ab
E: ID_NET_NAME_PATH=enp0s31f6
E: ID_PATH=pci-0000:00:1f.6
E: ID_PATH_TAG=pci-0000_00_1f_6
E: ID_NET_NAME=enp0s31f6

If the ID_NET_NAME_ONBOARD line does not appear, that confirms your system firmware does not properly identify the network interface as an onboard one. You might wish to fix this by renaming the interfaces to use the names they would have ideally been assigned to anyway. To rename this interface, you would note the ID_PATH= line, and use it to write a configuration file as e.g /etc/systemd/network/70-eno1.link with the following contents:


Name=eno1    #or whatever you want

and likewise for the wireless interface.

Instead of setting an explicit Name=, you can also use a NamePolicy= setting to select any of the pre-generated ID_NET_NAME_* candidates, or to set an order of preference for selecting a pre-generated name. See man 5 systemd.link for more details.

After creating these files, you should update your initramfs (sudo update-inintramfs -u) and reboot. After rebooting, you should find your interfaces with the names of your choice.

Note that the enp0s31f6 is a name that is based on the PCI device path: it indicates it refers to PCI device 00:1f.6 as 31 = 0x1f. Likewise, wlp0s20f3 would be PCI device 00:14.3 (20 = 0x14).

  • 1
    I think udev scripts rename wired ethernet devices to en... (based on their PCIe device number, and wireless LAN network devices to wl.... If that's accurate, maybe worth mentioning this convention that modern GNU/Linux distros use; the kernel itself still does initially auto-number devices starting with eth0. Apr 19, 2022 at 0:25
  • The new naming scheme may have been originally prototyped as udev scripts, but by now it seems to be implemented internally by modern versions of udevd. On distributions using a reasonably up-to-date version of systemd (and systemd-integrated udevd), the method I described in my answer above is probably the simplest way to assign custom names to network interfaces.
    – telcoM
    Apr 19, 2022 at 4:26
  • Right, good answer, was mostly just commenting to point out what the naming scheme is about (in case some readers don't find the names self-explanatory), and to mention that the names do come from user-space, not the kernel itself, in case people are curious about who decided that eth0, 1, ... and wlan0, etc. were not idea for systems with complicated configs, especially if boot-time detection order could change based on parallel stuff racing with each other on modern init setups. (I now see some of that info was already there in your answer.) Apr 19, 2022 at 4:35
  • @PeterCordes I edited my answer a bit based on your comments. However, since the question includes a link to a discussion that includes a description of the naming scheme and how it's implemented, I chose not to repeat that, as I was already going beyond just answering the actual Question.
    – telcoM
    Apr 19, 2022 at 8:09

Among other things, you can use the hostname command for this. There are two options to help you here:

hostname -i or hostname --ip-address : This will work only if the hostname can be resolved (which might be a good thing if you are using a hostname to ssh into this host). Note that the next option below is preferred.

hostname -I or hostname --all-ip-addresses : This will print all the IP addresses of the host. It does NOT depend on hostname resolution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .