在虚拟机中安装 Linux 无法 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