CentOS Setup Network (Modify ip& Modify Gateway & Modify DNS)

Source: Internet
Author: User
Tags nameserver

Excerpt from: www.cnblogs.com/visi_zhangyang/articles/2429185.html

CentOS Modify IP address

# ifconfig Eth0 192.168.1.80

This will change the IP address to 192.168.1.80(if not found on the network, then you may need to change the gateway and DNS, will be mentioned later), but when you restart the system or network card, will still change back to the original address, This modification applies only to temporary IP modifications. To make permanent changes, you need to modify /etc/sysconfig/network-scripts/ifcfg-eth0 This file, the main content of this file (you do not have the file, you can manually add):

# 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 #网卡对应的网络地址, the network segment that belongs to

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

CentOS Modify Gateway

# route add default GW 192.168.1.1 Dev eth0

This changes the gateway to 192.168.1.1 , which is only temporary, when you restart the system or network card, it will be back to the original gateway. To make permanent changes, you need to modify /etc/sysconfig/network This file, the main content of this file (you do not have the file, you can manually add):

# vi/etc/sysconfig/network

Networking=yes #表示系统是否使用网络, generally set to Yes. If set to No, the network is not available.

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

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

After modifying the above file to restart the network card will not take effect:# Service Network restart ********

CentOS Modify DNS

After the above are modified, when you ping a domain is Ken can not pass, but the ping corresponding IP address is the same, then we need to modify DNS. Modify the DNS to /etc/resolv.conf this file by modifying :

# vi/etc/resolv.conf

NameServer 8.8.8.8 #google域名服务器 nameserver 8.8.4.4 #google域名服务器

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

If the CentOS system is built on top of the virtual machine, select the ' Bridge adapter ' connection when setting up the virtual machine's network.

CentOS Setup Network (Modify ip& Modify Gateway & Modify DNS)

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.