From the course: LPIC-1 Exam 102 (Version 5.0) Cert Prep

Gather network information - Linux Tutorial

From the course: LPIC-1 Exam 102 (Version 5.0) Cert Prep

Start my 1-month free trial

Gather network information

- [Instructor] Traditionally, Linux used the net tools commands including ifconfig, netstat, arp route and iptunnel. These commands have mostly been superceeded by the IP route T- suite of tools including the IP and SS commands as well as others. I find the syntax of the legacy tools easier to remember, but in time they may no longer be available so it's important to migrate to IP route two. We will install the net tools package in this course so we have access to the legacy commands as well as the replacements which are installed by default. You can do this on any of your three virtual machines or all of them. I'm going to use ARP Host one. To do so, log into our ARP Host one and in a terminal type in sudo space yum space install space dash Y space net dash tools and hit enter. Type in your password if prompted when it's done installing, make sure IP route two is installed as well. In enterprise Linux seven IP route two is called IP route. Bring your line back and change the net tools to IP route and hit enter. To get IP address and network mask information using legacy tools, we'll type in clear and then type in ifconfig. From this output we can see the IP version four and IP version six addresses for all network devices. These lines of prefix was the words I net and I net six. To show information for a specific network interface, we can provide it as an argument, type in clear and then type in ifconfig space ETH two ETH two being the name of my network card. If your network card is named something different enter that. We can also see the network mask prefixed by the word net mask. It's interesting to note that you can give ifconfig the network mask insider form, but it prints it back in dot notation. To get IP and network mask information using the newer IP tool type in clear and then type in, IP space ADDR and hit enter. This shows a lot of useful information in a very cryptic form. IP shows the IP address for each network interface as well as the net mask insider form. If you wanted to show network information for only one device, the syntax is slightly more complex than ifconfig. Type in clear and then type in IP space, ADDR space show space, show, space ETH2 and hit enter. This will narrow the output to only the ETH two I nterface. Perhaps the output of ifconfig is more readable than that of IP, but that same output is harder to parse and shell scripts. Using the newer IP command, we can provide the route sub command and get the default gateway. Contrary to what I said earlier about the IB command being harder to read, I think the output of IP route is more readable than the legacy route command. Let's try it. Type in clear and type in IP space route and hit enter. The topline store default gateways by numeric addresses in which network interfaces they use. Now let's look at host names. There are three types of host names, static, transient, and pretty. The static host name is the one stored in etc host name, and can be read by a text viewer. The transient host name is a dynamic host name used by the Colonel. By default, when the system starts, it's set to the static host name, but it can change any time by user or a service such as DHCP or MDNS. The Pretty host name is a free form UTF8 string of text that is presented to the user. The host name can be up to 64 characters in length, has to be composed of seven bit ASCII, lowercase characters and cannot have spaces or dots. Red Hat recommends both the static and transient host names match the Fully Qualified Domain Name or FQDN used by DNS. Red Hat also recommends that the host name conforms to the format of DNS name labels, even though it's not necessary from a machine perspective. The host name, CTL command enforces that host aims only consist of lowercase a through z, uppercase A through Z. The numbers zero through nine, hyphens, underscores and dots which are used to delimit sections. They cannot, however, begin or end in and die and cannot have two dots immediately next to each other. Here are some examples of valid DNS names. It's worth noting that older systems may not play nice with the underscore character, so may be a good practice to avoid it. To show just a host name, we can use a legacy tool named host name. Type in clear, and then type in host name and hit enter. To get more information, we would want to use the host name, CTL command that comes with system D.

Contents