Three methods for configuring IP addresses in LINUX

Source: Internet
Author: User

In LINUX, you can configure the IP address of the NIC in command mode after the linux system is installed. The configuration file is usually/etc/sysconfig/network-scripts/ifcfg-interface-name
1. configure the nic ip address vi/etc/sysconfig/network-scripts/ifcfg-eth0 # Second NIC: vi/etc/sysconfig/network-scripts/ifcfg-eth1DEVICE = eth0 # physical device name IPADDR = 192.168.1.10 # IP address NETMASK = 255.255.255.0 # mask value NETWORK = 192.168.1.0 # network address (optional) BROADCAST = 192.168.1.255 # BROADCAST address (optional) GATEWAY = 192.168.1.1 # GATEWAY address www.2cto.com ONBOOT = yes # [yes | no] (whether to activate the device during boot) USERCTL = no # [yes | no] (whether non-root users can control the device) BOOTPROTO = static # [none | static | bootp | dhcp] (no protocol used during boot | static allocation | BOOTP protocol | DHCP protocol)
2. Configure the nic dns configuration file under/etc/resolv. conf. Vi/etc/resolv. confnameserver 202.109.14.5 # Master DNSnameserver 219.141.136.10 # After DNSsearch localdomain is configured, you must restart the network service: service network restart or/etc/init. d/network restart ------------------ [root @ sd ~] # Vi/etc/sysconfig/network-scripts/ifcfg-Wired connection _ 1 TYPE = EthernetBOOTPROTO = noneIPADDR = 192.168.0.252PREFIX = 24 GATEWAY = 192.168.0.1DNS1 = 192.168.0.1DEFROUTE = sources = yesIPV6INIT = noNAME = "connection 1 "UUID = d6e5099a-21aa-44c3-b44d-8df904faf14aONBOOT = yes ------------------------------------------------------------ 192.168.0.252 sd. jn sd [root @ sd ~] # Vi/etc/resolv. conf # Generated by NetworkManagersearch jn www.2cto.com nameserver 192.168.0.1 ------------------ 3. A single Nic is bound to two IPlinux network device configuration files stored in/etc/sysconfig/network-scripts, For the first network device Ethernet, the configuration file name is generally ifcfg-eth0. To bind one more IP address to the first network device, create a file named ifcfg-eth0: 0 in the/etc/sysconfig/network-scripts directory, as shown in the following example: DEVICE = "eth0: 0" IPADDR = "211.100.10.119" NETMASK = "255.255.255.0" ONBOOT = "yes" where DEVICE is the DEVICE name and IPADDR is the IP address of the DEVICE, NETMASK is a subnet mask, and ONBOOT indicates that it is automatically started when the system starts. If you need to bind another IP address, you only need to add one of the file name and the eth0 in the DEVICE in the file. LINUX supports up to 255 IP aliases. Configure the network environment in customized linux [1] www.2cto.com 1. Log On As the root user and run the setup command to enter the text mode setup utiliy to configure the network. Authentication Configurationfirewall configurationKeyboard configurationNetwork ConfigurationSystem servicesTimezone configurationX configuration2. If the NIC configuration does not take effect, run/etc/rc. d/init. d/network restartUse DHCP. Press the long space key to enable automatic allocation.
[2] ifconfig eth0 192.168.1.147: Set ifconfig eth0 network *** for the NIC ***. ***. ***. * ** after you set the subnet mask to use the default IP address for the broadcast address and DNS to temporarily take effect and restart or shut down, the IP address will be restored to eth0 as the network device name before modification.
[3] www.2cto.com underlying modification method 1, modify/etc/sysconfig/network-scripts/ifcfg-eth0 each attribute in this file can be modified, including IP, subnet mask, broadcast address, default Gateway 2. If the NIC configuration does not take effect, run/etc/rc. d/init. d/network restart command the setting we just made takes effect ifconfig and the displayed content lo represents that all the devices in the loop in LINUX are a file author guanhp2013

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.