Centos網路設定方法(手動設定,自動擷取)

來源:互聯網
上載者:User

標籤:

一、自動擷取IP的方法:

1、/ etc/sysconfig/network-scripts/ifcfg-eth0

[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 

DEVICE=eth0    //由eth0來啟動

HWADDR=00:0C:29:40:EC:61    //MAC地址

TYPE=Ethernet

UUID=9c6a7fc6-66ce-406d-993f-6ab26a730e72

ONBOOT=yes         //系統啟動時網路介面是否有效;預設NO

NM_CONTROLLED=yes

BOOTPROTO=dhcp  //擷取IP方式,static是固定IP,none是手動,dhcp是自動擷取

2、/etc/sysconfig/network

[[email protected] ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=smbserver

3、/etc/hosts

[[email protected] ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

4、/etc/resolv.conf

[[email protected] ~]# cat /etc/resolv.conf 

# Generated by NetworkManager

nameserver 202.96.128.86

nameserver 8.8.8.8  //DNS服務地址

二、手動設定IP、DNS

手動設定IP、DNS只需要修改三個檔案就可以了

1、/etc/sysconfig/network

[[email protected] network-scripts]$ cat /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=yes

#HOSTNAME=localhost.localdomain        //為什麼要把主機名稱注釋掉,一般先解析主機名稱或者網域名稱,再解析DNS

GATEWAY=192.168.1.1                            //加上網關

2、/etc/sysconfig/network-scripts/ifcfg-eth0

[[email protected] network-scripts]$ cat ifcfg-eth0

# Marvell Technology Group Ltd. 88E8039 PCI-E Fast Ethernet Controller

DEVICE=eth0

BOOTPROTO=none                         //啟動為手動

BROADCAST=192.168.1.255

HWADDR=00:16:D3:A2:F6:09

IPADDR=192.168.1.108                   //設定的IP

NETMASK=255.255.255.0                //子網路遮罩

NETWORK=192.168.1.0

IPV6INIT=yes

IPV6_AUTOCONF=yes

ONBOOT=yes

TYPE=Ethernet                                //網路類型

3、/etc/resolv.conf

[[email protected] network-scripts]$ cat /etc/resolv.conf

#; generated by /sbin/dhclient-script

#nameserver 192.168.1.1

#search localdomain

nameserver 116.228.111.118             //加上主DNS

nameserver 180.168.255.18              //加上次DNS

Centos網路設定方法(手動設定,自動擷取)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.