CentOS Network Settings

Source: Internet
Author: User
Tags centos

CentOS Modify IP Address

# ifconfig eth0 192.168.1.80

This will change the IP address to 192.168.1.80(if you find the network, then you may need to change the gateway and DNS, the following will be mentioned), but when you restart the system or network card, it will return to the original address, This modification only applies to the need for temporary IP modification.

To make a permanent change, you need to modify the /etc/sysconfig/network-scripts/ifcfg-eth0 file, the main content of which is as follows (the items you don't have in your file can be added manually):

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

Device=eth0 #描述网卡对应的设备别名

bootproto=static #设置网卡获得ip地址的方式, options can be static,dhcp or BOOTP

broadcast=192.168.1.255 #对应的子网广播地址

hwaddr=00:07:e9:05:e8:b4 #对应的网卡物理地址

ipaddr=12.168.1.80 #只有网卡设置成static时, this field is required

netmask=255.255.255.0 #网卡对应的网络掩码

network=192.168.1.0 #网卡对应的网络地址, which is the network segment that belongs to

Onboot=yes #系统启动时是否设置此网络接口, when set to Yes, this device is activated when the system starts

CentOS Modify Gateway

# route add default GW 192.168.1.1 dev eth0

This will change the gateway to 192.168.1.1 , this modification is only temporary, when you restart the system or network card, or will return to the original gateway.

To make a permanent change, you need to modify the /etc/sysconfig/network file, the main content of which is as follows (the items you don't have in your file can be added manually):

# vi/etc/sysconfig/network

Networking=yes #表示系统是否使用网络, generally set to Yes. If set to no, the network cannot be used.

Hostname=centos #设置本机的主机名, the host name set here corresponds to the hostname set in/etc/hosts

gateway=192.168.1.1 #设置本机连接的网关的IP地址.

The above file is modified to restart the NIC will not take effect:# Service Network restart ********

CentOS Modify DNS

The above are all modified, when you ping a domain name is Ken can not pass, but ping corresponding IP address is pass, at this time we need to modify DNS. Modify DNS to /etc/resolv.conf this file by modifying:

# vi/etc/resolv.conf

nameserver 8.8.8.8 #google域名服务器 nameserver8.8.4.4 #google域名服务器

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

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.