Linux笔记12(防火墙)

一、iptables防火墙

1.1 简介

早期的Linux系统中,默认使用的是iptables防火墙管理服务来配置防火墙 linux

大量的企业在生产环境中依然出于各类缘由而继续使用iptables web

1.2策略与规则

在进行路由选择前处理数据包(PREROUTING);shell

处理流入的数据包(INPUT);安全

处理流出的数据包(OUTPUT);服务器

处理转发的数据包(FORWARD);markdown

在进行路由选择后处理数据包(POSTROUTING)app

1.3iptables相关参数

参数 做用
-P 设置默认策略
-F 清空规则链
-L 查看规则链
-A 在规则链的末尾加入新规则
-I num 在规则链的头部加入新规则
-D num 删除某一条规则
-s 匹配来源地址IP/MASK,加叹号“!”表示除这个IP外
-d 匹配目标地址
-i 网卡名称 匹配从这块网卡流入的数据
-o 网卡名称 匹配从这块网卡流出的数据
-p 匹配协议,如TCP、UDP、ICMP
--dport num 匹配目标端口号
--sport num 匹配来源端口号

1.4实验【ping】:设置iptables策略

1.4.1 本机ping服务器

本机:192.168.0.9dom

Linux服务器:192.168.0.15ssh

C:\Users\Administrator>ping 192.168.0.15

正在 Ping 192.168.0.15 具备 32 字节的数据:
来自 192.168.0.15 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.0.15 的回复: 字节=32 时间=1ms TTL=64
来自 192.168.0.15 的回复: 字节=32 时间=1ms TTL=64
来自 192.168.0.15 的回复: 字节=32 时间=1ms TTL=64

192.168.0.15 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 1ms,平均 = 0ms

1.4.2查看并清除默认策略

[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             192.168.122.0/24     ctstate RELATED,ESTABLISHED
ACCEPT     all  --  192.168.122.0/24     anywhere            
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootpc
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

1.4.3 Linux服务器设置REJECT策略

root@localhost ~]# iptables -I INPUT -p icmp -j REJECT 

# 查看是否配置上去
[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)

target     prot opt source               destination         
REJECT     icmp --  anywhere             anywhere             reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

1.4.4 再次ping服务器

C:\Users\Administrator>ping 192.168.0.15

正在 Ping 192.168.0.15 具备 32 字节的数据:
来自 192.168.0.15 的回复: 没法连到端口。
来自 192.168.0.15 的回复: 没法连到端口。
来自 192.168.0.15 的回复: 没法连到端口。
来自 192.168.0.15 的回复: 没法连到端口。

192.168.0.15 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失)

1.4.5Linux服务器设置DROP策略

# 清空防火墙
[root@localhost ~]# iptables -F
[root@localhost ~]# 
[root@localhost ~]# iptables -P INPUT DROP
# 让全部icmp协议进来
[root@localhost ~]# iptables -I INPUT -p icmp -j DROP
[root@localhost ~]# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     icmp --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

1.4.5再次ping服务器

C:\Users\Administrator>ping 192.168.0.15

正在 Ping 192.168.0.15 具备 32 字节的数据:
请求超时。
请求超时。
请求超时。
请求超时。

192.168.0.15 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 0,丢失 = 4 (100% 丢失),

1.4.5使用-I参数在前面增长一个ACCEPT,容许ICMP协议访问服务器

[root@localhost ~]# iptables -I INPUT -p icmp -j ACCEPT

[root@localhost ~]# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     icmp --  anywhere             anywhere            
DROP       icmp --  anywhere             anywhere

注意:iptables防火墙是从前以后开始判断的,前面生效了,后面就无心义了!socket

先容许再拒绝全部 > 先拒绝在容许全部 更加安全

1.5实验【端口22】:设置iptables策略

1.5.1使用ssh访问Linux服务器

[C:\~]$ 

Connecting to 192.168.0.15:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Activate the web console with: systemctl enable --now cockpit.socket

Last login: Tue Jul 20 07:27:50 2021

1.5.2使用iptables策略限制22端口tcp访问

[root@localhost ~]# iptables -I INPUT -p tcp --dport 22 -j REJECT 
[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
REJECT     tcp  --  anywhere             anywhere             tcp dpt:ssh reject-with icmp-port-unreachable
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps

1.5.3再次使用SSH链接Linux服务器

[C:\~]$ 

Connecting to 192.168.0.15:22...
Could not connect to '192.168.0.15' (port 22): Connection failed

Type `help' to learn how to use Xshell prompt.

1.6实验【批量限制端口】:设置iptables策略

1.6.1拒绝22端口+1000-1500端口tcp协议访问

[root@localhost ~]# iptables -I INPUT -p tcp --dport 22 -j REJECT 
[root@localhost ~]# iptables -I INPUT -p tcp --dport 1000:1500 -j REJECT 
[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
REJECT     tcp  --  anywhere             anywhere             tcp dpts:cadlock2:vlsi-lm reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             anywhere             tcp dpt:ssh reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

1.6.2使用xshell测试

[C:\~]$ 

Connecting to 192.168.0.15:22...
Could not connect to '192.168.0.15' (port 22): Connection failed

Type `help' to learn how to use Xshell prompt.

# 测试成功!

1.7iptables防火墙保存

[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
REJECT     tcp  --  anywhere             anywhere             tcp dpts:cadlock2:vlsi-lm reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             anywhere             tcp dpt:ssh reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@localhost ~]# iptables-save 
# Generated by xtables-save v1.8.2 on Tue Jul 20 07:50:36 2021
*filter
:INPUT ACCEPT [1207:1625091]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [906:68760]
-A INPUT -p tcp -m tcp --dport 1000:1500 -j REJECT --reject-with icmp-port-unreachable
-A INPUT -p tcp -m tcp --dport 22 -j REJECT --reject-with icmp-port-unreachable
COMMIT
# Completed on Tue Jul 20 07:50:36 2021
# Generated by xtables-save v1.8.2 on Tue Jul 20 07:50:36 2021
*security
:INPUT ACCEPT [954:1589536]
:FORWARD ACCEPT [0:0]
…………
root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
REJECT     tcp  --  anywhere             anywhere             tcp dpts:cadlock2:vlsi-lm reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             anywhere             tcp dpt:ssh reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

二、Firewalld防火墙(cmd模式)

RHEL 8系统中集成了多款防火墙管理工具,其中firewalld(Dynamic Firewall Manager of Linux systems)服务是默认的防火墙配置管理工具,也叫Linux系统的动态防火墙管理器,它拥有基于CLI(命令行界面)和基于GUI(图形用户界面)的两种管理方式。

2.一、 firewalld中经常使用的区域名称及策略规则

区域 默认规则策略
trusted 容许全部的数据包
home 拒绝流入的流量,除非与流出的流量相关;而若是流量与ssh、mdns、ipp-client、amba-client与dhcpv6-client服务相关,则容许流量
internal 等同于home区域
work 拒绝流入的流量,除非与流出的流量相关;而若是流量与ssh、ipp-client与dhcpv6-client服务相关,则容许流量
public 拒绝流入的流量,除非与流出的流量相关;而若是流量与ssh、dhcpv6-client服务相关,则容许流量
external 拒绝流入的流量,除非与流出的流量相关;而若是流量与ssh服务相关,则容许流量
dmz 拒绝流入的流量,除非与流出的流量相关;而若是流量与ssh服务相关,则容许流量
block 拒绝流入的流量,除非与流出的流量相关
drop 拒绝流入的流量,除非与流出的流量相关

2.二、 firewall-cmd 命令

命令行终端是一种极富效率的工做方式,firewall-cmd是firewalld防火墙配置管理工具的CLI命令行界面版本

参数 做用
--get-default-zone 查询默认的区域名称
--set-default-zone=<区域名称> 设置默认的区域,使其永久生效
--get-zones 显示可用的区域
--get-services 显示预先定义的服务
--get-active-zones 显示当前正在使用的区域与网卡名称
--add-source= 将源自此IP或子网的流量导向指定的区域
--remove-source= 再也不将源自此IP或子网的流量导向某个指定区域
--add-interface=<网卡名称> 将源自该网卡的全部流量都导向某个指定区域
--change-interface=<网卡名称> 将某个网卡与区域进行关联
--list-all 显示当前区域的网卡配置参数、资源、端口以及服务等信息
--list-all-zones 显示全部区域的网卡配置参数、资源、端口以及服务等信息
--add-service=<服务名> 设置默认区域容许该服务的流量
--add-port=<端口号/协议> 设置默认区域容许该端口的流量
--remove-service=<服务名> 设置默认区域再也不容许该服务的流量
--remove-port=<端口号/协议> 设置默认区域再也不容许该端口的流量
--reload 让“永久生效”的配置规则当即生效,并覆盖当前的配置规则
--panic-on 开启应急情况模式
--panic-off 关闭应急情况模式

2.2.1查看防火墙默认区域

# 默认区域public
[root@localhost ~]# firewall-cmd --get-default-zone 
public

2.2.2查看网卡默认区域

[root@localhost ~]# firewall-cmd --get-zone-of-interface=ens160 
public

预计21~22日写完,看工做期间加不加班吧!

2.3修改网卡默认区域

[root@mmx ~]# firewall-cmd --permanent --zone=external --change-interface=ens160 
The interface is under control of NetworkManager, setting zone to 'external'.
success
[root@mmx ~]# firewall-cmd --reload 
success
[root@mmx ~]# firewall-cmd --get-zone-of-interface=ens160 
external

2.4修改firewalld默认区域设置为public

[root@mmx ~]# firewall-cmd --set-default-zone=public 
Warning: ZONE_ALREADY_SET: public
success
[root@mmx ~]# firewall-cmd --get-default-zone 
public

2.5救援模式

发现服务器不正常,为防止数据进一步丢失,咱们能够先把网线拔掉,或者服务器断电,有没有更好的方法呢?

救援模式也能作到一样的效果,还能够容许一些用户进入

命令 介绍
panic-on 开启救援模式
panic-off 关闭救援模式

2.5.1开启救援模式

[root@mmx ~]# firewall-cmd --panic-on
success

2.5.2主机ping服务器设备状态

[C:\~]$ ping 192.168.130.100

# 设备访问,icmp包直接被丢弃
正在 Ping 192.168.130.100 具备 32 字节的数据:
请求超时。
请求超时。
请求超时。
请求超时。

192.168.130.100 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 0,丢失 = 4 (100% 丢失),

2.5.3关闭救援模式

[root@mmx ~]# firewall-cmd --panic-off
success

2.5.4救援模式关闭后,主机能正常访问服务器

[C:\~]$ ping 192.168.130.100

正在 Ping 192.168.130.100 具备 32 字节的数据:
来自 192.168.130.100 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.130.100 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.130.100 的回复: 字节=32 时间=1ms TTL=64
来自 192.168.130.100 的回复: 字节=32 时间<1ms TTL=64

192.168.130.100 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 1ms,平均 = 0ms

2.6查询firewall防火墙状态

不加 --permanent命令,当前状态

加 -permanent命令,重启以后状态

[root@mmx ~]# firewall-cmd --zone=public --query-service=ssh
yes
[root@mmx ~]# firewall-cmd --zone=public --query-service=https
no
[root@mmx ~]# firewall-cmd --permanent --zone=public --query-service=https
no
[root@mmx ~]# firewall-cmd --permanent --zone=public --query-service=http
no

2.7放行服务

--add-service=[服务名称]

# 查看发现并无放行https服务
[root@mmx ~]# firewall-cmd --permanent --zone=public --query-service=https
no

[root@mmx ~]# firewall-cmd --permanent --zone=public --add-service=https
success

# 重启firewalld防火墙
[root@mmx ~]# firewall-cmd --reload 
success

# 发现已经容许http服务
[root@mmx ~]# firewall-cmd --permanent --zone=public --query-service=https
yes

2.8拒绝服务

--remove-service=[服务名称]

[root@mmx ~]# firewall-cmd --permanent --zone=public --remove-service=https
Warning: NOT_ENABLED: https
success
[root@mmx ~]# firewall-cmd --reload 
success
[root@mmx ~]# firewall-cmd --zone=public --query-service=https
no

2.9容许端口访问

--add-port=[端口-端口]/协议

[root@mmx ~]# firewall-cmd --zone=public --add-port=8080-8081/tcp
success

[root@mmx ~]# firewall-cmd --zone=public --list-ports 
8080-8081/tcp

2.10端口转发

ssh服务是22号端口,我把22号端口屏蔽了,ssh须要经过1500端口才能访问,端口转发功能正好解决这一痛点

2.10.1修改网卡区域为public

记得刚刚修改了网卡的默认区域,致使禁用ssh以后竟然还能访问设备,首先修改网卡区域为public

[root@mmx ~]# firewall-cmd --permanent --zone=public --change-
--change-interface=  --change-source=     --change-zone=       
[root@mmx ~]# firewall-cmd --permanent --zone=public --change-interface=ens160 
The interface is under control of NetworkManager, setting zone to 'public'.
success
[root@mmx ~]# firewall-cmd --reload 
success

2.10.2将22端口指向1500

该步骤确保ssh只能由一个端口访问

[root@mmx ~]# firewall-cmd --permanent --zone=public --add-forward-port=port=22:proto=tcp:toport=1500:toaddr=192.168.130.100
success
[root@mmx ~]# firewall-cmd --reload 
success

2.10.3配置端口转发

[root@mmx ~]# firewall-cmd --permanent --zone=public --add-forward-port=port=1500:proto=tcp:toport=22:toaddr=192.168.130.100
Warning: ALREADY_ENABLED: 1500:tcp:22:192.168.130.100
success
[root@mmx ~]# firewall-cmd --reload 
success

2.10.4在xshell中测试效果

# 直接使用ssh命令
[C:\~]$ ssh 192.168.130.100

Connecting to 192.168.130.100:22...
Could not connect to '192.168.130.100' (port 22): Connection failed.

Type `help' to learn how to use Xshell prompt.

#使用ssh命令+指定端口,配置完成
[C:\~]$ ssh 192.168.130.100 1500

Connecting to 192.168.130.100:1500...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Activate the web console with: systemctl enable --now cockpit.socket

Last login: Mon Jul 19 23:02:41 2021 from 192.168.130.1

2.11 富规则

表示更细致、更详细的防火墙策略配置,它能够针对系统服务、端口号、源地址和目标地址等诸多信息进行更有针对性的策略配置。

需求:不让一个组访问ssh和http协议

一、创建家庭规则组

二、拒绝ssh

三、拒绝http……

[root@mmx ~]# firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.130.0/24" service name="ssh" reject"
success
[root@mmx ~]# firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.130.0/24" service name="http" reject"
success
[root@mmx ~]# firewall-cmd --reload 
success

三、Firewalld防火墙(图形化界面)

firewalld防火墙配置管理工具的GUI图形用户界面版本,几乎能够实现全部以命令行来执行的操做。绝不夸张的说,即便读者没有扎实的Linux命令基础,也彻底能够经过它来妥善配置RHEL 8中的防火墙策略

实验以前,让我把系统恢复成初始快照!

3.1安装图形化工具

3.1.1挂载光盘镜像

[root@mmx ~]# mkdir /media/cdrom
[root@mmx ~]# mount /dev/cdrom /media/cdrom/
mount: /media/cdrom: WARNING: device write-protected, mounted read-only.

# 写入/etc/fstab文件
[root@mmx ~]# echo /dev/cdrom /media/cdrom/ iso9660 defauts 0 0
/dev/cdrom /media/cdrom/ iso9660 defauts 0 0
[root@mmx ~]# echo /dev/cdrom /media/cdrom/ iso9660 defauts 0 0 >> /etc/fstab 
[root@mmx ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Sat Feb 13 18:57:33 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=4d4c29d8-ed99-4dc5-9d18-1c07f42c205e /                       xfs     defaults        0 0
UUID=47ad9072-96e0-4ba5-8644-d281a35ac6a2 /boot                   xfs     defaults        0 0
UUID=4ae13371-a715-4fe3-aca6-64fe31bb459f swap                    swap    defaults        0 0
/dev/cdrom /media/cdrom/ iso9660 defaults 0 0

# 该命令无报错就行!
[root@mmx ~]# mount -a

3.1.2配置dnf软件仓库

[root@mmx yum.repos.d]# cat xiaoming.repo 
[BaseOS]
name=BaseOS
baseurl=file:///media/cdrom/Base
enbled=1
gpgcheck=0

[AppStream]
name=AppStream
baseurl=file:///media/cdrom/AppStream
enabled=1
gpgcheck=0

3.1.3安装firewall-config图形化防火墙

[root@mmx ~]# dnf install firewall-config
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
AppStream                               12 MB/s | 5.3 MB     00:00    
BaseOS                                 0.0  B/s |   0  B     00:00    
Cannot find a valid baseurl for repo: rhel, ignoring this repo.
Failed to synchronize cache for repo 'BaseOS', ignoring this repo.
Last metadata expiration check: 0:00:02 ago on Tue 20 Jul 2021 12:57:54 AM PDT.
Dependencies resolved.
=======================================================================
 Package             Arch       Version            Repository     Size
=======================================================================
Installing:
 firewall-config     noarch     0.6.3-7.el8        AppStream     157 k

Transaction Summary
=======================================================================
Install  1 Package

Total size: 157 k
Installed size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                               1/1 
  Installing       : firewall-config-0.6.3-7.el8.noarch            1/1 
  Running scriptlet: firewall-config-0.6.3-7.el8.noarch            1/1 
  Verifying        : firewall-config-0.6.3-7.el8.noarch            1/1 
Installed products updated.

Installed:
  firewall-config-0.6.3-7.el8.noarch                                   

Complete!

3.4使用防火墙

[root@mmx ~]# firewall-config

1626768474839.png

3.2使用图形化工具实现端口转发

3.2.1找到Port Forwarding

1626768578614.png

3.2.2新建规则(端口1500转换成22,22端口转换成1500)

1626768654922.png
1626768671898.png

3.2.3使用xshell工具测试

实验成功

1626768780167.png

四、服务的访问控制列表

实验环境RHEL7

/etc/hosts.allow

/etc/hosts.deny

规则:先容许后拒绝

4.1 TCP Wrappers服务的控制列表文件中经常使用的参数

客户端类型 示例 知足示例的客户端列表
单一主机 192.168.10.10 IP地址为192.168.10.10的主机
指定网段 192.168.10. IP段为192.168.10.0/24的主机
指定网段 192.168.10.0/255.255.255.0 IP段为192.168.10.0/24的主机
指定DNS后缀 .linuxprobe.com 全部DNS后缀为.linuxprobe.com的主机
指定主机名称 www.baidu.com 主机名称为www.baidu.com的主机
指定全部客户端 ALL 全部主机所有包括在内

4.2实验,容许本机sshd,拒绝全部其余设备sshd

本机 IP地址 192.168.125.1

RHEL7 IP地址192.168.125.132

4.2.1添加策略进入hosts.allow和hosts.deny文件

[root@localhost ~]# echo sshd:192.168.125.* >> /etc/hosts.allow 
[root@localhost ~]# echo sshd:* >> /etc/hosts.deny 
[root@localhost ~]# tail -n 3 /etc/hosts.allow 
#       See 'man tcpd' for information on tcp_wrappers
#
sshd:192.168.125.
[root@localhost ~]# tail -n 3 /etc/hosts.deny 
#       See 'man tcpd' for information on tcp_wrappers
#
sshd:*

4.2.2使用ssh链接测试

[C:\~]$ 

Connecting to 192.168.125.132:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

WARNING! The remote SSH server rejected X11 forwarding request.
Last login: Wed Jul 21 00:50:26 2021 from 192.168.125.1
[root@localhost ~]#

4.2.3删除容许策略

[root@localhost ~]# tail -n 5 /etc/hosts.allow 
#
#       See 'man 5 hosts_options' and 'man 5 hosts_access'
#       for information on rule syntax.
#       See 'man tcpd' for information on tcp_wrappers
#

4.2.4再次测试设备可否使用ssh链接

[C:\~]$ 

Connecting to 192.168.125.132:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(红帽7) at 17:04:55.

Type `help' to learn how to use Xshell prompt.

Cockpit驾驶舱管理工具

Cockpit是一个基于网页的图形化工具,自然具有很好的跨平台性,被 普遍使用于服务器、容器、虚拟机等等多种管理场景,即使是新手均可以直接上手操做。最后要说的是红帽公司对Cockpit十分的看重,从最开始就默认安装到了RHEL 8系统中,衍生的CentOS和Fedora也都是标配它。

一、cockpit工具的安装

1.1 系统默认安装cockpit包

[root@linuxprobe ~]# dnf install cockpit
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
AppStream                                       3.1 MB/s | 3.2 kB     00:00    
BaseOS                                          2.7 MB/s | 2.7 kB     00:00    
Package cockpit-185-2.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

1.2启动服务、设置开机自动启动

[root@linuxprobe ~]# systemctl start cockpit
[root@linuxprobe ~]# systemctl enable cockpit.socket
Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket → /usr/lib/systemd/system/cockpit.socket.

二、根据Linux服务器ip地址访问9090端口

例如:https://XXX.XXX.XXX.XXX:9090

1626786582292.png

三、相关查看&配置界面

1626786650309.png

1626786677190.png

1626786806271.png

1626786818287.png

1626786827838.png

1626786836877.png

1626786849010.png

1626786877532.png

1626786885716.png

1626786895275.png

相关文章
相关标签/搜索