Seven Practical command line tools for Linux Network Configuration

Source: Internet
Author: User

Although most Linux distributions now have GUI Network Management configurations, it is helpful to be familiar with the command line tool. Let's take a look at the common commands below these popular Linux distributions. By the way, if you want to know the details of the tool and options, you can enter man and enter the Tool Name to access its man page.

Open your terminal now and try it!

Ifconfig for basic interface and IP configuration

Ifconfig provides some basic but important functions. It can turn on and off the network adapter and assign the IP address and netmask information. Some Common commands are as follows:

View the current configuration of the network interface and the interface Name:

Ifconfig

Turn on or off the (down) Adapter

Ifconfig <Network Name> <up | down>

Assign an IP address to the adapter:

Ifconfig <Network Name> <IP address>

Assign a second IP address to the adapter:

Ifconfig <Network Name: number of instances> <IP address>

Example: ifconfig eth0: 0 192.168.1.101

Detailed introduction: ifconfig for Linux Command Network Operations

Ethtool used to manage the Ethernet Card

Ethtool allows you to view and modify various configurations of an Ethernet adapter (excluding Wi-Fi NICS), including Tx/RX, checksumming, and wake-on-LAN Settings. The following are some useful commands:

Display the driver information of a network adapter, which is suitable for querying software compatibility:

Ethtool-I <Interface Name>

Display network data:

Ethtool-S

Set the adapter connection speed (mbps)

Ethtool speed <10 | 100 | 1000>

Detailed introduction: ethtool for Linux/Unix Commands

IwconfigConfigure a wireless network

Iwconfig can be regarded as ifconfig and ethtool of the wireless network adapter. You can check basic Wi-Fi network settings, such as SSID, channel, and encryption. You can also modify some advanced settings, including the receipt sensitivity, RTS/CTS, fragments, and number of retries. The following describes several useful commands:

Display the current wireless settings, including the Interface Name:

Iwconfig

Set Essid (extended service setting reader) or network name:

Iwconfig <Interface Name> Essid <Network Name>

Example: iwconfig <Interface Name> "My
Network"

Example: iwconfig <Interface Name>
Any

Set the wireless channel (1-11) of Radio ):

Iwconfig <Interface Name> <channel>

Enter the WEP encryption key (WPA and wpa1 are not supported yet, And wpa_supplicant is required ):

Iwconfig eth0 key <key in hex format>

Restrict the adapter to connect to the AP only at the specified MAC address:

Iwconfig <Interface Name> aP <MAC address>

Example: iwconfig eth0 AP 00: 60: 1D: 01: 23: 45

Sets the launch intensity of radio, which is only valid when the wireless Nic supports it. The default unit is dBm, which can be set to MW:

Iwconfig <Interface Name> txpower <strength>

Example: iwconfig eth0 txpower 15

Example: iwconfig eth0 txpower 30 MW

Detailed explanation: Linux operating system wireless network commands

Tcpdump used to sniff network packets

This is not a simple tool. This is a sniffer/analyzer. It can capture packets transmitted between your interface and the network. This tool is often called through other GUI programs, but it is also useful in terminal. You can start with the following commands:

-I: Set the interface to be captured, such as eth0 or ATH0.

-N: Stop replacing the IP address with the host name.

-NN: Stop parsing the host name or port name.

-S: the maximum number of bytes per packet. The default value is 68. If it is set to 0, the entire packet is displayed.

V,-VV, and-vvv: displays detailed information output along with packet, such as the full length and options of IP packet, fully decoded SMB packet, and telnet details.

-X: displays packet content in hex format.

-X: Output packet content in ASCII format.

Detailed introduction: super detailed usage of tcpdump

Ping, Your network sonar

The ping tool is similar to that provided by Microsoft in windows, but the option type and name are different. In addition, by default, Ping in Linux will never stop, instead of four in windows.

Start to ping an IP address or host name/Domain Name:

Ping <IP address>

To stop the Ping, use Ctrl + C.

Some useful options include:

-C: indicates the number of packages sent.

-I: The length of wait time between packages, in seconds

-S: packet size. The default value is 56.

-W: The Ping duration, in seconds.

Related self-testing: Ping is not that simple [network basics • Preliminary]

Netstat for Network Data Detection

The netstat tool displays detailed information about network connections, interface data, route tables, masquerade connections, and multicast members. Common commands are as follows:

View the list of opened sockets:

Netstat

Show all network interfaces:

Netstat-I

Display the summary of each protocol:

Netstat-S

Details: netstat Parameters

Hostname used to view and modify the Host Name

All administrators know what a host name is. The host name is a more friendly Display Method for network devices than IP addresses. Linux provides a hostname tool that allows you to temporarily modify your host name.

View the current host name:

Hostname

Temporarily change the Host Name (which can be maintained before restart ):

Hostname <New Host Name>

To change the host name permanently, edit the/etc/hostname file or the/etc/sysconfig/network file.

Original article: 7 useful Linux networking commands Author: Eric Geier

Author Profile

Eric Geier is the founder and CEO of nowiressecurity, and author of many popular books on network and security technologies.


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.