[Turn] ifconfig command in linux Detailed Detailed

1 Overview 

ifconfig tool can be used not only simple access network interface configuration information may further modifications to these configurations. Card information configured with ifconfig command, the reboot card after restart, the configuration does not exist. To the above computer configuration information stored in forever, it would have to modify the configuration file of the card.

2 command Detailed

2.1 Command Common parameters

Usage:

ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
[add <address>[/<prefixlen>]]
[del <address>[/<prefixlen>]]
[[-]broadcast [<address>]] [[-]pointopoint [<address>]]
[netmask <address>] [dstaddr <address>] [tunnel <address>]
[outfill <NN>] [keepalive <NN>]
[hw <HW> <address>] [metric <NN>] [mtu <NN>]
[[-]trailers] [[-]arp] [[-]allmulti]
[multicast] [[-]promisc]
[mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]
[txqueuelen <NN>]
[[-]dynamic]
[up|down] ...

2.2 Common Command Parameter Description

parameter

Explanation

-a

Show all interface information.

-s

Display summary information (like netstat -i).

<interface> address

Setting the IPv4 address for the network card.

<interface> add <address>

Configure IPv6 address to a specified network card.

<interface> del <address>

Delete the specified IPv6 address of the network card.

<interface> netmask <address>

Set the subnet mask card. Prefix 0x mask may be 32-bit hexadecimal number, and may be separated by dots of four decimal numbers. If you do not intend to divide your network into subnets you can leave this option; if you want to use subnets, keep in mind that every system in the network must have the same subnet mask.

<interface> dstaddr <address>

Setting a remote address, to establish point to point communication.

<interface> tunnel <address>

Establishing a tunnel.

<interface> hw <address>

Set the hardware address.

<interface> mtu <NN>

Setting the maximum transmission unit.

<interface> [-]arp

Setting specifies whether the card supports ARP protocol. - said they did not support arp.

<interface> multicast

Set the multicast flag for the card.

<interface> [-]promisc

Set whether to support promiscuous mode network card, if you choose this parameter, the NIC will receive the network packets sent to it all. - means closed promiscuous mode.

<interface> txqueuelen <NN>

Set the transmission queue length of the card.

<interface> up

Start the specified card.

<interface> down

Close the specified card. This parameter can be effectively prevented by the specified interface IP traffic, if you want to permanently shut down the interface, we also need to remove all the routing information from the interface of the core routing table.

2.3 NICs field a brief description
 

(1) Simple analysis 

[root @ localhost ~] # ifconfig eth0

// UP: that "interface is enabled."
// BROADCAST: means "host supports the broadcast."
// RUNNING: means "interfaces at work."
// MULTICAST: that "hosts support multicasting."
// MTU: 1500 (maximum transmission unit): 1500 bytes
eth0: the flags = 4163 <the UP, BROADCAST, the RUNNING, the MULTICAST> MTU 1500

// inet: the IP address of the NIC.
// netmask: network mask.
// broadcast: broadcast address.
192.168.1.135 Netmask 255.255.255.0 Broadcast 192.168.1.255 inet

the IPv6 address of the NIC //
inet6 FE80 :: 2AA: bbff: FECC: 64 ddee the prefixlen ScopeID 0x20 <Link>

// Connection Type: Ethernet (Ethernet) HWaddr (hardware mac address)
// txqueuelen (transmit queue length is set NIC)
ether 00: AA: BB: CC: dd: EE txqueuelen (Ethernet) 1000


when the RX packets received, the correct number of packets //.
The amount of data received // RX bytes.
// RX errors when received, number of packets error.
// RX dropped when received, number of packets dropped.
Upon receiving // RX overruns, due to the excessive speed of the number of lost packets.
// RX frame data is received, frame error number of packets lost.
218 511 2825 bytes packets the RX (213.3 KiB)
the RX errors Dropped 0 0 0 Frame 0 overruns

when // TX packets sent, number of packets correctly.
// TX bytes amount of data sent.
// TX errors during transmission, error number of packets.
// When TX dropped sent, number of packets dropped.
Sending // TX overruns, due to the excessive speed of the number of lost packets.
// TX carrier is transmitted, carrier errors and lost data packet number.
// The number of collisions conflict packets.
145 236 1077 bytes packets the TX (141.8 KiB)
the TX errors Dropped 0 0 0 overruns Carrier 0 0 Collisions

3 Simple example

3.1 shows the network devices information 

(1) show activation card information

ifconfig 

(2) all the network information

ifconfig -a 

(3) a brief display card information

ifconfig -s 

3.2 Start Close the specified card
(1) Close card

ifconfig eth0 down 

(2) Start card

ifconfig eth0 up 

3.3 ip address configuration and delete 

(1) Configuration ip

// ip address configuration
ifconfig eth0 192.168.1.100

// the ip address and subnet mask
ifconfig eth0 192.168.1.100 netmask 255.255.255.0

// the ip address, subnet mask and broadcast address
ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255 

(2) adding a plurality of single NIC IP addresses

ifconfig eth0:0 192.168.1.100 netmask 255.255.255.0 up

ifconfig eth0:1 192.168.2.100 netmask 255.255.255.0 up
 

(3) delete the IP address

ifconfig eth0 del 192.168.1.100

3.4 modify the MAC address

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

3.5 enable and disable the ARP protocol

(1) enable arp

ifconfig eth0 arp

(2) Disable arp

ifconfig eth0 -arp

Disable arp when you can see NOARP field appears.

[root@localhost ~]# ifconfig eth0 arp
[root@localhost ~]#
[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link>
ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet)
RX packets 2635 bytes 204710 (199.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1071 bytes 144688 (141.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[root@localhost ~]# ifconfig eth0 -arp
[root@localhost ~]#
[root@localhost ~]# ifconfig eth0
eth0: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST> mtu 1500
inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link>
ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet)
RX packets 2636 bytes 204770 (199.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1071 bytes 144688 (141.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

3.6 setting the maximum transmission unit
 

ifconfig eth0 man 1500

3.7 set promiscuous mode network card
 

(1) Enable

ifconfig eth0 promisc
 

(2) disabled

ifconfig eth0 -promisc
 

If this parameter, the network card receives all packets addressed to it. PROMISC field appears when enabled.

[root@localhost ~]# ifconfig eth0 promisc
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ifconfig eth0
eth0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500
inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link>
ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet)
RX packets 2659 bytes 206696 (201.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1071 bytes 144688 (141.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


[root@localhost ~]#
[root@localhost ~]# ifconfig eth0 -promisc
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link>
ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet)
RX packets 2661 bytes 206816 (201.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1071 bytes 144688 (141.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

3.8 Setting multicast mode network card
 

(1) Enable

ifconfig eth0 allmulti
 

(2) disabled

ifconfig eth0 -allmulti

If this parameter, the network card will receive all multicast packets on the network. When enabled MULTICAST field appears.

[root@localhost ~]# ifconfig eth0 allmulti
[root@localhost ~]#
[root@localhost ~]# ifconfig eth0
eth0: flags=4675<UP,BROADCAST,RUNNING,ALLMULTI,MULTICAST> mtu 1500
inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link>
ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet)
RX packets 2676 bytes 207716 (202.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1071 bytes 144688 (141.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


[root@localhost ~]#
[root@localhost ~]# ifconfig eth0 -allmulti
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link>
ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet)
RX packets 2676 bytes 207716 (202.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1071 bytes 144688 (141.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

3.9 configuration and remove the IPv6 address
 

(1) add

ifconfig eth0 add 3ffe:3240:800:1005::2/64
 

(2) deleted

3ffe del eth0 ifconfig: 3240: 800: 1005 :: 2/64
----------------
Disclaimer: This article is CSDN blogger original article "Luchi travel", following CC 4.0 by-sa copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/u011857683/article/details/83758503

Guess you like

Origin www.cnblogs.com/shuai7boy/p/11387990.html