From the course: Linux: Network Configuration
Configure a static IP using ifconfig - Linux Tutorial
From the course: Linux: Network Configuration
Configure a static IP using ifconfig
- [Instructor] Net tools is a set of software that was widely used to configure network interfaces on Linux systems. To explore the set of tools, I'll use a CentOS six virtual machine. Now, before you check your calendars, I'm recording this in 2021 and CentOS six is not a maintained release anymore, but as I mentioned earlier, most new distros use more modern tools, and so to get a distro that includes old tools, we need to hop in the time machine and go back a few years. CentOS six when it's first installed, doesn't have an active network connection. So it gives us a great opportunity to explore how to configure a network connection, Using the net tools collection of software. To use the net tool suite of software to configure the network on the system, we'll primarily use the ifconfig command. I-F is short for interface in many places on Linux systems, And when you see I-F in the name of something, it usually means that it has to do with network interfaces. An example of this, is the program iftop, which shows statistics about network traffic through particular interfaces. If I just write, ifconfig by itself here, I see one result on my screen and interface called L-O, which is the local loop back interface, but I don't see any other interfaces. Most notably there's no ethernet interface shown here. That's because ifconfig by itself only shows active interfaces ones that have been set as being available for the system to use, to see all the interfaces, including inactive ones, I can write, ifconfig dash A. There's my ethernet adapter, and it has the interface name E-T-H zero on this system. There's also a little bit of information about the interface and we'll look at that more in just a bit. I can bring this interface up or market as active with the command ifconfig E-T-H zero up, and then when I run, ifconfig that interfaces in my list, but that doesn't mean I can access the network. It just means the system considers this network interface available for use, even though it has no network address. So let's give it an address. To do that, I'll write, ifconfig and the name of the interface and the address that I want to assign to the interface in this case, 10.0.1.120/24. When I run this command ifconfig will assign the address to the interface and set the interface as up. If it isn't already. If I don't want to use CIDR notation, that's the slash 24 on the end of the address, I can also provide a net mask using, ifconfig, the interface name net mask, and the net mask, which in this case would be, 255.255.255.0. But I won't do that. So I'll press control+C. Now my interface has an address and because that address is on my local network, this interface can communicate with systems on the local network. I can check this using the ping command to ping another system on the network, like the gateway. That works. But if the system needs to communicate outside the network, it doesn't know how to do that yet. We can see this by using ping to ping something that's outside the network. In this case one of Cloudflare's DNS servers. I'll write, ping 1.1.1.1.1 and I get the message that the network is unreachable. To allow communication outside the local network, we need to tell the system where to send data that's intended for other networks, that's a router or gateway. And for the system, I'll define the default gateway using this interface. To do that. I'll write, Route, add default G-W for gateway and the address of the gateway. In my case, 10.0.1.1 The default gateway is where the system will send all traffic, not meant for the local network, unless we create other more specific routes, but we'll keep things simple for now. Now I can send traffic outside the network. Let's try that ping of 1.1.1.1 again. And this time I can see that it's working. I can see the traffic is getting from my system to a host on the internet. It's important to note though, that while this interface is up and running for communication with both the local and wide-area IP network, we still need to take one more step to use it in a way that we might be accustomed to, by using a DNS server to resolve human readable host names to IP addresses. We'll explore that in a bit.
Contents
-
-
-
-
Configure a static IP using ifconfig4m 4s
-
(Locked)
Explore interface information with ifconfig4m 27s
-
(Locked)
Configure a static IP using the ip command6m 1s
-
(Locked)
Interface information with ip4m 57s
-
(Locked)
Provide DNS settings3m 24s
-
(Locked)
Configure an interface using DHCP5m 26s
-
(Locked)
Connect to Wi-Fi with iwconfig and wpa_supplicant7m 25s
-
-
-
-
-
-
-