先设置物理机、虚拟机的桥接模式,
参考文章:https://blog.youkuaiyun.com/tiramisu_L/article/details/80557772
https://blog.youkuaiyun.com/wumumang/article/details/54173075
再进行以下操作
1.更改本地ip配置 vi /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.7.112.130
netmask 255.255.255.0
gateway 10.7.112.254
dns-nameservers 10.1.7.97 10.1.7.98
2.设置DNS文件 vi /etc/resolv.conf(如上一步中配置了dns-nameservers则这里会自动配置)
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.1.7.97
nameserver 10.1.7.98
3.修改启动脚本 vi /etc/rc.local(可不修改)
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
4.重启配置文件 /etc/init.d/networking restart
5.如重启网络后还不行可试下ifconfig eth0 down/up