Detailed parsing of Ifconfig commands

Source: Internet
Author: User

Detailed parsing of Ifconfig commands

1. test environment:

[Root @ lvskeep ~] # Cat/etc/redhat-release

CentOSrelease 5.4 (Final)

[Root @ lvskeep ~] # Uname-r

2.6.18-164. el5

[Root @ lvskeep ~] # Ifconfig # Local Network Configuration

Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 11

Inet addr: 10.0.0.30 Bcast: 10.0.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a11/64 Scope: Link

Up broadcast running multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 91733 (89.5 KiB) TX bytes: 84456 (82.4 KiB)

Interrupt: 185 Base address: 0x1400

Eth1 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30 Bcast: 192.168.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a1b/64 Scope: Link

Up broadcast running multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 6622 (6.4 KiB) TX bytes: 7942 (7.7 KiB)

Interrupt: 169 Base address: 0x1480

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

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

Collisions: 0 txqueuelen: 0

RX bytes: 1224 (1.1 KiB) TX bytes: 1224 (1.1 KiB)

Note:

Eth0 indicates the first network card. HWaddr indicates the physical address of the network card.

The physical address (MAC address) of each network adapter is 00: 0C: 29: BC: 7A: 1B. the inet addr is used to represent the network adapter.

IP address. The IP address of this Nic is 10.0.0.30, broadcast address,

Bcast: 10.0.0.255, Mask Address Mask: 255.255.255.0

Lo indicates the host's bad return address, which is generally used to test a network program, but does not want the Local Area

Users on the Internet or Internet can view the network interfaces used only on this host. For example, I

You can enter 127.0.0.1 in your browser to view your website.

WEB site. But you can only see it, and other hosts or users in the LAN cannot know it;

2. Run the man command to view the help provided by the system.

[Root @ lvskeep ~] # Man ifconfig

NAME

Ifconfig-configure a network interface

SYNOPSIS # summary, summary, general idea

Ifconfig [interface]

Ifconfig interface [aftype] options | address...

DESCRIPTION

Ifconfig is used to configure thekernel-resident network interfaces. Itis used at boot time to set up interfaces as necessary. After that, it is usually only needed whendebugging or when system tuning isneeded.

If no arguments are given, ifconfig displays the status of the currently active interfaces. if a single interface argument is given, itdisplays the status of the given interface only; if a single-a argument is given, it displays the status of allinterfaces, even those that are down. otherwise, it configures an interface.

AddressFamilies

If the first argument after theinterface name is recognized as the name of a supported address family, thataddress family is used for decoding and displaying all protocol addresses. currently supported address families includeinet (TCP/IP, default), inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk

Phase2), ipx (Novell IPX) and netrom (AMPR Packet radio ). all numbers supplied as parts in IPv4 dotteddecimal notation may be decimal, octal, or hexadecimal, as specified in the ISOC standard (that is, a leading 0x or 0X implies hexadecimal; otherwise, aleading implies octal; otherwise, the number is interpreted as decimal ). use ofhexamedial and octal numbers is not RFC-compliant and therefore its use is discouraged and may go away.

OPTIONS

Interface # e. g eth0, eth1

The name of the interface. This is usually a driver name followed by aunit number, for example eth0 for the first Ethernet interface.

E. g

[Root @ lvskeep ~] # Ifconfigeth0

Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 11

Inet addr: 10.0.0.30 Bcast: 10.0.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a11/64 Scope: Link

Up broadcast running multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 68647 (67.0 KiB) TXbytes: 66442 (64.8 KiB)

Interrupt: 185 Base address: 0x1400

Up This flag causes the interface to be activated. It is implicitly specified if an address is assigned to the interface.

E. g

Run the ifconfig eth0 up command on the VM to activate eth0.

[Root @ lvskeep ~] # Ifconfig eth0 up

[Root @ lvskeep ~] # Ifconfig # verify Activation

Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 11

Inet addr: 10.0.0.30 Bcast: 10.0.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a11/64 Scope: Link

Up broadcast running multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 91733 (89.5 KiB) TX bytes: 84456 (82.4 KiB)

Interrupt: 185 Base address: 0x1400

Eth1 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30 Bcast: 192.168.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a1b/64 Scope: Link

Up broadcast running multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 6622 (6.4 KiB) TX bytes: 7942 (7.7 KiB)

Interrupt: 169 Base address: 0x1480

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

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

Collisions: 0 txqueuelen: 0

RX bytes: 1224 (1.1 KiB) TX bytes: 1224 (1.1 KiB)

The eth0 is successfully activated.

Down This flag causes thedriver for this interface to be shut down.

E. g

SecureCRT Software

[Root @ lvskeep ~] # Ifconfigeth0 down

Result: The cursor blinks continuously.

Operate directly in a virtual machine

[Root @ lvskeep ~] # Ifconfig

Eth1 Linkencap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 1B

Inetaddr: 192.168.0.30 Bcast: 192.168.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a1b/64 Scope: Link

Up broadcastrunning multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 6622 (6.4KiB) TX bytes: 7942 (7.7 KiB)

Interrupt: 169 Baseaddress: 0x1480

Lo Link encap: LocalLoopback

Inet addr: 127.0.0.1 Mask: 255.0.0.0

Inet6 addr: 1/128 Scope: Host

Up loopbackrunning mtu: 16436 Metric: 1

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

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

Collisions: 0 txqueuelen: 0

RX bytes: 1224 (1.1KiB) TX bytes: 1224 (1.1 KiB)

Note: After the ifconfig eth0 down command is executed, the eth0 NIC will be stopped and disconnected. The SecureCRT is a virtual machine connected through eth0, so the cursor will flash all the time; run the ifconfig command on the VM to verify that eth0 has actually stopped.

[-] Arp Enable or disable the use of the ARP protocol on this interface.

E. g

[Root @ lvskeep ~] # Ifconfig eth0-arp # ARP Protocol disabled

After executing this command, SecureCRT and the virtual machine are disconnected. When ARP is disabled, the relationship between the IP address and the MAC address is lost and the host cannot be identified.

[Root @ lvskeep ~] # Ifconfig eth0 arp # enable ARP

Connect to the normal arp command again (Appendix 1)

[-] Promisc

Enable or disable the promiscuousmode of the interface. If selected, allpackets on the network will be unbound by the interface.

[-] Allmulti

Enable or disable all-multicastmode. If selected, all multicast packetson the network will be unbound by theinterface.

MetricN # specify the number of incoming packets

This parameter sets the interfacemetric.

MtuN This parameter sets the MaximumTransfer Unit (MTU) of an interface.

# Set MTU for network devices

Dstaddraddr

Set the remote IP address for apoint-to-point link (such as PPP). Thiskeyword is now obsolete; use the pointopoint keyword instead.

Netmaskaddr

Set the IP network mask for thisinterface. This value defaults to theusual class A, B or C network mask (as derivedfrom the interface IP address), but it can be set to any value.

E. g

[Root @ lvskeep ~] # Ifconfig eth1194250.30 netmask 255.255.255.0.0 # Subnet Mask

[Root @ lvskeep ~] # Ifconfig eth1

Eth1 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30 Bcast: 192.168.255.255 Mask: 255.255.255.0.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a1b/64 Scope: Link

Up broadcast running noarpmulticast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 6622 (6.4 KiB) TX bytes: 11144 (10.8 KiB)

Interrupt: 169 Base address: 0x1480

Note: netmask cannot be capitalized.

Addaddr/prefixlen

Add an IPv6 address to aninterface. # Set the IPv6 IP address of the network device.

Del addr/prefixlen

Remove an IPv6 address from aninterface. # Delete the IPv6 IP address of a network device.

Tunnelaa. bb. cc. dd

Create a new SIT (IPv6-in-IPv4) device, tunnelling to the given destination. # Create a tunnel communication address between IPv4 and IPv6

Irqaddr

Set the interrupt line used by this device. Not all devices can dynamically change theirIRQ setting. # Set the IRQ of the network device

Io_addr addr # Set the I/O address of the network device

Set the start address in I/Ospace for this device.

Mem_startaddr # Set the starting address occupied by the network device in the main memory

Set the start address for sharedmemory used by this device. Only a fewdevices need this.

Mediatype # Set the media type of the network device

Set the physical port or mediumtype to be used by the device. not alldevices can change this setting, and those that can vary in what values they support. typical values for type are 10base2 (thinEthernet), 10 baseT (twisted-pair 10 Mbps Ethernet), AUI (external transceiver) and so on. the special mediumtype of auto can be used to tell the driver to auto-sense the media. again, notall drivers can do this.

[-] Broadcast [addr] # the data packets to be sent to the specified address are processed as broadcast data packets.

If the address argument is given, setthe protocol broadcast address for this interface. Other-wise, set (or clear) the IFF_BROADCAST flag for the interface.

[-] Pointopoint [addr] # establish a direct connection with the network device of the specified address. This mode has the confidentiality function.

This keyword enables the point-to-point modeof an interface, meaning that it is a direct link between two machines withnobody else listening on it. if the address argument is also given, set theprotocol address of the other side of the link, just like the obsolete dstaddr keyword does. otherwise, set or clear the IFF_POINTOPOINT flag for the interface.

Hwclass address

Set the hardware address of thisinterface, if the device driver supports this operation.

Multicast

Set the multicast flag on the interface. This shoshould notnormally be needed as the drivers set the flag correctly themselves.

Address

The IP address to be assigned tothis interface.

Txqueuelenlength

Set the length of the transmitqueue of the device. It is useful to set this to small values for slower devices with a high latency (modem links, ISDN) to prevent fast bulk transfers from dis-

Turbing interactive traffic liketelnet too much.

NOTES

Since kernel release 2.2 there are noexplicit interface statistics for alias interfaces anymore. the statistics printed for the original address are shared with all alias addresses on the samedevice. if you want per-address statisticsyou shoshould add explicit accounting rules for the address using the ipchains (8) command.

Interrupt problems with Ethernet device drivers fail with EAGAIN. Seehttp: // www.scyld.com/expert/irq-conflict.html for more information.

FILES

/Proc/net/socket

/Proc/net/dev

/Proc/net/if_inet6

BUGS

While appletalk DDP and IPX addresseswill be displayed they cannot be altered by this command.

SEEALSO

Route (8), netstat (8), arp (8), rarp (8), ipchains (8)

AUTHORS

Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>

Alan Cox, Alan.Cox@linux.org>

Phil Blundell, Philip.Blundell@pobox.com>

Andi Kleen

Net-tools 14 August 2000 IFCONFIG (8)

Instance:

1. If you want to know all the network interfaces of the host, run the following command:

[Root @ lvskeep ~] # Ifconfig-

Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 11

Inet addr: 10.0.0.30 Bcast: 10.0.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a11/64 Scope: Link

Up broadcast running multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 280167 (273.6 KiB) TXbytes: 214214 (209.1 KiB)

Interrupt: 185 Base address: 0x1400

Eth1 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30 Bcast: 192.168.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a1b/64 Scope: Link

Up broadcast running noarp multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 6622 (6.4 KiB) TX bytes: 14376 (14.0 KiB)

Interrupt: 169 Base address: 0x1480

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

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

Collisions: 0 txqueuelen: 0

RX bytes: 11816 (11.5 KiB) TXbytes: 11816 (11.5 KiB)

Sit0 Link encap: IPv6-in-IPv4

Noarp mtu: 1480 Metric: 1

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

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

Collisions: 0 txqueuelen: 0

RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)

2. If we want to view a port, for example, if we want to view the status of eth1, we can use the following method:

[Root @ lvskeep ~] # Ifconfig eth1

Eth1 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30 Bcast: 192.168.0.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a1b/64 Scope: Link

Up broadcast running noarp multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 6622 (6.4 KiB) TXbytes: 14376 (14.0 KiB)

Interrupt: 169 Base address: 0x1480

How to configure the network port in ifconfig

The ifconfig tool configures network interfaces through command parameters.

Ifconfig network port IP address hw <HW> MAC address netmask mask address

Broadcast address [up/down]

3. Use ifconfig to debug the eth1 NIC address

[Root @ lvskeep ~] # Ifconfigeth1 down

[Root @ lvskeep ~] # Ifconfigeth1 192.168.1.30 broadcast 192.168.1.255 netmask 255.255.255.0

[Root @ lvskeep ~] # Ifconfigeth1 up

[Root @ lvskeep ~] # Ifconfigeth1

Eth1 Link encap: Ethernet HWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.1.30 Bcast: 192.168.1.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: febc: 7a1b/64 Scope: Link

Up broadcast running noarp multicast mtu: 1500 Metric: 1

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

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

Collisions: 0 FIG: 1000

RX bytes: 6622 (6.4 KiB) TXbytes: 21736 (21.2 KiB)

Interrupt: 169 Base address: 0x1480

Note:

The first line: ifconfig eth0 down indicates that if eth0 is activated, it will be DOWN. This command is equivalent to ifdown eth0;

Row 2: Use ifconfig to configure the eth0 IP address, broadcast address, and network mask;

Row 3: Use ifconfig eth0 up to activate eth0. This command is equivalent to ifup eth0.

Row 4: Use ifconfig eth0 to view the eth0 status;

You can also use the command IP address, network mask, and broadcast address to activate the NIC. The up parameter must be added.

[Root @ lvskeep ~] # Ifconfig eth1 192.168.1.30broadcast 192.168.1.255 netmask 255.255.255.0 up

4. Set the IP address, network mask, broadcast address, physical address, and activate eth1 of the network adapter.

[Root @ lvskeep ~] # Ifconfigeth1 192.168.0.30 hw ether 00: 0C: 29: BC: 7A: 11 broadcast 192.168.0.255 netmask 255.255.255.0 up

SIOCSIFHWADDR: Device orresource busy

Stop and change the MAC address first. It is recommended that you do not change the MAC address, which is prone to errors.

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.