VMware Workstation下centOS互联

目标

  1. 修改配置文件,使之可以与主机及外网互联
  2. 启用sshd服务,使用SecureCRT连接centOS

VMware Workstation网络配置

点击菜单 Edit > Preferences,点击NAT Settings
网络配置
配置网关IP,一般默认即可,也可以自己修改
网关

注:下面的CentOS中会用这里配置的网关、子网掩码

查看本机的DNS IP
本地DNS

注:下面的CentOS中会用这里DNS IP

CentOS网络配置

[root@localhost /]# cd /etc/sysconfig/network-scripts/ #切换至network-scripts目录下
[root@localhost network-scripts]# vi ifcfg-ens33 #编辑ifcfg打头的文件

修改

BOOTPROTO=static #动态为dhcp
ONBOOT=yes #原先为no

添加

IPADDR=192.168.123.130 #设置IP地址
GATEWAY=192.168.123.2 #设置网关
NETMASK=255.255.255.0 #设置子网掩码
DNS1=192.168.0.1 #设置DNS
DNS2=8.8.8.8 #google提供的免费DNS服务器的IP地址
DNS3=8.8.4.4 #google提供的另一个免费DNS服务器的IP地址
[root@localhost network-scripts]# service network restart #重启网络服务
[root@localhost network-scripts]# ping www.baidu.com #ping外网
PING www.a.shifen.com (119.75.213.61) 56(84) bytes of data.
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=1 ttl=128 time=30.3 ms
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=2 ttl=128 time=30.8 ms
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=3 ttl=128 time=31.3 ms
[root@localhost network-scripts]# yum install net-tools #安装网络工具,如果不安装无法使用ifconfig等工具
[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.123.131  netmask 255.255.255.0  broadcast 192.168.123.255
        inet6 fe80::97b8:f5ed:5cf4:6b9d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:83:9b:ed  txqueuelen 1000  (Ethernet)
        RX packets 2203  bytes 269053 (262.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1678  bytes 412661 (402.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost network-scripts]#  yum list installed | grep openssh-server #如果运行如下,则说明已经安装了ssh服务
openssh-server.x86_64                 7.4p1-16.el7                     @anaconda

[root@localhost network-scripts]# yum install openssh-server #如果没有,则运行此命令安装
[root@localhost network-scripts]# cd /etc/ssh/
[root@localhost ssh]# ls
moduli  ssh_config  sshd_config  ssh_host_ecdsa_key  ssh_host_ecdsa_key.pub  ssh_host_ed25519_key  ssh_host_ed25519_key.pub  ssh_host_rsa_key  ssh_host_rsa_key.pub
[root@localhost ssh]# vi sshd_config #编辑ssh配置,去掉如下属性的注释
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
PermitRootLogin yes
PasswordAuthentication yes

[root@localhost ssh]# sudo service sshd start #启动sshd服务
[root@localhost ssh]# ps -ef | grep sshd #检查sshd服务是否已经开启
[root@localhost ssh]# netstat -an | grep 22 #检查22号端口是否开启监听

一切正常后,便可以通过远程工具SecureCRT连接centOS。

如何在VMware Workstation下安装centOS可以参照 VMware Workstation 14安装Centos 7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值