Introduce
安裝虛擬機無法DHCP獲取地址,搜了點資料設置成功,記下來以後好找文檔。
設置靜態IP
vi /etc/network/interfaces
# The primary network interface
auto eth0 #表示讓網卡開機自動掛載eth0
iface eth0 inet static
address 192.168.2.1
gateway 192.168.2.254
netmask 255.255.255.0
/etc/init.d/networking restart
or
service networking restart
# Centos**
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0C:29:1D:86:BD
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID=da0d1da0-568a-45cf-a93f-66a30a4870e7
IPADDR=192.168.1.12
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
IPV6INIT=no
USERCTL=no
設置DNS
vi /etc/resolvconf/resolv.conf.d/base
#添加
nameserver 8.8.8.8
nameserver 8.8.4.4
resolvconf -u
# Centos
vi /etc/resolv.conf
nameserver 168.95.1.1
nameserver 8.8.8.8