前言
之前谈到如何创建虚拟机。
这节谈将如何配置ip等信息,使本地ssh连接上虚拟机。
安装ifconfig
登录后输入
su
再输入密码,切换为root模式。
然后安装ifconfig,输入:
yum install ifconfig
之后输入
ifconfig
显示ip则说明安装成功,否则则没有安装成功。
如果没有安装成功,则输入:
yum search ifconfig
看看是否缺少什么工具包,这里显示是net-tools.x86_64
则输入:
yum install net-tools.x86_64
先安装工具包,再输入:
yum install ifconfig
安装完成则有:
本机配置
在虚拟机中点击编辑,选择虚拟网络编辑器:
点击更改设置
点击VMnet8,然后如图设置
然后点击NAT设置
选择如图设置:
然后打开windows网络设置,点击更改适配器设置:
选择VMware Network Adapter
,右键点击属性:
选择TCP/IPv4,点击属性
:
按照如下图设置:
linux配置
打开虚拟机环境,输入:
vi /etc/sysconfig/network-scripts/ifcfg-ens33
按i
进入insert模式,将配置文件修改如下:
按esc
退出insert模式,然后依次按:wq
保存退出。
然后输入:
systemctl restart network
重启网络后,输入
ifconfig
可以看看当前ip信息:
ip为192.168.10.200
输入:
vi /etc/hostname
将hostname修改为
docker
:wq
保存退出后,然后输入:
vi /etc/hosts
修改hosts为:
将我们ip地址加上,配置docker主机名。
然后:wq
退出。
这时候重启机器:
reboot
这个时候linux环境配置好了。
我们去下载一个叫switchhosts
的软件,它可以自由切换本机的hosts配置,详情可以网上搜搜。诸如此类的教程挺多的,看到switchhosts主界面:
我们创建一个叫docker的配置如图:
配置为:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
192.168.10.1 windows10.microdone.cn
192.168.10.200 docker
然后把开关打开即可
不需要再去C:\Windows\System32\drivers\etc
路径下手动改hosts文件了。
ssh连接
我这里使用了Xshell进行连接:
创建一个叫docker的连接,连接配置如下:
由于我们的配置主机名,所以这里写主机名即可,不需要写ip。(如果连接不上,可以手动写主机:192.168.10.200)
账号密码记得写一下。
然后点击连接即可:
成功
问题参考
yum无法安装 东西
https://blog.csdn.net/qq_25919879/article/details/121855981
参考
https://blog.csdn.net/catViolin/article/details/117254069
https://blog.csdn.net/Trying_/article/details/120779972
https://blog.csdn.net/weixin_45022563/article/details/123922815