CentOS sets the network (modify IP & amp; Modify gateway & amp; Modify DNS), and centos network modifies ip

Source: Internet
Author: User
Tags domain name server nameserver

CentOS sets the network (modify IP address & modify gateway & modify DNS), and centos network modifies ip Address

CentOS IP address Modification

# Ifconfig eth0 192.168.1.80

In this way, the IP address is changed192.168.1.80(If you find that the network is no longer available, you may need to change the gateway and DNS as mentioned later), but after you restart the system or network adapter, it will still change back to the original address. This modification method only applies to temporary IP address modification. To make a permanent modification, you must modify/Etc/sysconfig/network-scripts/ifcfg-eth0The main content of this file is as follows (you can manually add items not in your file ):

# Vi/etc/sysconfig/network-scripts/ifcfg-eth0

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

BOOTPROTO = static # Set the way for the NIC to obtain the IP address. The options can be static, dhcp, or bootp.

BROADCAST = 192.168.1.255 # corresponding subnet BROADCAST address

HWADDR = 00: 07: E9: 05: E8: B4 # physical address of the corresponding Nic

IPADDR = 12.168.1.80 # This field is required only when the NIC is set to static.

NETMASK = 255.255.255.0 # network mask corresponding to the network adapter

NETWORK = 192.168.1.0 # The NETWORK address corresponding to the NIC, that is, the NETWORK segment to which the ENI belongs

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.

 

 

CentOS gateway Modification

# Route add default gw 192.168.1.1 dev eth0

In this way, the gateway is changed192.168.1.1This modification is temporary. After you restart the system or network card, it will change back to the original gateway. To make a permanent modification, you must modify/Etc/sysconfig/networkThe main content of this file is as follows (you can manually add items not in your file ):

# Vi/etc/sysconfig/network

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.

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.

* ********* After the above files are modified, You need to restart the NIC to take effect:# Service network restart ********

CentOS DNS Modification

After all the above changes, when you ping a domain name, you will be unable to get through, but ping the corresponding IP address is the same, then we need to modify the DNS. Modify DNS by modifying/Etc/resolv. confThis file:

# Vi/etc/resolv. conf

Nameserver 8.8.8.8 # google Domain Name Server nameserver 8.8.4.4 # google Domain Name Server

Through all the above settings, the system should be able to access the Internet.

If the centos system is built on a virtual machine, select the 'Bridge adapt' connection when setting the network of the virtual machine.

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.