IFCONFIG Network Configuration Tool Detailed Details

xiaoxiao2021-03-06  85

Whether it is Linux automatic installation or we hand-installed, Linux will ask you questions about the network and configure the relevant software. This basic command for configuring the NIC is ifconfig.

After executing the ifconfig command, the system will set the necessary parameters in the kernel table, so that Linux knows how to communicate with the network card on the network. The ifconfig command has the following two formats:

※ ifconfig [interface]

※ ifconfig interface [AfType] Option | Address ...

The first format of Ifconfig (or ifconfig commands without any parameters) can be used to view the network configuration of the current system.

After just installing the system, it is actually using Linux without a NIC or a network connection, but you can use the wreath mode by IFConfig, so that the computer considers yourself on the network.

Now we run the ifconfig command, the ifconfig command without the parameters can display the currently started network interface, and its output is:

-------------------------------------------------- ---------

[root @ machine1 / sbin] #ifconfig

Eth0 Link ENCAP: Ethernet Hwaddr 52: 54: AB: DD: 6F: 61

inet Addr: 210.34.6.89 Bcast: 210.34.6.127 Mask: 255.255.255.128

Up Broadcast Running Multicast MUNTU: 1500 metric: 1

RX Packets: 46299 Errors: 0 Dropped: 0 overruns: 0 frame: 189

TX Packets: 3057 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0

Collisions: 0 TXQuelelen: 100

Interrupt: 5 Base Address: 0xece0

Lo Link Encap: Local Loopback

INET Addr: 127.0.0.1 Mask: 255.0.0.0

Up loopback running mtu: 3924 metric: 1

RX Packets: 44 Errors: 0 Dropped: 0 overruns: 0 Frame: 0

TX Packets: 44 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0

Collisions: 0 TXQuelelen: 0

-------------------------------------------------- ------------------

Among them, the part of ETH0 is the local Ethernet card configuration parameter, which shows the device name / dev / eth0 and hardware MAC address 52: 54: AB: DD: 6F: 61, MAC address is the manufacturer fixed The only address of each NIC has.

However, we can manually change the MAC address of the NIC, as long as we join the NETWORK in /etc/rc.d/init.d/:

Ifconfig eth0 HW Ether xx: xx: xx: xx: xx: xx

Then restart, then use the ifconfig command to view it, we will find that the MAC address of the network card has become XX: XX: XX: XX: XX: XX. Next line shows the IP address information of this unit, which is the IP address, network broadcast address, and subnet mask of this unit. It must be confirmed that this information is correct, otherwise the Linux server cannot establish a connection with other network devices. We can also manually implement the bundle of IP and MAC addresses.

Arp -i eth0 -s xxx.xxx.xxx.xxx (ip) xx.xx.xx.xx.xx (Mac)

Next, it is displayed in the network status of the device. The MTU (Maximum Transmission Unit) and the Metric field displays the value of the current M t U and metrics of the interface. Follow the conventions, the metric is used for some operating systems for calculating the cost of a route. Then display the network statistics of the interface communication. The RX and TX indicate the received and transmitted packets, respectively. If your network card has been configured but can also communicate with other devices, the cause of the failure can be simply analyzed from the display data from RX and TX. In this case, if you see the count of the package (Packets) of the package (Packets), it is possible that the system's IP address appears chaos; if you see a large number of errors (ERRORS) and collion (Collisions), Then this is likely that the network's transmission medium has problems, such as the network cable is not blocked or HUB damage. Then, the following INTERRUPT: 5 Base Address: 0xeCE0 displays the interrupt number and port number of the NIC, which is two very important hardware configuration information. If your network card is PCI, then Linux may automatically configure this information when boot (it is also very likely to manually configure), but most of the network cards are PNP, this requires us to manually configure it. . If your network card is not configured, then run: [root @ machine1 / sbin] #ifconfig

The system will only output part of LO. LO is the Look-Back network interface, it can be seen from the IP address 127.0.0.1, it represents "native". Regardless of whether the system is access to the network, this device always exists unless you ban network support when you compile, this is a special device called a return device, which is automatically configured by Linux to provide a network's own connection. IP address 127.0.0.1 is a special return address (that is, the default native address), you can test IP addresses 127.0.0.1 with Telnet on your own system. If you have an inetd process, you will get a login prompt from your own machine. Linux can communicate between processes and simulation networks using this feature. (If you are interested, you can also try this actual IP address of this machine. If the machine here is 210.34.6.89, or try "localhost", "127.0.1", which can also simulate network communication. This is Linux a very Highlighting the advantages!) If you just care about whether a device is normal, you can add the interface name after IFConfig:

[Root @ machine1 / sbin] # ifconfig eth0 eth0 Link encap: Ethernet HWaddr 52: 54: AB: DD: 6F: 61 inet addr: 210.34.6.89 Bcast: 210.34.6.127 Mask: 255.255.255.128 UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1 RX Packets: 0 Dropped: 0 Overruns: 0 Frame: 198 TX Packets: 3200 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0 Collisions: 0 TXQUEELEN: 100 Interrupt: 5 Base Address: 0xece0

Indicates that the ETH0 device has been working properly.

Sometimes you need to configure multiple IP addresses for a device interface, and the method is to use the device alias, for example, the Eth0 device can have Eth0, Eth0: 0, Eth0: 1 .... Multiple individual names, each can have an independent IP address:

ifconfig eth0 210.34.6.89 netmask 255.255.255.128 broadcast 210.34.6.127 ifconfig eth0: 0 210.34.6.88 netmask 255.255.255.128 broadcast 210.34.6.127 Thus, 210.34.6.89 and 210.34.6.88 will be bound to eth0 device using the same network Equipment, different IP addresses. If you want to suspend a work of a network interface, use the Down parameter:

IFConfig Eth0 Down

The ETH0 network interface will be canceled. In response, there is a parameter UP, but since it is default, it is never used. If we use the IFConfig command with parameters, you can manually set the network card configuration parameters. Effective ifconfig command parameters and its meaning are (the features corresponding to the option can be opened, and you can add a dash (-) only before the option name):

Interface network device name, such as Eth0 means the first network card of the unit. The UP flag interface is in the "UP" state, that is, the IP layer can be accessed. This option is used to give an address on the command line. If this interface has been temporarily canceled by the "Down" option (the tag corresponding to this option is UP Running), it is also possible to re-enable an interface. The DOWN label sign is in the "Down" state, that is, the IP layer cannot be accessed. This option effectively ban IP communication flows from this interface. Note that it does not automatically delete all routing information using the interface. If an interface is permanently canceled, these routing entries should be deleted, and in the case of possible, the standby route is available. The Netmask is divided into subnet mask for interfaces. Either a 32-bit sixteen-binary number of the 0x in front, either adopting the four-segment number used for only two hosts. This option is required for SLIP and PLIP interfaces. Address Sets the IP address of the specified interface device. DSTADDR adderss set remote IP addresses for PPP, this keyword can be replaced with Pointopoint. IrqAddress settings the interrupt line used by the specified interface device. PointTopoint Address This option is used to only relate to the point-to-point link for both hosts. For SLIP and PLIP interfaces, this option is necessary (if a point-to-point address has been set, ifconfig will display the PoinTPoint tag). The Broadcast Address broadcast address is typically from the network number, and all of the host part is set. Some options are different: this option can be applied to some strange environments (if the webfig will display a Broadcast tag if the broadcast address has been set. HW Class Addr Sets the MAC address of the specified interface device, and you must follow the hardware name or equivalent ASCII code with the equivalent. Currently supported hardware classes include Ether, AX25, ARCNET and NETROM. Metric Number This option can be used to assign metrics for routing tables created for interfaces. Routing Information Protocol (RIP) uses metrics to build network routing tables. The default metric used by ifconfig is 0. If you don't run the RIP program, you don't have to use this option. If you want to run the RIP program, try not to change this default metric. MTU BYTES This option is used to set the maximum transmission unit, which is the maximum number of bytes that can be processed at once. For Ethernet interfaces, the default setting of the MTU is 1,500 bytes; 296 bytes are for SLIP interfaces. ARP This option is dedicated to a broadcast network such as Ethernet or package broadcast. It enables ARP (address resolution protocol) to protect the physical address of each host on the network. For the broadcast network, the default setting is "ON". Promisc plans the interface into the Promiscuous mode. In the broadcast network, this will cause the interface to receive all the packets, regardless of the other host. This option allows network communication to analyze network communication with packet filters and so-called Ethernet peeping techniques. Typically, this is quite useful for the Yuan's fierce who takes out the network fault. On the other hand, if someone deliberately attacks your network, you can also browse to S communication data, and then get your password, and destroy your network. An important guarantee measures are to eliminate anyone to access their computer into your Ethernet.

Another option is used to protect the security of certain authentication protocols, such as Kerberos or SRA login kits (the tag corresponding to this option is Promisc). Trailers open or close the tracker. This feature cannot be implemented in some Linux systems. AllMulti multicast addresses are broadcast data to a group of hosts that are not in the same subnet. The multicast address has not yet obtained kernel support (the tag corresponding to this option is allMulti) TXQuelelen LEN Set the transmit queue length of the specified interface device. It can be seen that there is a large number of parameters available for configuring a network card, the following is an instance of using ifconfig commands on this computer: ----------------------- -------------------------------------------------- ----- ifconfig eth0 210.34.6.89 Netmask 255.255.255.128 Broadcast 210.34.6.127 -------------------------------------------------------------------------------------------------------------- --------------------------------------------- This command role Is setting the IP address of the NIC ETH0, the network mask, and the local broadcast address of the network. The same way can be used to configure Eth1, Eth2, etc., usually NetMask and Broadcast as long as one is set.

转载请注明原文地址:https://www.9cbs.com/read-107823.html

New Post(0)