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

The usage of the Linux basic command ifconfig

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the usage of the Linux basic command ifconfig". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of the Linux basic command ifconfig".

Ifconfig

The ifconfig instruction is used to configure network interface parameters and to display the working status of the current kernel network interface. If no parameters are provided, ifconfig displays the status of the currently active interface. If a single interface parameter is given, only the status of the given interface is displayed; if a single "- a" parameter is given, the status of all interfaces is displayed, even for down interfaces. Otherwise, it configures an interface.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Ifconfig [interface | up | down]

2. List of option parameters

Parameters.

Description

Interface

The name of the interface. This is usually a driver name followed by a unit number, such as eth0 for the first Ethernet interface.

Up

This flag will cause the interface to be activated. If an address is assigned to an interface, the address is implicitly specified.

Down

This flag causes the driver for this interface to be shut down.

[-] arp

Enable or disable the use of the ARP protocol on this interface.

[-] promisc

Enables or disables promiscuous mode for the interface. If checked, all packets on the network will be received by the interface.

[-] allmulti

Enables or disables all multicast modes. If checked, the interface will receive all multicast packets on the network.

Metric N

This parameter sets the interface metric. It is not available under GNU/Linux

Mtu N

This parameter sets the maximum transmission unit (MTU) of the interface.

Dstaddr addr

Set a remote IP address for a point-to-point link, such as PPP. This keyword is now out of date; use the pointopoint keyword instead.

Netmask addr

Sets the IP network mask for this interface. This value defaults to the usual Class A, B, or C netmask (derived from the interface IP address), but can be set to any value.

Add addr/prefixlen

Add an IPv 6 address to an interface

Del addr/prefixlen

Remove the IPv 6 address from the interface

Tunnel:: aa.bb.cc.dd

Create a new SIT (IPv6-in-IPv4) device that tunnels to the given destination.

Irq addr

Sets the interrupt line used by this device. Not all devices can change their IRQ settings dynamically.

Io_addr addr

Set the starting address in the Istroke O space for the device

Mem_start addr

Sets the starting address of the shared memory used by this device. Only a few devices need this.

Media type

Set the physical port or media type to be used by the device. Not all devices can change this setting, as well as those devices that can change their supported values. Typical type values are 10 base 2 (thin Ethernet), 10 base T (twisted pair 10 Mbps Ethernet), AUI (external transceiver), and so on. The special media type of the driver can be used to tell the driver to automatically perceive the media. Similarly, not all drivers can do this.

[-] broadcast [addr]

If the address parameter is given, the protocol broadcast address is set for the interface. Otherwise, set (or clear) the IFF_BROADCAST flag for the interface.

[-] pointopoint [addr]

This keyword enables the peer-to-peer mode of the interface, which means that it is a direct link between the two machines, and no one else is listening to it. If the address parameter is also given, set the protocol address at the other end of the link, just like the outdated dstaddr keyword. Otherwise, set or clear the IFF_POINTOPOINT flag for the interface.

Hw class address

If the device driver supports this operation, set the hardware address for this interface. The keyword must be followed by the name of the hardware class and a printable ASCII equivalent to the hardware address. Currently supported hardware classes include ether (Ethernet), ax25 (AMPRAX.25), ARCnet and netrom (AMPR NET/ROM).

Multicast

Set the multicast flag on the interface. This should not usually be required because the driver itself sets the correct flags.

Address

The IP address to assign to this interface.

Txqueuelen length

Sets the length of the transmission queue for the device. For slower devices with high latency (modem link, ISDN), it is useful to set it to a small value to prevent fast batch transmission from interfering too much with interactive communications such as telnet.

3. Address family

If the first parameter after the interface name is identified as the name of the supported address family, the address family is used to decode and display all protocol addresses. Currently supported address families include Internet (TCP/IP, default), inet6 (IPv 6), Axis25 (AMPR packet radio), ddp (AppleTalk phase 2), IPX (Novell IPX), and netrom (AMPR packet radio). All numbers provided in the IPv4 dotted decimal representation can be decimal, octal, or hexadecimal, as specified in the ISO C standard (that is, leading 0x or 0x represents hexadecimal; otherwise, leading "0" represents octal; otherwise, the number is interpreted as decimal). The use of hexadecimal and octal numbers is not RFC compliant, so its use is discouraged and may disappear.

4. Examples

1) View the current network status

[root@localhost ~] # ifconfig / / does not have any parameter options and displays all current network status

Eth0 Link encap:Ethernet HWaddr 08:00:27:14:33:57

Inet6 addr: fe80::a00:27ff:fe14:3357/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

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

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

Collisions:0 txqueuelen:1000

RX bytes:83580745 (79.7MiB) TX bytes:5842218 (5.5MiB)

Lo Link encap:Local Loopback

Inet addr:127.0.0.1 Mask:255.0.0.0

Inet6 addr: 1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

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

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

Collisions:0 txqueuelen:0

RX bytes:786270 (767.8 KiB) TX bytes:786270 (767.8 KiB)

2) View the status of the specified network card

[root@localhost ~] # ifconfig eth0 / / displays the specified Nic status

Eth0 Link encap:Ethernet HWaddr 08:00:27:14:33:57

Inet6 addr: fe80::a00:27ff:fe14:3357/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

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

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

Collisions:0 txqueuelen:1000

RX bytes:83580745 (79.7MiB) TX bytes:5842218 (5.5MiB)

3) start the network card

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

[root@localhost ~] # ifconfig eth0 up / / enable eth0

[root@localhost ~] # ifconfig eth0 / / View eth0, ip has been assigned

Eth0 Link encap:Ethernet HWaddr 08:00:27:14:33:57

Inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0

Inet6 addr: fe80::a00:27ff:fe14:3357/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

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

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

Collisions:0 txqueuelen:1000

RX bytes:83582067 (79.7MiB) TX bytes:5843588 (5.5MiB)

Thank you for your reading, the above is the content of "the usage of the Linux basic command ifconfig". After the study of this article, I believe you have a deeper understanding of the usage of the Linux basic 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

Servers

Wechat

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

12
Report