mac 配置 VMware 的 CentOS 网络 (NAT 模式)

Mac set VMware's CentOS Network (NAT Mode)

因为每次都要去网上找教程 (😂), 所以记录一下自己的配置过程

  1. VMware 默认配置就为 NAT 模式


    NAT 模式
  2. 关闭防火墙

    1
    2
    3
    4
    5
    6
    
    # 关闭
    > systemctl stop firewalld
    # 禁用
    > systemctl disable firewalld
    # 查看状态
    > systemctl status firewalld
  3. 禁用 selinux

    1
    2
    
    # 将 SELINUX 设置为 `disabled`
    > vi /etc/selinux/config

    禁用 selinux

    安全增强型 Linux(Security-Enhanced Linux)简称 SELinux, 它是一个 Linux 内核模块, 也是 Linux 的一个安全子系统.

  4. 获取 mac vmnet8 的 gateway 地址

    1
    
    > cat /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf

    找到 # NAT gateway address 一行, 然后记下 ipnetmask

  5. 修改虚拟机中的网卡配置

    1
    
    > vi /etc/sysconfig/network-scripts/ifcfg-ens33

    ifcfg-ens33

    上图红框为修改内容, 绿框为新增内容

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    BOOTPROTO=static
    ONBOOT=yes
    IPADDR=172.16.143.101
    GATEWAY=172.16.143.2
    NETMASK=255.255.255.0
    DNS1=114.114.114.114
    DNS2=8.8.8.8
    
    # 其中 GATEWAY 为第 4 步中的 ip, NETMASK 为第 4 步 中的 netmask
  6. 重启虚拟机网卡

    1
    
    > systemctl restart network
  7. ping 一下外网就可以啦!

    1
    
    > ping www.baidu.com
  8. 修改主机名

    1
    2
    3
    
    > vi /etc/hostname
    # 将其中内容删除, 改为: `buli_server1`
    > vi /etc/hosts

    /etc/hosts
  9. 重启

    1
    
    > reboot -f
0%