zoukankan      html  css  js  c++  java
  • VM12中CentOS7以NAT方式连接网络的方法

    解决问题:centos网络连不上,连不上主机,ifconfig等命令不能用(配完有网了,安装上就好了)等问题


    前提:安装vm12,centos7(最小安装) 


    注意:以下以192开头的,你都要替换成自己的,可在vm中找到(192.168.181.66:我自己设的ip,192.168.181.2:网关)



    (1)配置eno16777736(/etc/sysconfig/network-scripts/ifcfg-eno16777736),
    #配置开始#
    TYPE=Ethernet
    BOOTPROTO=static
    DEFROUTE=yes
    PEERDNS=yes
    PEERROUTES=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes
    IPV6_FAILURE_FATAL=no
    NAME=eno16777736
    UUID=4ee0a1dd-fd55-4a2c-acb3-732bf9766e04
    DEVICE=eno16777736
    ONBOOT=yes
    IPADDR0=192.168.181.66
    PREFIX0=24
    GATEWAY0=192.168.181.2
    NETMASK=255.255.255.0
    DNS1=8.8.8.8
    DNS2=114.114.114.114
    #配置结束#

    (2)配置DNS步骤1(/etc/NetworkManager/NetworkManager.conf ),
    #配置开始#
    # Configuration file for NetworkManager.
    #
    # See "man 5 NetworkManager.conf" for details.
    #
    # The directory /etc/NetworkManager/conf.d/ can contain additional configuration
    # snippets. Those snippets override the settings from this main file.
    #
    # The files within conf.d/ directory are read in asciibetical order.
    #
    # If two files define the same key, the one that is read afterwards will overwrite
    # the previous one.
    [main]
    plugins=ifcfg-rh
    dns=none
    [logging]
    #level=DEBUG
    #domains=ALL
    #配置结束#

    (3)配置DNS步骤2(/etc/resolv.conf),
    #配置开始#
    nameserver 8.8.8.8
    nameserver 114.114.114.114
    #配置结束#

    (4)注意网络是以NAT模式而不是桥接模式,注意配置完重启(systemctl restart network)

    @Arya0624

  • 相关阅读:
    php xdebug的配置、调试、跟踪、调优、分析
    alpine使用的避坑指南
    nginx fastcgi模块ngx_http_fastcgi_module详细解析、使用手册、完整翻译
    深入理解 Kubernetes 资源限制:CPU
    使用xdebug对php做性能分析调优
    alpine安装sshd/ssh server
    冒泡排序的终极改进优化
    基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建
    NPM使用
    NodeJS学习历程
  • 原文地址:https://www.cnblogs.com/Arry10/p/7731745.html
Copyright © 2011-2022 走看看