Linux Basic Network Settings

Source: Internet
Author: User
Tags root access traceroute command

First, view and test the network

Viewing and testing your network configuration is the first step in managing Linux network services, and this section will learn about network viewing and test commands in Linux systems. Most of the commands described here can be done with normal user privileges, but ordinary users need to specify the absolute path to the command file when executing commands in the "www.qixoo.qixoo.com/Sbin/" directory.

(i) View network configuration

    1. Use the ifconfig command-View network interface address

      A host's network interface card (NIC) is often referred to as a "network interface." On Linux systems, you can use the Ifconfig command to view the address configuration information for a network interface.

    • View Active Network Interface Devices

      When the Ifconfig command does not have any parameters and options, the network interface information that is enabled (active) in the current host is displayed. For example, you can see both the Eth0 and LO network interface information after executing the ifconfig command directly. (the following are performed on Red Hat Enterprise Linux 7, slightly different from other versions)

In the above output, the eno16777736 corresponds to the first physical network card, and lo corresponds to the virtual loopback interface. Virbro is a virtual network card.

    • eno16777736: The name of the first Ethernet block.

    • Lo: "Loopback" network interface, "Lo" is the abbreviation of "loopback", it does not represent a true network interface, but a virtual network interface, its IP address is "127.0.0.1" by default. Loopback addresses are typically used only for native network testing.

    • Virbr0: "Virbr0" is a virtual network card.

    • To view the specified network interface information

When you only need to view information about one of these network interface information, you can use the name of the network interface as a parameter to the Ifconfig command (regardless of whether the NIC is active). For example, you can only view configuration information for the NIC eno16777736 after you execute the ifconfig eno16777736 command.

From the results shown in the above command, you can learn some basic information about the eno16777736 NIC, as described below.

    • Ether: Represents the Physical address (MAC address) of the network interface, such as "00:0c:29:11:47:04". The physical address of the network interface is usually not changed and is the world's only hardware address determined by the NIC at production time.

    • Inet: Represents the IP address of the network interface, such as "192.168.239.128".

    • Broadcas: Represents the broadcast address where the network interface resides, such as "192.168.239.255".

    • Netmask: Represents the subnet mask for the network interface, such as "255.255.255.0".

In addition, the "TX", "RX" and other information to understand the number of packets sent and received through the network interface, traffic and more properties.

2. Use the hostname command-view host name

In a Linux system, a considerable portion of the network services are identified by the host name of the machine, if the hostname is improperly configured, may cause program function failure. Use the hostname command to view the host name of the current host without adding any options or parameters.

3. Use the route command-view the Routing Entry table

The routing table in Linux system determines the whereabouts of sending data from this machine to other hosts and other networks, which is the key information to eliminate the network failure. The direct execute route command can view the routing table information in the current host, in the output result, the destination column corresponds to the address of the target network segment, the gateway column corresponds to the address of the next hop router, and the Iface column corresponds to the network interface that sends the data.

When the target segment is "Default", it indicates that this line is the default gateway record; When the next hop is *, the target network segment is directly connected to this machine.

If used with the "-N" option, the address in the routing record can be displayed as a number, which bypasses the process of parsing the hostname, which can speed up execution in the case of more entries in the routing table. For example, the * address in the output information after executing the "route-n" command will be displayed as "0.0.0.0", and "default" will also be displayed as "0.0.0.0" in the Defaults gateway record.

4. Use the netstat command-view network connectivity

By using the netstat command, you can view the current system's network connection status, routing table, interface statistics and other information, is an effective tool to understand network status and troubleshoot network services. Here are a few options commonly used by the netstat command.

    • -A: Displays network connection information for all active in the current host (including listening, non-listening service ports)

    • -N: Displays information about the host address, port, and so on in digital form.

    • -r: Displays routing table information.

    • -L: Displays the network connection and port information in the listening (listening) state.

    • -T: View information about the TCP protocol.

    • -U: Displays information about the UDP protocol.

    • -P: Displays the process number and process name information associated with the network connection (this option requires root access).

      Typically, the "-ANPT" combination option is used to display all TCP connection information in the current system numerically. The corresponding process information is also displayed. Using the grep command with the command management pipeline, you can also filter the specific records that you need in the results. For example, perform the following command to see if there is a service program that listens to the TCP 22 port (that is, SSH) in this computer, including the PID number and the process name in the output information.

(ii) Testing network connectivity

    1. Using the ping command-test the connectivity of the network

Using the ping command, you can continuously send test packets to the destination host and display the feedback results, knowing that the CTRL + C key combination aborts the test and displays the final statistical results. For example, the following operation tests connectivity tests from native to another host 192.168.195.112, and receives the returned packets when the connection is normal.

When you perform a ping test command, you cannot obtain a feedback packet that is sent back from the target host, which indicates a network connectivity failure between the native and the destination host. For example, if you see the "Destination Host unreachable" Feedback, the destination host is unreachable, the target address may not exist, or the host is closed, and if you see feedback from "Network is unreachable", Indicates that no routing records are available (such as the default gateway) and that the destination host's network cannot be reached.

When there are factors in the network that affect the stability of the communication process, such as a network card failure, a virus or a network attack, and so on, you may frequently see the feedback result of Request timeout when you test with the ping command, indicating a time-out between the connection to the target host and the slow or missing packet response. In addition, when there are strict firewall restrictions in the target host, you may receive feedback from the Request timeout.

2. Using the traceroute command-route path for tracking packets

Use the traceroute command to test which network nodes are passed from the current host to the destination host, and to display the connection status (response time) of each intermediate node. For nodes that are not responding, the connection status is displayed as "*". For example, the following results can be seen from the local to the target host 192.168.195. Between, the middle of the need to cross a router

The traceroute command is more accurate than the ping command to locate the point of failure (breakpoint) of a network connection and is therefore slower to execute than the ping command. During network testing and troubleshooting, the network connection to the destination host is usually tested with the ping command, and if a network connection is found to be faulty, use the traceroute command to track where the intermediate point is failing.

Linux Basic Network Settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.