Set IP address for centos

Source: Internet
Author: User
Tags domain name server nameserver

/Etc/sysconfig/Network
/Etc/sysconfig/network-scripts/ifcfg-eth0
/Etc/resolv. conf
/Etc/hosts

1. centos DNS Modification

Modify the DNS configuration file of the corresponding Nic
# Vi/etc/resolv. conf
Modify the following content

Nameserver 8.8.8.8 # Google Domain Name Server
Nameserver 8.8.4.4 # Google Domain Name Server
2. centos gateway Modification
Modify the gateway configuration file of the corresponding Nic
[Root @ centos] # vi/etc/sysconfig/Network

Modify the following content
Networking = Yes (indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used, and many system servicesProgramCannot be started)
Hostname = centos (set the Host Name of the local machine. The host name set here must correspond to the host name set in/etc/hosts)
Gateway = 192.168.1.1 (set the IP address of the gateway connected to the local machine. For example, the gateway is 10.0.0.2)
3. Modify the IP address of centos

Modify the configuration file of the corresponding Nic IP Address
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Modify the following content

Device = eth0 # describe the device alias for the NIC, for example, it is eth0 in the ifcfg-eth0 File
Bootproto = static # Set the way for the NIC to obtain the IP address. The possible options are static, DHCP, or BOOTP, which respectively correspond to the IP address specified by the static state and the IP address obtained through the DHCP protocol, IP addresses obtained through the BOOTP protocol
Broadcast = 192.168.0.255 # corresponding subnet broadcast address
Hwaddr = 00: 07: E9: 05: E8: B4 # physical address of the corresponding Nic
Ipaddr = 12.168.1.2 # If you set the method for obtaining the IP address from the NIC to static, this field specifies the IP address of the NIC.
Ipv6init = No
Ipv6_autoconf = No
Netmask = 255.255.255.0 # network mask corresponding to the network adapter
Network = 192.168.1.0 # network address of the NIC
Onboot = yes # whether to set this network interface when the system starts. If it is set to yes, the device is activated when the system starts.

ifcfg-eth0
View sourceprint?
device = eth0 // device name
bootproto = static // start type DHCP | static
broadcast = 192.168.1.255 // broadcast address
hwaddr = 00: 06: 5b: Fe: DF: 7c // hardware MAC address
ipaddr = 192.168.0.2 // ip address
netmask = 255.255.255.0 // subnet mask
network = 192.168.0.0 // network address
gateway = 192.168.0.1 // gateway address
onboot = Yes // whether to start the application
type = Ethernet // network type

4. Restart the network configuration
# service network restart
or
#/etc/init. d/network restart

Related Article

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.