How to Set Static IP in Ubuntu Ifconfig Network Configuration Tool

Source: Internet
Author: User


The network parameters of Ubuntu are stored in The file/etc/network/interfaces. dhcp is used by default. The content is as follows: # The primary network interfaceauto eth0iface eth0 inet dhcp setting static IP is as follows:
1) edit/etc/network/interfaces1.1) to block a dhcp line # The primary network interfaceauto eth0 www.2cto.com # iface eth0 inet dhcp 1.2) add parameters related to static IP # The primary network interfaceiface eth0 inet staticaddress 192.168.0.10netmask 255.255.255.0gateway 192.168.0.1 2) edit/etc/resolv. conf, set dnsnameserver 202.96.134.133nameserver 202.106.0.20 3) execute the following two commands to enable the new settings $ sudo ifdown eth0 $ sudo ifup eth0 ifconfig whether it is Linux automatic installation or our hands During installation, Linux will ask you about network problems and configure related software. The basic command used to configure the NIC is ifconfig. After executing the ifconfig command, the system will set necessary parameters in the kernel table, so that Linux will know how to communicate with the network card. The ifconfig command has two formats: ※ifconfig [interface] ※ifconfig interface [aftype] option | address... The first format of ifconfig (or the ifconfig command without any parameters) can be used to view the network configuration of the current system. After installing the system, you actually use Linux without a network adapter or network connection. However, ifconfig can be used to work in a loop so that the computer can think that it is working on the network. Run the ifconfig command. The ifconfig command without parameters can display the network interface currently started. The output result is: Running [root @ machine1/sbin] # ifconfigeth0 Link encap: ethernet Hwaddr 52: 54: AB: DD: 6F: 61 inet addr: 210.34.6.89 Bcast: Adjust Mask: Adjust bandwidth limit 128up BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1RX packets: 46299 errors: 0 dropped: 0 overruns: 0 frame: 189TX packets: 3057 errors: 0 dropped: 0 overrun S: 0 carrier: 0 collisions: 0 blocks: 100 Interrupt: 5 Base address: linked Link encap: Local Loopbackinet addr: 127.0.0.1 Mask: 255.0.0up loopback running mtu: 3924 Metric: 1RX packets: 44 errors: 0 dropped: 0 overruns: 0 frame: 0TX packets: 44 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 0 www.2cto.com -------------------------------------------------------------------- the part headed by eth0 is the local Ethernet Card configuration parameters. The device name/dev/eth0 of the nic and the MAC address of the hardware in the system are shown as 52: 54: AB: DD: 6F: 61, 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 as long as we are at/etc/rc. d/init. add: ifconfig eth0 hw ether xx: xx to the network in d/, and then restart the system. Run the ifconfig command to check the problem, we will find that the MAC address of the NIC has changed to xx: xx. The next line displays the IP address information of the local machine, including the local IP address, network broadcast address, and subnet mask. 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. xxx. xxx (IP) xx. xx. xx. xx. xx (MAC) displays the network status of the device. The MTU (maximum transmission unit) and Metric (measurement value) fields display the current m t u 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. Next, Interrupt: 5 Base address: 0xece0 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). However, most NICs currently use PnP, this requires manual configuration. If your Nic is not configured, run [root @ machine1/sbin] # ifconfig to output only the lo-led part. Lo is the look-back network interface. It can be seen from the IP address 127.0.0.1 that it represents "Local Machine ". This device always exists no matter whether the system is connected to the network. Unless you disable network support during kernel compilation, it is a special device called the return device, it is automatically configured by Linux to provide network connections. The IP address 127.0.0.1 is a special return address (the default local address). 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. (If you are interested, you can also try the actual IP address of the local machine, for example, the machine here is 210.34.6.89, or try "localhost" or "127.0.0.1" to simulate network communication. This is an outstanding advantage of Linux !) If you are only concerned about whether a device is normal, you can add the interface name [root @ machine1/sbin] # ifconfig eth0eth0 Link encap: Ethernet HWaddr 52: 54: AB: DD: 6F: 61 inet addr: 210.34.6.89 Bcast: Adjust Mask: Adjust bandwidth limit 128up broadcast running multicast mtu: 1500 Metric: 1RX packets: 50568 errors: 0 dropped: 0 overruns: 0 frame: TX 198packets: 3200 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 100 www.2cto.com Interrupt: 5 Base Address: 0xece0 indicates that the eth0 device is working properly. Sometimes you need to configure multiple IP addresses for a device interface by using the device alias. For example, the eth0 device may have eth0, eth0: 0, eth0: 1 .... multiple aliases, each of which can have an independent IP Address: ifconfig eth0 210.34.6.89 netmask bandwidth 255.255.128 broadcast 210.34.6.127 ifconfig eth0: 0 210.34.6.88 netmask bandwidth 255.255.255.128 broadcast protocol, both 210.34.6.89 and 210.34.6.88 are bound to the eth0 device and use the same network device and different IP addresses. If you want to suspend the work of a network interface, using the down parameter: ifconfig eth0 down will cancel the eth0 network interface. There is a parameter up, but it is never used because it is the default value. If we use the ifconfig command with parameters, You can manually set the NIC configuration parameters. Valid ifconfig command parameters and their meanings are as follows: (you can enable or cancel the feature corresponding to the option. You only need to add a break (-) before the option name.): Interface network device name, for example, eth0 indicates the first Nic of the local machine. Up indicates that the interface is in the "up" status, that is, the IP layer can access it. This option is used when an address is given on the command line. If this interface has been temporarily canceled by the "down" option (the flag corresponding to this option is up running), it can also be used to re-enable an interface. The down flag indicates that the interface is in the "down" status, that is, the IP layer cannot access it. This option effectively disables the IP communication flow interface. Note that it does not automatically delete all routing information that uses this interface. If you permanently cancel an interface, delete these route entries and provide alternate routes whenever possible. Www.2cto.com netmask is assigned a subnet mask for the interface. Either give a 32-bit hexadecimal number whose front is 0x, or use a four-digit number that is only applicable to the two hosts. This option must be configured for the SLIP and PLIP interfaces. Address: sets the IP address of the specified interface device. Dstaddr adderss sets a remote IP address for PPP. This keyword can be replaced by pointopoint. Irqaddress sets the interrupt line used by the specified interface device. Pointtopoint address this option applies to point-to-point connections of only two hosts. For the SLIP and PLIP interfaces, this option must be configured (if a point-to-point address has been set, ifconfig will display the POINTTPOINT mark ). The broadcast address is generally derived from the network number and is obtained by setting all the bits of the host part. Some I P adopt different solutions: This option can be applied to some strange environments (ifconfig will display a BROADCAST flag if a BROADCAST address has been set ). Hw class addr sets the MAC address of the specified interface device. The keyword must be followed by the hardware name or equivalent ASCII code. Currently, the Supported Hardware classes include ether, ax25, ARCnet, and netrom. Metric number this option can be used to assign a metric value to the route table created by the interface. The routing information protocol (RIP) uses metric values to construct a network routing table. The default measurement value used by ifconfig is 0. If you do not run the RIP program, you do not need to use this option. If you want to run the RIP program, try not to change the default measurement value. Mtu bytes this option is used to set the maximum number of transmission units, that is, the maximum number of bytes that the interface can process at a time. For Ethernet interfaces, MTU is set to 1500 bytes by default; for SLIP interfaces, MTU is set to 296 bytes. Arp labels are used for broadcast networks such as Ethernet or packet broadcast. It enables ARP to protect the physical addresses of hosts on the network. For the Broadcast Network, the default value is "on ). Promisc places the interface in promiscuous (chaotic) mode. In the broadcast network, this interface will receive all data packets, regardless of whether the target is another host or not. This option allows you to analyze network communication by using the packet filter and the so-called Ethernet peek technology. In general, this is quite useful for finding out the culprit of network faults. On the other hand, if someone deliberately attacks your network, you can also browse the s communication data to obtain the password and destroy your network. An important guarantee is to prevent anyone from connecting their computers to your Ethernet. Another option is used to protect the security of some authentication protocols, such as Kerberos or SRA logon Suite (the option corresponds to PROMISC ). Www.2cto.com traIlers enable or disable the tracker. Currently, this function cannot be implemented in some Linux systems. The allmulti multicast address broadcasts data to a group of hosts on different sub-networks. The multicast address has not yet received Kernel support (this option corresponds to ALLMULTI). txqueuelen len sets the length of the sending queue for the specified interface device. A large number of parameters can be used to configure the NIC. The following is an example of using the ifconfig command on this computer: ifconfig eth0 210.34.6.89 netmask 255.255.255.128 broadcast 210.34.6.127 using this command sets the IP address, network mask, and local broadcast address of the network adapter eth0. The same method can be used to configure 11 lingxian, such as eth1 and eth2.

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.