CentOS 6 Network Settings

Source: Internet
Author: User
Tags nameserver

Environment:

System hardware: VMware vsphere (cpu:2*4 core, memory 2G)

System version: centos-6.5-x86_64

Router Gateway: 192.168.1.1

Steps:

1. View the network MAC address
[Email protected] ~]# Cat/etc/udev/rules.d/70-persistent-net.rules

Displays the following information
# PCI Device 0x15ad:0x07b0 (VMXNET3)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "00:50:56:94:04:3c", attr{type}== "1", kernel== "eth*" , name= "Eth0"

# PCI Device 0x15ad:0x07b0 (VMXNET3)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "00:50:56:94:53:24", attr{type}== "1", kernel== "eth*" , name= "Eth1"

Eth0: Corresponding to the first card, eth1: On the second net card. Currently using Eth0 connection router, eth1 reserved (server is generally used to connect other hosts)


2. Modify the host name
[Email protected] ~]# vim/etc/sysconfig/network
  

Open the file, modify the following and save

Networking=yes #使用网络
Hostname=centos #设置主机名称

3. Modify the NIC
[Email protected] ~]# Vim/etc/sysconfig/network-scripts/ifcfg-eth0
  

Open the file, modify the following and save

Device=eth0 #对应第一张网卡
Type=ethernet
Onboot=yes #是否启动时运行
Nm_controlled=yes
Bootproto=static #使用静态IP instead of assigning IP by DHCP
Defroute=yes
Ipv4_failure_fatal=yes
Ipv6init=no
Name= "System eth0" #名称
hwaddr=00:50:56:94:04:3c #必须对应etho是的MAC地址 (/etc/udev/rules.d/70-persistent-net.rules)
Peerdns=yes
Peerroutes=yes
ipaddr=192.168.1.40 #指定本机IP地址
netmask=255.255.255.0 #指定子网掩码
gateway=192.168.1.1 #指定网关

4. Modify DNS
[Email protected] ~]# vim/etc/resolv.conf

Open the file, modify the following and save
NameServer 8.8.8.8 #GOOGLE的DNS服务器
NameServer 61.144.56.100 #指定当前城市最近的DNS服务器 (different cities, internet search)
NameServer 192.168.1.1 #指定经路由器上指定的DNS服务器

* Execute file read-only command, otherwise service restart, configuration is lost

Chattr +i/etc/resolv.conf

* Also note that between NameServer 61.144.56.100 is a space, instead of a "=" number, the equals sign configuration is wrong


5. Restart the network configuration
[[Email protected] ~] #service Network restart

  

6. Restart

[[Email protected] ~] #shutdown-R now

7. View current IP Settings

[Email protected] ~]# ifconfig

CentOS 6 Network Settings

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.