Virtual machine installation Centos7 configuration static address

Skip the process of installing a virtual machine here

Configuration of NAT static network card under CentOs 7

Recently, I built big data under CentOs 7 and found the necessity of configuring static ip in centOS7. This blog post will talk about how to configure the static ip of centOS7 in the VM virtual machine.

  1. Set the network configuration of the vm virtual machine, set the network card to NAT mode, and view the virtual network card information in NAT mode.insert image description here
  2. Then set the things that need to be set, for example, I want the network segment ip where my virtual machine is located to be the 192.168.86.x network segmentinsert image description here
    insert image description here
    insert image description here

The initial IP address here refers to the initial IP address of the network IP to which your virtual machine belongs. If you are in dynamic DHCP mode, an address will be randomly selected from 192.168.86.100~192.168.86.254 as the IP of your virtual machine address. Of course, this has nothing to do with the static ip in our article.

  1. Then we enter the virtual machine, log in to centos, and enter the following directory.
[root@hadoop002 ~]# cd /etc/sysconfig/network-scripts/
[root@hadoop002 network-scripts]# pwd
/etc/sysconfig/network-scripts

Then we edit this file.
vim ifcfg-ens33
insert image description here

Here is the file I have configured myself. If you have not configured it, it should be as follows.

TYPE="Ethernet"   # 网卡类型: 这里默认是以太网
PROXY_METHOD="none"  # 代理方式
BROWSER_ONLY="no"    
BOOTPROTO="dhcp"   #[none|static|bootp|dhcp](引导时不使用协议|静态分配|BOOTP协议|DHCP协议)
DEFROUTE="yes"       # 默认路由
IPV4_FAILURE_FATAL="no"   # 是否开启IPV4致命错误检测:否
IPV6INIT="yes"        # ipv6是否初始化:是
IPV6_AUTOCONF="yes" 
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"   #网卡物理设备名称
UUID="1514ed14-8587-4fbd-ac1c-c95ddc8255cf"# 网卡信息通用唯一识别码
DEVICE="ens33"   # 网卡设备名称,必须哈`NAME` 相同
ONBOOT="yes" # 是否开机启动,默认:no

Then we configure the information we need to configure under ONBOOT

IPADDR=192.168.86.102 #你想配置的静态IP地址
NETMASK=255.255.255.0 #子网掩码
GATEWAY=192.168.86.2 #网关,这里对应前面我们在VMWare虚拟网络设置的网关
DNS1=198.168.1.1  #这里的DNS解析服务器,我们需要打开自己的物理机,ipconfig,里面去查找里面的DNS服务器地址填在下面。
DNS2=192.168.10.1

After the configuration is complete, restart the virtual machine
and execute the reboot command

modify hostname

centos7

[root@hadoop002 ~]# vim /etc/hostname

Guess you like

Origin blog.csdn.net/qq_16733389/article/details/126912613