操作系统:Ubuntu 18.04.2 LTS
虚拟机:VMware 12
设置多个虚拟机组件集群的时候,需要配置各个虚拟机有着不同的ip地址。因此这里简单介绍一下如何配置虚拟机ip。
设置虚拟机网络为nat模式
打开虚拟机网络编辑器选项
更改设置,取消DHCP服务,设定子网ip(该服务是用来动态分配ip地址)
网关ip
sudo vim /etc/network/interfaces 修改网络配置
# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto ens33 #查看自己的网卡名称,可以通过ifconfig命令查询
iface ens33 inet static #设置该网卡为静态ip
address 192.168.73.129 #静态IP地址设置
netmask 255.255.255.0 #掩码设置
gateway 192.168.73.2 #网关ip设置
dns-nameservers 8.8.8.8 114.114.114.114 #DNS服务器地址设置(解析域名,访问外网)若出现可以ping通DNS服务器,但是不能ping通域名,则DNS设置仍然有问题,修改/etc/systemd/resolved.conf内容
# cat /etc/systemd/resolved.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
#添加DNS服务器地址
DNS=114.114.114.114
DNS=8.8.8.8
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes重启机器
reboot