VirtualBox虚拟机Centos7设置静态ip桥接网络

使用vb安装了centos7,想使用桥接网络

  1. vb中设置网络方式为桥接网络
  2. 使用ip add查看当前网络名称,查看到当前网络名为enp0s3.(各个系统可能不一样)
  3. 编辑静态ip vim /etc/sysconfig/network-scripts/ifcfg-enp0s3,设置如下:
    image.png
  4. 设置网关vim /etc/sysconfig/network
    image.png

    这里的gateway是在宿主机(windows)上根据ipconfig查看得到的。
    5.设置DNS vim /etc/resolv.conf
    image.png

    114.114.114.114是国内的DNS服务器,8.8.8.8是谷歌的DNS服务器。
  5. 重启网络
    systemctl restart NetworkManager
    systemctl restart network

参考: https://gist.github.com/fernandoaleman/2172388

备注:linux中除了ifconfig可以看网络连接信息,还可以使用nmcli命令

你可能感兴趣的:(VirtualBox虚拟机Centos7设置静态ip桥接网络)