Linux basic commands -ifconfig

ifconfig command

ifconfig command is used to configure the network parameters and display the network interface of the Linux kernel. 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.

grammar

ifconfig (parameters)
parameter
add <address> : Configuration of network devices ip IPv6 address; 
del <address> : Remove the network device IP address of IPv6; 
Down: Closes the specified network device;
 <HW <network device type> <hardware address> : Set the network device type and hardware address; 
io_addr <I / O address>: set the network device the I / O address; 
IRQ <the IRQ address> : set the network device the IRQ; 
Media <network Media type> : set the network device media type; 
mem_start < memory address> : start address in main memory of the network device occupied; 
Metric <number> : Specifies the number of times when packet transfer calculation, the number to be added; 
MTU <byte> : set the MTU of the network device; 
Netmask <subnet Mask> : set the subnet mask of the network device; 
tunnel <address> : address establishing a communication tunnel between the IPv4 and the IPv6; 
up: start specified network device;
 -broadcast <address>: The packet destined for the specified address as a broadcast packet processed;
-pointopoint <address> : address of the specified devices establish a network connection directly, this model has a security function;
 - promisc: promiscuous mode off or start the designated network device; 
IP Address: The IP address of the designated network device; 
network device: Specify name of the network device.

Examples

Network information display device (active state):

[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3E:00:1E:51  
          inet addr:10.160.7.81  Bcast:10.160.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:61430830 errors:0 dropped:0 overruns:0 frame:0
          TX packets:88534 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3607197869 (3.3 GiB)  TX bytes:6115042 (5.8 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:56103 errors:0 dropped:0 overruns:0 frame:0
          TX packets:56103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5079451 (4.8 MiB)  TX bytes:5079451 (4.8 MiB)

Description:

eth0 represents a card, which HWaddrrepresents the physical address of the card, can see the current physical address of the card (MAC address) is used 00:16:3E:00:1E:51.

inet addr is used to indicate the IP address of the network card, this card is the IP address 10.160.7.81, broadcast address Bcast:10.160.15.255, mask address Mask:255.255.240.0.

lo is a loopback address of the host, this is generally used to test a web application, but do not want the user LAN or outside the network to view, and the view can only run on which network interfaces on this host. For example, the  httpd specify the server to the loopback address, you can see the rack WEB site in browser and enter 127.0.0.1. But only you can see, the host or other LAN users do not know.

  • First line: Connection Type: Ethernet (Ethernet) HWaddr (hardware mac address).
  • Second row: NIC IP address, subnet mask.
  • Third row: the UP (NIC on state on behalf of) the RUNNING (on behalf of the network cable is connected to the card) the MULTICAST (supports multicast) the MTU: 1500 (maximum transmission unit): 1500 bytes.
  • Fourth, the five elements: receive and send data packets statistics.
  • Seventh row: receive and send data bytes statistics.

Start Close the specified card:

ifconfig eth0 up
ifconfig eth0 down

ifconfig eth0 upTo start the network card eth0, ifconfig eth0 downis off the network card eth0. ssh login linux server operations to be careful, you can not open a closed, unless you have multiple network cards.

Configuration and remove the IPv6 address for the network card:

the Add 33ffe eth0 ifconfig: 3240 : 800 : 1005 :: 2 / 64-     # Configure IPv6 address for the network card eth0 
ifconfig eth0 del 33ffe: 3240 : 800 : 1005 :: 2 / 64-     # IPv6 address for the network card eth0 delete

MAC address modification ifconfig:

ifconfig eth0 hw ether 00:AA:BB:CC:dd:EE
Configuring IP address:
[root@localhost ~]# ifconfig eth0 192.168.2.10
[root@localhost ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0
[root@localhost ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255

Enable and disable arp protocol:

ifconfig eth0 arp # arp protocol of open network card eth0 
ifconfig eth0 -arp # arp protocol network card eth0 is closed

The maximum transmission unit setting:

eth0 MTU the ifconfig 1500     # provided by the maximum packet size of 1500 bytes

 

Guess you like

Origin www.cnblogs.com/lj7xun/p/10983181.html