Ipconfig command and ifconfig command usage introduction, ipconfigifconfig

Source: Internet
Author: User
Tags dns troubleshooting

Ipconfig command and ifconfig command usage introduction, ipconfigifconfig

1. ipconfig: The ipconfig utility in Windows (winipcfg on the graphic user interface in Windows 95/98) can be used to display the current TCP/IP configuration setting value. This information is generally used to check whether the manually configured TCP/IP settings are correct. Main options:

/All: displays the complete TCP/IP configuration information for all adapters. Ipconfig can display the added information (such as IP addresses) configured for the DNS and WINS servers and the physical address (MAC) built in the local Nic ). If the IP address is rented from the DHCP server, ipconfig displays the IP address of the DHCP server and the expected expiration date of the lease address. Without the/all parameter, ipconfig only displays the IP address, subnet mask, and default gateway values of each adapter. An adapter can represent a physical interface (such as a network adapter installed) or a logical interface (such as a dial-up connection ).

/Renew [adapter]: Update DHCP configurations for all adapters (if no Adapter is specified) or specific adapters (if adapter parameters are included. This parameter is only available on computers with NICs configured to automatically obtain IP addresses. To specify an adapter name, type the name of the adapter displayed by using the ipconfig command without parameters. Note that in most cases, the NIC will be re-assigned the same IP address as previously assigned.

/Release [adapter]: Send the dhcp release message to the DHCP server to release all the adapters (if no Adapter is specified) or specific adapters (if the adapter parameter is included) and discard the IP Address Configuration. This parameter can disable the TCP/IP of the adapter configured to automatically obtain the IP address.

/Flushdns: clears the content cached by the DNS customer parser. If necessary, you can use this process to discard negative cache records and any other dynamically added records from the Cache during DNS troubleshooting.

/Displaydns: displays the content cached by the DNS customer parser, including records pre-loaded from the local host file and any resource records recently obtained by querying the name parsed by the computer. DNS Customer Service uses this information to quickly resolve frequently-queried names before querying the configured DNS server.

/Registerdns: refresh all DHCP leases and re-register the DNS name. You can use this parameter to troubleshoot failed DNS name registration or solve the dynamic update problem between the customer and the DNS server, without restarting the customer's computer. The DNS settings in the TCP/IP protocol advanced attribute can determine which names are registered in the DNS.

/Showclassid [adapter]: displays the DHCP category ID of the specified adapter. To view the DHCP category IDs of all adapters, use the asterisk (*) wildcard instead of the Adapter. This parameter is only available on computers with NICs configured to automatically obtain IP addresses.

/Setclassid Adapter [ClassID]: Modify the DHCP category ID of a specific Adapter. To set DHCP category IDs for all adapters, use the asterisk (*) wildcard instead of the Adapter. This parameter is only available on computers with NICs configured to automatically obtain IP addresses. If no DHCP category ID is specified, the current category ID is deleted.

Example:

> Ipconfig... display information

> Ipconfig/all... displays details

> Ipconfig/renew... update all adapters

> Ipconfig/renew EL *... update all connections whose names start with EL.

> Ipconfig/release * Con *... release all matching connections, such as "Local Area Connection 1" or "Local Area Connection 2"

> Ipconfig/allcompartments... displays information about all segments.

> Ipconfig/allcompartments/all... displays detailed information about all segments.

2. ifconfig: The program in Linux is ifconfig. Ifconfig is used to view, configure, enable, or disable network interfaces in the kernel. This tool is very common and is used to set necessary network interface parameters during system boot. You can use this tool to temporarily configure the IP address, mask, broadcast address, and gateway of the NIC. You can also write it into a file (such as/etc/rc. d/rc. local). After the system boots, it will read the file and set an IP address for the NIC.

(1) view the network interface status: ifconfig outputs the status of the currently activated network interface if no parameters are attached. If you want to know all the network interfaces of the host, run ifconfig-a. If you want to view a port, such as the eth0 status, run ifconfig eth0.

[Python] view plaincopy

[Jackzhou @ localhost ~] $ Ifconfig

Eth0Linkencap: EthernetHWaddr00: 0C: 29: D8: 45: 30

Inetaddr: 192.168.0.115Bcast: 192.168.0.255Mask: 255.255.255.0

Inet6addr: fe80: 20c: 29ff: fed8: 4530/64 Scope: Link

UPBROADCASTRUNNINGMULTICASTMTU: 1500 Metric: 1

RXpackets: 14865 errors: 0 dropped: 0 overruns: 0 frame: 0

TXpackets: 4942 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 FIG: 1000

RXbytes: 3142109 (2.9MiB) TXbytes: 652835 (637.5KiB)

Interrupt: 19 Baseaddress: 0x2000

LoLinkencap: LocalLoopback

Inetaddr: 127.0.0.1Mask: 255.0.0.0

Inet6addr ::: 1/128 Scope: Host

UPLOOPBACKRUNNINGMTU: 16436 Metric: 1

RXpackets: 12 errors: 0 dropped: 0 overruns: 0 frame: 0

TXpackets: 12 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 txqueuelen: 0

RXbytes: 720 (720 bytes B) TXbytes: (Bytes B)

Eth0 indicates the first network card. HWaddr indicates the physical address of the network card. You can see that the physical address (MAC address) of this network card is 00: 0C: 29: D8: 45: 30. The MAC address is determined by the manufacturer. Each network card has a unique address. However, you can manually change the MAC address of the NIC by adding the following to the/etc/rc. d/init. d/network file:

Ifconfig eth0 hw ether xx: xx

Then restart and run the ifconfig command to check whether the MAC address of the NIC has changed to xx: xx. Inet addr is used to indicate the IPv4 address of the NIC. the IP address of the NIC is 192.168.0.115, the broadcast address is Bcast: 192.168.0.255, And the Mask address is Mask: 255.255.255.0. Make sure that the information is correct. Otherwise, the Linux server cannot establish a connection with other network devices. We can also manually bind the IP address to the Mac address. The command is:

Arp-I eth0-s xxx. xxx (IP) xx. xx (MAC)

The following figure shows the network status of the device. UP indicates that the NIC is enabled, RUNNING indicates that the NIC is connected, and MULTICAST indicates that MULTICAST is supported. The MTU (maximum transmission unit) and Metric (measurement value) fields display the current MTU and measurement value of this interface. By convention, the measurement value is used by some operating systems to calculate the cost of a route. Then, the network statistics of interface communication are displayed. RX and TX indicate the received and transmitted packets respectively. If your network card has been configured but still cannot communicate with other devices, you can analyze the fault cause from the display data of RX and TX. In this case, if you see an increase in the number of packets received and transferred (packets), the system IP address may be in disorder; if you see a large number of errors (errors) collisions may cause problems with the network transmission media, such as network cable failure or hub damage. Collisions indicates the network signal collision, and txqueuelen indicates the length of the transmission buffer.

The following Interrupt: 19 Base address: 0x2000 displays the NIC Interrupt call number and port number, which are two important hardware configurations. If your Nic is PCI, Linux may automatically configure this information during boot (or you may manually configure it ). If the NIC is PnP, ifconfig is usually used for manual configuration.

Lo indicates the host's loopback address. This is generally used to test a network program, but does not want users on the LAN or Internet to view it, you can only run and view the network interfaces on this host. For example, if you specify the httpd address of the Apache server to the loopback address, enter 127.0.0.1 in the browser to view the WEB site you set up. But you can only see it, and other hosts or users in the LAN cannot know it. You can use telnet to test the IP address 127.0.0.1 on your system. If the inetd process is running, you will get a logon prompt from your machine. Linux can use this feature to communicate between processes and simulation networks.

(2) configure the network interface: ifconfig can be used to configure the IP address, mask, gateway, and physical address of the network interface. It is worth noting that ifconfig is used to specify an IP address for the NIC, which is only used to debug the network, and does not change the NIC configuration file of the system. If you want to fix the IP address of the network interface, there are currently three methods: one is to modify the IP address through a dedicated tool for each release and version; the second is to directly modify the configuration file of the network interface. The third is to modify a specific file and add the ifconfig command to specify the IP address of the NIC, for example, in RedHat or Fedora, write the configuration command of ifconfig to/etc/rc. d/rc. local file. The most common parameter format when configuring network ports in ifconfig is:

Ifconfig network port IP address hw MAC address netmask mask address broadcast address [up/down]

Instance 1: for example, we use ifconfig to debug the address of the eth0 Nic.

[Python] view plaincopy

[Root @ linuxchao ~] # Ifconfigeth0down

[Root @ linuxchao ~] # Ifconfigeth0192.168.1.99broadcast192.168.1.255netmask1_255.255.0

[Root @ linuxchao ~] # Ifconfigeth0up

[Root @ linuxchao ~] # Ifconfigeth0

Eth0Linkencap: EthernetHWaddr00: 03: 0D: 27: 86: 41

Inetaddr: 192.168.1.99Bcast: 192.168.1.255Mask: 255.255.255.0

Inet6addr: fe80: 203: dff: fe27: 8641/64 Scope: Link

UPBROADCASTRUNNINGMULTICASTMTU: 1500 Metric: 1

RXpackets: 618 errors: 0 dropped: 0 overruns: 0 frame: 0

TXpackets: 676 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 FIG: 1000

RXbytes: 491238 (479.7KiB) TXbytes: 86286 (84.2KiB)

Interrupt: 5 Baseaddress: 0x8c00

Example 2: In this example, we need to learn how to set the network IP address and the physical address (MAC address) of the NIC ). For example, we set the IP address, network mask, broadcast address, physical address of the network adapter eth1 and activate it.

[Python] view plaincopy

[Root @ linuxchao ~] # Ifconfigeth1194251.252hwether04: 64: 03: 00: 12: 51netmask255. 255.255.0broadcast192.168.1.255up

You can take the following two steps:

[Python] view plaincopy

[Root @ linuxchao ~] # Ifconfigeth1hwether04: 64: 03: 00: 12: 51

[Root @ linuxchao ~] # Ifconfigeth1194251.252netmask?255.0broadcast192.168.1.255up

The hw is followed by the network interface type. ether indicates Ethernet and supports ax25, ARCnet, and netrom. For more information, see man ifconfig.

(3) Configure Virtual Network Interfaces: Sometimes we need to configure virtual network interfaces to meet different needs. For example, we use different IP addresses to set up and run multiple httpd servers, you need to use a virtual address to save the same IP address. If you want to open two httpd servers, you must specify the port number. A virtual network interface is used to specify multiple IP addresses for a network interface. The virtual interfaces are eth0: 0, eth0: 1, eth0: 2,..., and eth0: N. Of course, you must specify multiple IP addresses for eth1, that is, eth1: 0, eth1: 1, eth1: 2,..., and so on. In fact, if you use ifconfig to configure multiple IP addresses for a nic, you can use the ifconfig usage we mentioned earlier. This is relatively simple. See the following example:

[Python] view plaincopy

[Root @ linuxchao ~] # Ifconfigeth1: 0192.168.1.251hwether04: 64: 03: 00: 12: 51netmask255. 255.255.0broadcast192.168.1.255up

Or two steps.

[Python] view plaincopy

[Root @ linuxchao ~] # Ifconfigeth1hwether04: 64: 03: 00: 12: 51

[Root @ linuxchao ~] # Ifconfigeth1194251.251netmask?255.0broadcast192.168.1.255up

Note: When specifying an IP address, you must specify a different physical address for each virtual network card. In Redhat/Fedora or a system similar to Redhat/Fedora, you can configure the network IP address, broadcast address, mask address, physical address, and activate the network interface in one sentence, write/etc/rc. d/rc. local. For example:

Ifconfig eth1: 0 192.168.1.250 hw ether 00: 11: 00: 33: 11: 44 netmask 255.255.255.0 broadcast 192.168.1.255 up

Ifconfig eth1: 1 192.168.1.249 hw ether 00: 11: 00: 33: 11: 55 netmask 255.255.255.0 broadcast 192.168.1.255 up

The above is the network interface for eth1, and two virtual interfaces are set. Each interface has its own physical address, IP address, and so on.

(4) activating and terminating the network interface connection: Use the ifconfig command to activate and terminate the network interface, connect to the network interface, and add the down or up parameter, you can disable or activate the corresponding network interface. You can also use the ifup and ifdown tools.

[Python] view plaincopy

[Root @ linuxchao ~] # Ifconfigeth0down

[Root @ linuxchao ~] # Ifconfigeth0up

[Root @ linuxchao ~] # Ifupeth0

[Root @ linuxchao ~] # Ifdowneth0

This is also true for activating other network interfaces, such as ppp0 and wlan0, but only valid for the NIC of the specified IP address.

Note that the IP address automatically assigned by DHCP must be activated by the network tools provided by each release. Of course, you must install the dhcp client. We should understand this. For example, Redhat/Fedora:

[Root @ linuxchao ~] #/Etc/init. d/network start

Slackware release;

[Root @ linuxchao ~] #/Etc/rc. d/rc. inet1

Note that the ifconfig tool is still widely used, but is regarded as an outdated tool. Currently, more powerful ip tools can replace ifconfig, which are included in most Linux distributions. You can use the ip addr and ip link commands to replace ifconfig, and use the ip-s link command for packet information statistics.

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.