Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of the linux command ifconfig

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "detailed explanation of the linux command ifconfig", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "the detailed explanation of the linux command ifconfig"!

Many windows are very familiar with the ipconfig command line tool, which is used to obtain and modify network interface configuration information. Depending on some option attributes used in the ifconfig command, the ifconfig tool can be used not only to simply obtain network interface configuration information, but also to modify these configurations.

1. Command format:

Ifconfig [network equipment] [parameters]

2. Command function:

The ifconfig command is used to view and configure network devices. When the network environment changes, you can configure the network through this command.

3. Command parameters:

4. Use an example:

Example 1: displays network device information (active)

Command:

Ifconfig

Output:

[root@localhost ~] # ifconfig

Eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:20

Inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0

TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7MiB)

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:68 errors:0 dropped:0 overruns:0 frame:0

TX packets:68 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:0

Eth0: the code name of the network card.

Link encap (encapsulation [inkpsju'lein;inkps'lein] n. Encapsulated, packaged, sealed): Ethernet Ethernet.

HWaddr: the hardware address of the network card, used to be called MAC.

The IP address of inet addr:IPv4, and the subsequent Bcast and Mask represent Broadcast and Netmask, respectively.

Inet6 addr: it's the IPv6 version of IP, which we didn't use, so skip scope: domain.

RX: that line represents the number of packets received since the network was started. Packets represents the number of packets, errors represents the number of packet errors, dropped represents the number of packets dropped due to problems, and so on.

TX: contrary to RX, it is the transmission of the network from startup to now.

Collisions: represents the situation of packet collisions. If it happens too many times, your network is not in good condition.

Txqueuelen: represents the storage length of the buffer used to transfer data.

RX Bytes, TX Bytes: the total number of bytes transmitted and received.

Interrupt, Memory: data of network card hardware, IRQ bifurcation and memory address.

By observing the above information, you can generally understand the situation of your network, especially the number of error in RX and TX, and whether there is a serious collision situation.

Description:

Eth0 represents the first network card, where HWaddr represents the physical address of the network card. You can see that the physical address (MAC address) of this network card is 00:50:56:BF:26:20.

Inet addr is used to represent the IP address of the network card. The IP address of this network card is 192.168.120.204, broadcast address, Bcast:192.168.120.255, mask address Mask:255.255.255.0.

Lo is the bad address of the host, which is generally used to test a network program, but does not want users of the local area network or external network to view it, so it can only run and view the network interface used on this host. For example, assign the HTTPD server to the bad address and type 127.0.0.1 in the browser to see your WEB site. But only you can see, other hosts or users of the local area network do not know.

First line: connection type: Ethernet (Ethernet) HWaddr (hardware mac address)

Second line: IP address, subnet, mask of the network card

Line 3: UP (for network card on status) RUNNING (network cable for network card is connected) MULTICAST (support for multicast) MTU:1500 (maximum transmission unit): 1500 bytes

Fourth and fifth elements: statistics of receiving and sending packets

Line 7: receive and send data byte statistics.

Example 2: starts and shuts down the specified network card

Command:

Ifconfig eth0 up

Ifconfig eth0 down

Output:

Description:

Ssh login Linux server operation should be careful, closed can not be turned on, unless you have multiple network cards.

Example 3: configure and delete IPv6 addresses for network cards

Command:

Ifconfig eth0 add 33ffe:3240:800:1005::2/64

Ifconfig eth0 del 33ffe:3240:800:1005::2/64

Output:

Description:

Ifconfig eth0 add 33ffe:3240:800:1005::2/64 configures the IPv6 address for the network card eth0

Ifconfig eth0 add 33ffe:3240:800:1005::2/64 deletes the IPv6 address for the network card eth0

During the practice, ssh login Linux server operation should be careful, closed can not be turned on, unless you have multiple network cards.

Example 4: modify MAC address with ifconfig

Command:

Ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE

Output:

[root@localhost ~] # ifconfig eth0 down / / close the network card

[root@localhost ~] # ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE / / modify MAC address

[root@localhost ~] # ifconfig eth0 up / / start the network card

[root@localhost ~] # ifconfig

Eth0 Link encap:Ethernet HWaddr 00:AA:BB:CC:DD:EE

Inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0

TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7MiB)

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:68 errors:0 dropped:0 overruns:0 frame:0

TX packets:68 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:0

RX bytes:2856 (2.7KiB) TX bytes:2856 (2.7KiB)

[root@localhost ~] # ifconfig eth0 hw ether 00:50:56:BF:26:20 / / close the Nic and modify the MAC address

[root@localhost ~] # ifconfig

Eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:20

Inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0

TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7MiB)

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:68 errors:0 dropped:0 overruns:0 frame:0

TX packets:68 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:0

RX bytes:2856 (2.7KiB) TX bytes:2856 (2.7KiB)

Description:

Example 5: configure IP address

Command:

Output:

[root@localhost ~] # ifconfig eth0 192.168.120.56

[root@localhost ~] # ifconfig eth0 192.168.120.56 netmask 255.255.255.0 broadcast 192.168.120.255

Description:

Ifconfig eth0 192.168.120.56

Ifconfig eth0 192.168.120.56 netmask 255.255.255.0

Configure the eth0 network card with an IP address of 192.168.120.56 with a submask of 255.255.255.0

Ifconfig eth0 192.168.120.56 netmask 255.255.255.0 broadcast 192.168.120.255

/ configure the eth0 Nic with IP address: 192.168.120.56, plus submask: 255.255.255.0, plus a broadcast address: 192.168.120.255

Example 6: enable and disable the ARP protocol

Command:

Ifconfig eth0 arp

Ifconfig eth0-arp

Output:

[root@localhost ~] # ifconfig eth0 arp

[root@localhost ~] # ifconfig eth0-arp

Description:

Ifconfig eth0 arp enables the arp protocol of the network card eth0

Ifconfig eth0-arp shuts down the arp protocol of network card eth0

Example 7: set the maximum transmission unit

Command:

Ifconfig eth0 mtu 1500

Output:

[root@localhost ~] # ifconfig eth0 mtu 1480

[root@localhost ~] # ifconfig

Eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:1F

Inet addr:192.168.120.203 Bcast:192.168.120.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1480 Metric:1

RX packets:8712395 errors:0 dropped:0 overruns:0 frame:0

TX packets:36631 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:597062089 (569.4 MiB) TX bytes:2643973 (2.5 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:9973 errors:0 dropped:0 overruns:0 frame:0

TX packets:9973 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:0

RX bytes:518096 (505.9 KiB) TX bytes:518096 (505.9 KiB)

[root@localhost ~] # ifconfig eth0 mtu 1500

[root@localhost ~] # ifconfig

Eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:1F

Inet addr:192.168.120.203 Bcast:192.168.120.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:8712548 errors:0 dropped:0 overruns:0 frame:0

TX packets:36685 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:597072333 (569.4 MiB) TX bytes:2650581 (2.5 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:9973 errors:0 dropped:0 overruns:0 frame:0

TX packets:9973 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:0

RX bytes:518096 (505.9 KiB) TX bytes:518096 (505.9 KiB)

[root@localhost ~] #

Description:

Set the maximum big data packet size to 1500 bytes.

Note: the network card information configured with the ifconfig command will not exist after the machine is restarted after the network card is restarted. If you want to keep the above configuration information on your computer forever, you need to modify the configuration file of the network card.

Thank you for your reading, the above is the content of "detailed explanation of linux command ifconfig". After the study of this article, I believe you have a deeper understanding of the detailed explanation of linux command ifconfig, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report