mac 设置 vmware 为桥接模式使用桥接, wifi 的ip与虚拟机的ip需要处于同一网段
mac wifi 的 ip
虚拟机设置后的ip
恢复动态IP
vim /etc/sysconfig/network (注释所有内容)
vim /etc/sysconfig/network-scripts/ifcfg-eth0
# 设置为动态(其他内容不修改)
BOOTPROTO=dhcp
设置静态IP
涉及到三个配置文件:
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf
vim /etc/sysconfig/network
# Created by anaconda
# 设置静态ip,添加以下内容:
NETWORKING=yes
HOSTNAME=localhost.localdomain
# 主机的网络ip
GATEWAY=192.168.0.120
vim /etc/sysconfig/network-scripts/ifcfg-eth0
E=eth0
TYPE=Ethernet
# 虚拟机设置的静态ip
IPADDR=192.168.0.151
PREFIX=24
# 子网掩码
NETMASK=255.255.255.0
# 前三位与 ip 相同
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
# 主机的网络ip
GATEWAY=192.168.0.120
DEFROUTE=yes
ONBOOT=yes
USERCTL=yes
# 设置为静态
BOOTPROTO=static
NAME=eth0
IPV4_FAILURE_FATAL=yes
# mac 地址
HWADDR=00:0c:29:0e:9d:50
# 必须设置,否则无法进行域名解析
DNS1=8.8.8.8
vim /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
nameserver 218.85.152.99
nameserver 218.85.157.99
nameserver 8.8.8.8
search localdomain
网络服务重启一下,如果失败,可以先试着重启一下,执行 reboot,重启 centos7
service network restart
centos7 无法启动网络(service network restart)错误解决办法
第一种,和 NetworkManager 服务有冲突
# 关闭 NetworkManger 服务
service NetworkManager stop
# 禁止开机启动
chkconfig NetworkManager off
第二种,和配置文件的MAC地址不匹配
# 这两个文件的 HWADDR 设置为一致
vim /etc/udev/rules.d/70-persistent-net.rules
vim /etc/sysconfig/network-scripts/ifcfg-eth0
解决 Failed to start LSB: Bring up/down networking 问题
1、执行 service network restart 出现以下错误
Restarting network (via systemctl): Job for network.service failed. See 'systemctl status network.service'
and 'journalctl -xn' for details.
2、根据上面的提示,执行
systemctl status network.service
3、修改mac地址
# 修改 HWADDR 为虚拟机的新 mac 地址
vim /etc/sysconfig/network-scripts/ifcfg-eth0
4、查看centos7的虚拟机的mac地址
[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:0e:9d:50 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.151/24 brd 192.168.0.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe0e:9d50/64 scope link
valid_lft forever preferred_lft forever
网友评论