Linux Network ifconfig command and Ping

Source: Internet
Author: User

Ifconfig Command Network configuration

The ifconfig command is used to configure and display network parameters for network interfaces in the Linux kernel. The NIC information configured with the Ifconfig command does not exist after the machine restarts after the network card restarts. In order to keep the above configuration information in the computer forever, it is necessary to modify the network card configuration file.

Grammar
Ifconfig (parametric)
Parameters
add< Address: Set the IP address of the network device IPV6 ;del< address;: Delete the IP address of the network device IPV6; down: Turn off the specified network device;
Instance

Display Network device information (Active State):

[Email protected] ~]# ifconfigeth0      Link encap:ethernet  HWaddr 00:16:3e:00:1e:51 inet            addr:10.160.7.81  bcast:10.160.15.255  mask:255.255.240.0 up          broadcast RUNNING multicast  mtu:1500  metric:1          RX packets:61430830 errors:0 dropped:0 overruns:0 frame:0          TX packets:88534 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 Txqueuelen :          bytes:3607197869 RX (3.3 GiB)  TX bytes:6115042 (5.8 MiB) Lo        Link encap:local Loopback            inet addr:127.0.0.1  mask:255.0.0.0 up          LOOPBACK RUNNING  mtu:16436  metric:1          RX packets:56103 errors:0 dropped:0 overruns:0 frame:0          TX packets:56103 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:5079451 (4.8 MiB)  TX bytes:5079451 (4.8 MiB)

Description

eth0 represents the first network card, which HWaddr represents the physical address of the network card, you can see the current network card physical address (MAC address) is 00:16:3E:00:1E:51 .

inet addr is used to indicate the IP address of the network card, the IP address of this network card is 10.160.7.81 , broadcast address Bcast:10.160.15.255 , mask address Mask:255.255.240.0 .

Lo is the loopback address of the host, which is typically used to test a network program, but does not want the local area network or extranet users to be able to view, can only run on this host and view the network interface used. For example , the HTTPD server is designated to the loopback address, the browser input 127.0.0.1 can see your Web site. But you can only see that the other host or user of the LAN is unknown.

    • First line: Connection type: Ethernet (Ethernet) HWADDR (Hardware MAC address).
    • The second line: The IP address, subnet, and mask of the network card.
    • Third line: Up (for Nic on) RUNNING (network cable on behalf of the NIC is connected) multicast (support multicast) mtu:1500 (Maximum transmission Unit): 1500 bytes.
    • Line fourth to fifth: Receive, send packet statistics.
    • Line seventh: Receive, send data byte count statistics.

Start to close the specified network card:

Ifconfig eth0 upifconfig eth0 down

ifconfig eth0 upTo start the NIC Eth0, ifconfig eth0 down turn off the NIC Eth0. SSH login Linux server operation be careful, shut down can not be turned on, unless you have multiple network cards.

Configure and remove IPV6 addresses for network cards:

Ifconfig eth0 Add 33ffe:3240:800:1005::2/64    #为网卡eth0配置IPv6地址ifconfig eth0 del 33ffe:3240:800:1005::2/64    # Remove IPV6 address for Nic Eth0

To modify the MAC address with Ifconfig:

ifconfig eth0 hw ether 00:aa:bb:cc:dd:ee

Configure IP Address:

[Email protected] ~]# ifconfig eth0 192.168.2.10[[email protected] ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0[[ Email protected] ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255

To enable and disable the ARP protocol:

Ifconfig eth0 ARP    #开启网卡eth0 ARP protocol ifconfig eth0-arp   #关闭网卡eth0 ARP protocol

Set the maximum transmission unit:

Ifconfig eth0 MTU    #设置能通过的最大数据包大小为 bytes

1 Network command: Ping

1.1 Command Description

Instruction Name: Ping

Instruction Path:/bin/ping

Execute Permissions: All Users

Syntax: ping [options] IP address

-C specify number of times to send

Function Description: Test network connectivity

Example: #ping 192.168.12.2

1.2 Application Examples

The most remote probe command to use now is to send an ICMP request packet to the remote host to see if the caller is online (or if there is a response). The use of the Windows Ping command is basically similar, but the result is different: the ping command under Windows will automatically end by sending only four ICMP requests by default, while the ping command under Linux sends the request by default until you press CTRL + C forced end. For example:

[HTML]View PlainCopy
    1. [[Email protected]~]# Ping 192.168.12.2

However, you can also specify the number of pings in a Linux system to avoid an unlimited ping operation. For example:

[HTML] view plain copy

    1. [[Email protected]~]# ping-c 4 192.168.12.2

The above example indicates that the specified 4 ping operation is performed.

The results of operation 1 are as follows:

Figure 1 Ping command execution results

Note: In the ping process to observe the packet loss rate (Packetloss), if the packet loss rate is very high, even if the ping pass, the network is very poor.

Linux Network ifconfig command and Ping

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.