CentOS 6.3 static IP settings tutorial

Source: Internet
Author: User

CentOS 6.3 static IP settings tutorial

 

There is a computer installed with CentOS6.3 in the LAN. when the power is down or restarted, its IP address will be re-allocated by DHCP. If you want to remotely control the computer, you have to turn on the monitor to view its new IP address, this is too troublesome. So we need to set the IP address of this computer to static.

(1) Find the/etc/sysconfig/network-scripts/ifcfg-eth0 file, create one if not, the content is as follows

[Plain]View
Plaincopy

  1. Device = eth0
  2. Bootproto = static
  3. Broadcast = 192.168.0.255
  4. Onboot = Yes
  5. Ipaddr = 192.168.0.108
  6. Netmask = 255.255.255.0
  7. Gateway = 192.168.0.1
  8. Dns1 = 192.168.0.1

DEVICE = eth0 # describe the DEVICE alias corresponding to the NIC

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

ONBOOT = yes

IPADDR = 192.168.0.108 # If you set the method for obtaining the IP address from the NIC to static, this field specifies the IP address of the NIC.

NETMASK = 255.255.255.0 # network mask corresponding to the network adapter

GATEWAY = 192.168.0.1 # the IP address of the default GATEWAY, which can be found in CMD using ipconfig

DNS1 = 192.168.0.1 # address of the DNS1 server, which can be found in CMD using nslookup

 

(2) Find the/etc/sysconfig/network file. The content is as follows:

[Plain]View
Plaincopy

  1. NETWORKING = yes
  2. NETWORKING_IPV6 = no
  3. HOSTNAME = localhost. localdomain
  4. GATEWAY = 192.168.0.1

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 service programs cannot be started.

Networking_ipv6 = No

Hostname = localhost. localdomain # 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.0.1 # IP address of the default gateway

 

(3) view the/etc/resolv. conf file

[Plain]View
Plaincopy

  1. # Generated by NetworkManager
  2. Nameserver 192.168.0.1

This file does not need to be modified, it is automatically generated according to the NIC configuration file/etc/sysconfig/network-scripts/ifcfg-eth0. Even if the modification is made, the content will be washed out after the network service is restarted.

 

(4) restart the network service

[Plain]View
Plaincopy

  1. Service 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.