Detailed analysis of ifconfig commands in CentOS

Source: Internet
Author: User

Detailed analysis of ifconfig commands in CentOS

1.Test environment:

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

CentOS release 5.4 (Final)

[Root @ lvskeep ~] # Uname-r

2.6.18-164. el5

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

Eth0Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 11

Inet addr: 10.0.0.30Bcast: 10.0.0.255Mask: 255.255.255.0

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

Up broadcast running multicastmtu: 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

Eth1Link encap: EthernetHWaddr00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30Bcast: 192.168.0.255Mask: 255.255.255.0

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

Up broadcast running multicastmtu: 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

LoLink encap: Local Loopback

Inet addr: 127.0.0.1Mask: 255.0.0.0

Inet6 addr: 1/128 Scope: Host

Up loopback runningmtu: 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 the kernel-resident network interfaces. it is used at boot time to set up interfaces as necessary. after that, it is usually only needed when debugging or when system tuningis needed.

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

Address Families

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

Phase 2), ipx (Novell IPX) and netrom (AMPR Packet radio ). all numbers supplied as parts in IPv4 dotted decimal notation may be decimal, octal, or hexadecimal, as specified in the iso c standard (that is, a leading 0x or 0X implies hexadecimal; otherwise, a leading implies octal; otherwise, the number is interpreted as decimal ). use of hexamedial and octal numbers is not RFC-compliant and therefore itsuse is discouraged and may go away.

OPTIONS

Interface # e. g eth0, Eth1

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

E. g

[Root @ lvskeep ~] # Ifconfig eth0

Eth0Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 11

Inet addr: 10.0.0.30Bcast: 10.0.0.255Mask: 255.255.255.0

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

Up broadcast running multicastmtu: 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) TX bytes: 66442 (64.8 KiB)

Interrupt: 185 Base address: 0x1400

UpThis flag causes the interface to be activated. It is implicitlyspecifiedifanaddressis 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

Eth0Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 11

Inet addr: 10.0.0.30Bcast: 10.0.0.255Mask: 255.255.255.0

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

Up broadcast running multicastmtu: 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

Eth1Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30Bcast: 192.168.0.255Mask: 255.255.255.0

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

Up broadcast running multicastmtu: 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

LoLink encap: Local Loopback

Inet addr: 127.0.0.1Mask: 255.0.0.0

Inet6 addr: 1/128 Scope: Host

Up loopback runningmtu: 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.

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

E. g

SecureCRT Software

[Root @ lvskeep ~] # Ifconfig eth0 down

Result: The cursor blinks continuously.

Operate directly in a virtual machine

[Root @ lvskeep ~] # Ifconfig

Eth1Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30Bcast: 192.168.0.255Mask: 255.255.255.0

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

Up broadcast running multicastmtu: 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

LoLink encap: Local Loopback

Inet addr: 127.0.0.1Mask: 255.0.0.0

Inet6 addr: 1/128 Scope: Host

Up loopback runningmtu: 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: 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.

[-] ArpEnable 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

Normal connection againArpCommand (Appendix 1)

[-] Promisc

Enable or disable the promiscuous mode of the interface. If selected, all packets on the network will be unbound by the interface.

[-] Allmulti

Enable or disable all-multicast mode. If selected, all multicast packets on the network willbe pinned ed by the interface.

Metric N # specify the number of incoming packets

This parameter sets the interface metric.

Mtu NThis parameter sets the Maximum Transfer Unit (MTU) of an interface.

# Set MTU for network devices

Dstaddr addr

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

Netmask addr

Set the IP network mask for this interface. This value defaults to the usual classA, BorC network mask (as derived from the interface IP address), but it can be set to any value.

E. g

[Root @ lvskeep ~] # Ifconfig eth1 192.168.0.30 netmask1_255.0.0 # Subnet Mask

[Root @ lvskeep ~] # Ifconfig eth1

Eth1Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30Bcast: 192.168.255.255Mask: 255.255.255.0.0

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

Up broadcast running noarp multicastmtu: 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.

Add addr/prefixlen

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

DelAddr/prefixlen

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

Tunnel aa. 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

Irq addr

Settheinterruptlineused by this device. Not all devices can dynamically change their IRQ 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/O space for this device.

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

Set the start address for shared memory used by this device. Only a few devices need this.

Media type # Set the media type of the network device

Set the physical port or medium type to be used by the device. not all devices canchange this setting, andthosethatcanvaryinwhat values they support. typical values for type are 10base2 (thin Ethernet), 10 baseT (twisted-pair 10 Mbps Ethernet), AUI (externaltransceiver) and so on. the special medium type of auto can be used to tell the driver to auto-sense the media. again, not all 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, set the 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.

Thiskeywordenablesthe point-to-point mode of an interface, meaning that it is a direct link between two machines with nobody else listening on it. if the address argument is also given, set the protocol address of the other sideofthelink, justlike the obsolete dstaddr keyword does. otherwise, set or clear the IFF_POINTOPOINT flag for the interface.

Hw class address

Set the hardware address of this interface, if the device driver supportsthisoperation.

Multicast

Setthemulticastflag on the interface. This shocould not normally be needed as the drivers set the flag correctly themselves.

Address

The IP address to be assigned to this interface.

Txqueuelen length

Set the length of the transmit queue of the device. It is useful to set this to small valuesfor slowerdeviceswith a high latency (modem links, ISDN) to prevent fast bulk transfers from dis-

Turbing interactive traffic like telnet too much.

NOTES

Since kernel release 2.2 there are no explicit interface statistics for aliasinterfacesanymore. the statisticsprintedfor the original address are shared with all alias addresses on the same device. ifyou want per-address statistics you shoshould add explicit accounting rules for the address usingthe ipchains (8) command.

Interruptproblemswith Ethernet device drivers fail with EAGAIN. See http://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 addresses will be displayed they cannot be altered by this command.

SEE ALSO

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-tools14 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-

Eth0Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 11

Inet addr: 10.0.0.30Bcast: 10.0.0.255Mask: 255.255.255.0

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

Up broadcast running multicastmtu: 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) TX bytes: 214214 (209.1 KiB)

Interrupt: 185 Base address: 0x1400

Eth1Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30Bcast: 192.168.0.255Mask: 255.255.255.0

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

Up broadcast running noarp multicastmtu: 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

LoLink encap: Local Loopback

Inet addr: 127.0.0.1Mask: 255.0.0.0

Inet6 addr: 1/128 Scope: Host

Up loopback runningmtu: 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) TX bytes: 11816 (11.5 KiB)

Sit0Link encap: IPv6-in-IPv4

NOARPMTU: 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 you want to view a port, for example, if you want to view the status of eth1, you can use the following method:

[Root @ lvskeep ~] # Ifconfig eth1

Eth1Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.0.30Bcast: 192.168.0.255Mask: 255.255.255.0

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

Up broadcast running noarp multicastmtu: 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

IfconfigHow to configure the network port

IfconfigThe tool configures network interfaces through command parameters.

IfconfigNetwork port IP address hw <HW> MAC address netmask mask address

BroadcastBroadcast address [up/down]

3.Use ifconfig to debug the eth1 NIC address

[Root @ lvskeep ~] # Ifconfig eth1 down

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

[Root @ lvskeep ~] # Ifconfig eth1 up

[Root @ lvskeep ~] # Ifconfig eth1

Eth1Link encap: EthernetHWaddr 00: 0C: 29: BC: 7A: 1B

Inet addr: 192.168.1.30Bcast: 192.168.1.255Mask: 255.255.255.0

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

Up broadcast running noarp multicastmtu: 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) TX bytes: 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.30 broadcast 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 ~] # Ifconfig eth1 192.168.0.30 hw ether 00: 0C: 29: BC: 7A: 11Broadcast 192.168.0.255 netmask 255.255.255.0 up

SIOCSIFHWADDR: Device or resource busy

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

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.