CentOS6上配置靜態IP地址
問題預設情況下,CentOS 6安裝沒有網路接入相關配置,需要你對網路介面進行配置。解決方案查看預設介面配置介面相關配置儲存在/etc/sysconfig/network-scripts目錄下,下面顯示的是預設的介面配置。[plain]view plaincopy
- [root@CentOS65network-scripts]#more/etc/sysconfig/network-scripts/ifcfg-eth0
- DEVICE=eth0
- HWADDR=00:0C:29:C1:48:03
- TYPE=Ethernet
- UUID=b2bbb718-caa6-46c3-ae12-587cbedfd5fa
- ONBOOT=no
- NM_CONTROLLED=yes
- BOOTPROTO=dhcp
配置介面靜態地址[plain]view plaincopy
- #vi/etc/sysconfig/network-scripts/ifcfg-eth0
- DEVICE="eth0"
- NM_CONTROLLED="yes"
- ONBOOT=yes
- HWADDR=A4:BA:DB:37:F1:04
- TYPE=Ethernet
- BOOTPROTO=static
- UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
- IPADDR=10.220.33.108
- NETMASK=255.255.255.0
配置網關[plain]view plaincopy
- #vi/etc/sysconfig/network
- NETWORKING=yes
- HOSTNAME=centos6
- GATEWAY=10.220.33.1
重啟網路介面[plain]view plaincopy
- [root@CentOS65network-scripts]#/etc/rc.d/init.d/networkrestart
- Shuttingdowninterfaceeth0:[OK]
- Shuttingdownloopbackinterface:[OK]
- Bringinguploopbackinterface:[OK]
- Bringingupinterfaceeth0:Determiningifipaddress10.220.33.108isalreadyinusefordeviceeth0...
- [OK]
配置DNS伺服器[plain]view plaincopy
- #vi/etc/resolv.conf
- nameserverx.x.x.x#Replacewithyournameserverip
- nameservery.y.y.y#Replacewithyournameserverip
查看介面配置使用"ip a"或ifconfig命令可以查看當前介面配置資訊參考資料1.Centos:Interface configuration files