Note: Because this is an ongoing series, viewers will not receive a certificate of completion.
Skill Level Intermediate
- [Instructor] When you connect a computer to a network, either through Wifi or Ethernet, the computer is assigned an address on the local network. This address allows it to communicate with other devices on the same network, either to exchange information with them or to send information which they send onto other networks through the internet. So knowing the local IP address of your system is important for troubleshooting and it's useful to know if you need to connect to a service that the system is running. On recent distros, the command we use for this is IP. IP gives us the opportunity to see a lot of information about many kinds of objects and the kind we focus on here is address information. Typing IP address or IPA shows address information about network adaptors on the system. On some systems, there will be al to of adaptors, real and virtual. So let's take a look at the output here and figure out which one has the information we need. The first entry here is the loopback interface, LO and that's not something that we can use from another computer. The next one here is enp0s3 and in my case, that's the system's first ethernet adaptor. The name of the adaptor will vary in some cases based on the type of adaptor and the type of the system. Depending on how your system is set-up, you may see eth0, enp0s3, en0 or something with WL at the beginning for a wireless adaptor. We'll go over this more in the next episode Unpredictable Network Interface Names. If you aren't familiar with the name of your network interface and you're looking to find out your network address information, it can be a little bit of a chicken and egg problem to determine how to find either piece of information. In this episode, we'll focus on the network information. The entry for each network adaptor contains a lot of information. So let's take a look at what's shown. I'll clear the screen and focus in on only one of my adaptors. I'll type IP address show dev enp0s3. But you can follow along with just IP address. The first line here shows some characteristics of the interface including whether the network is up and whether the underlying interface is up. That's this UP right here and the underlying interface is LOWER UP. This is summarized over here in state UP. Let's skip the rest of the information for now but it can be useful info for troubleshooting. Link here shows the ethernet address or Mac address of the interface. That can be useful for setting firewall rules and troubleshooting as well. Inet here shows the IPV4 address of this adaptor. If you're using IPV4, that's the address you'd use to connect to the system. I can see that my network is using the 10.0.2.0 range. Part of the reserve ranges for private networks. A home network will frequently use a range in the 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16 block of IP addresses depending on how it's configured. And other networks may use a variation of this or use a range that includes public addresses. These address ranges are reserved for private network use so they don't conflict with IP addresses on the internet. So when you seen an address that starts with 10, with 172.16 or with 192.168, you can be pretty sure that's a private local address, not one that's reachable on the internet. Within these ranges, the network's DHCP server will hand out addresses to clients that join the network. All systems will have statically configured addresses. Usually your IP address for a system on a home or organization network will be part of one of these ranges but if you see an address that starts with 169.254, that's a signal to you that your system isn't getting an IP address from the network. When a system doesn't get an address, it assigns itself an address in the 169.254 range which can be used for peer-to-peer connections. When troubleshooting, it's assigned DHCP isnt' working or that something else is going on with the system's network connection though. And when you see this kind of address, it usually means your system's internet connection won't work until its address is configured. The inet line of the output of the IP address command also shows the sider notation for the network's net mask in this case 24 bits or 255.255.255.0 and here we see the broadcast address for the network. We're not as concerned about that here though. After this, we see the valid lifetime and preferred lifetime of the lease of the address. On a DHCP network, there will a time limit on the address the computer is given. After which it needs to ask for an address again. The address will usually stay the same though it may not especially if the system is offline for the period of this time limit. That's something to be aware of if you're using a service hosted on a system. If it's unexpectedly unavailable, check to see if the IP address has changed. After inet, we see inet6 which indicates the IPV6 address for the adaptor. While IPV6 is used increasingly in internet and Enterprise applications, it's less common to use directly at home. Many home systems will have an IPV6 address but because the address is a lot harder to read, type and memorize, most people still use IPV4 addresses around the house. If you don't see an inet line at all, it can indicate that the interface is disabled or disconnected. That's a quick look at how to find your IP address on the Linux system and if you'd like to learn more about networking on Linux or networking in general, be sure to check out our courses that cover these things in more depth.