CentOS mini版本网络配置+SSH工具连接

简介: 1. VM网络设置图1.png点击NAT设置图2记住网关和子网ip,后面会用2. CentOs网络设置[root@localhost download]# cd /etc/sysconfig/network-scri...

1. VM网络设置

img_acae5411b090b46c6cfd4d7420e20ce5.png
图1.png

点击NAT设置


img_90c09281a51a19e7bab379ecafcb60b9.png
图2

记住网关和子网ip,后面会用

2. CentOs网络设置

[root@localhost download]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33  ifdown-eth   ifdown-post    ifdown-Team      ifup-aliases  ifup-ipv6   ifup-post    ifup-Team      init.ipv6-global
ifcfg-lo     ifdown-ippp  ifdown-ppp     ifdown-TeamPort  ifup-bnep     ifup-isdn   ifup-ppp     ifup-TeamPort  network-functions
ifdown       ifdown-ipv6  ifdown-routes  ifdown-tunnel    ifup-eth      ifup-plip   ifup-routes  ifup-tunnel    network-functions-ipv6
ifdown-bnep  ifdown-isdn  ifdown-sit     ifup             ifup-ippp     ifup-plusb  ifup-sit     ifup-wireless

用vim打开 ifcfg-ens33

img_0bd09db47edac3737d6da0a559d03ed2.png

修改我圈中的这几项,网关和子网ip与之前一一对应起来。

重启网络模块

service network restart

3. 检测网络是否配置成功

ping百度
[root@localhost network-scripts]# ping baidu.com
PING baidu.com (220.181.57.216) 56(84) bytes of data.
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=128 time=18.5 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=128 time=18.7 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=128 time=17.7 ms

查看ip

此命令需要先安装net工具包yum install net-tools -y

[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.27.132  netmask 255.255.255.0  broadcast 192.168.27.255
        inet6 fe80::99b3:c79:5377:c3fe  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:7b:59:07  txqueuelen 1000  (Ethernet)
        RX packets 288077  bytes 405462136 (386.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14968  bytes 2189388 (2.0 MiB)
        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 83  bytes 8297 (8.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 83  bytes 8297 (8.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
更换yum源

CentOS 7.x 安装阿里yum源

安装vim

yum install vim -y

4. SSH工具连接

安装openssh-server

yum install openssh-server -y

开放22端口或者关闭防火墙(二选一)

开放端口

firewall-cmd --zone=public --add-port=22/tcp --permanent
其中:
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效

关闭防火墙

//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld

关闭SELinux

#临时关闭
setenforce 0
#永久关闭
vi /etc/selinux/config
开始连接

我用的是XShell工具


img_c391d3ff258d604ab473a3749a998d70.png
img_04e9f041dbe7112c6c9c71a0351ad6a8.png

什么?ssh还连接不上?

在VM里还原默认网络配置,然后注意把NAT模式的子网ip也对应做修改。


img_d18ac3aa3d7d3ea2b6267828a696c416.png
img_bec46f87a6a14e997c1df9a90f809e3c.png
相关文章
|
14天前
|
应用服务中间件 Linux 网络安全
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
14 0
|
22天前
|
Ubuntu
虚拟机Ubuntu连接不了网络的解决方法
虚拟机Ubuntu连接不了网络的解决方法
|
1月前
|
运维 网络协议 安全
【Shell 命令集合 网络通讯 】Linux 网络抓包工具 tcpdump命令 使用指南
【Shell 命令集合 网络通讯 】Linux 网络抓包工具 tcpdump命令 使用指南
44 0
|
1月前
|
网络协议 Linux 网络安全
curl(http命令行工具):Linux下最强大的网络数据传输工具
curl(http命令行工具):Linux下最强大的网络数据传输工具
44 0
|
1月前
|
Shell Linux C语言
【Shell 命令集合 网络通讯 】Linux 关闭PPP(Point-to-Point Protocol)连接 ppp-off命令 使用指南
【Shell 命令集合 网络通讯 】Linux 关闭PPP(Point-to-Point Protocol)连接 ppp-off命令 使用指南
42 1
|
1月前
|
数据采集 JavaScript 前端开发
实用工具推荐:适用于 TypeScript 网络爬取的常用爬虫框架与库
实用工具推荐:适用于 TypeScript 网络爬取的常用爬虫框架与库
|
1月前
|
监控 网络协议 Linux
【Shell 命令集合 网络通讯 】Linux 显示网络 连接、路由表和网络接口信息 netstat命令 使用指南
【Shell 命令集合 网络通讯 】Linux 显示网络 连接、路由表和网络接口信息 netstat命令 使用指南
59 1
|
4天前
|
网络协议 安全 Linux
IDEA通过内网穿透实现固定公网地址远程SSH连接本地Linux服务器
IDEA通过内网穿透实现固定公网地址远程SSH连接本地Linux服务器
|
4天前
|
存储 网络协议 Linux
如何使用内网穿透工具实现远程SSH访问Deepin系统
如何使用内网穿透工具实现远程SSH访问Deepin系统
|
4天前
|
安全 网络安全 网络虚拟化
《计算机网络简易速速上手小册》第3章:计算机网络设备和工具(2024 最新版)
《计算机网络简易速速上手小册》第3章:计算机网络设备和工具(2024 最新版)
23 1