GNU/Linux - Ubuntu中的UFW介绍

UFW - Uncomplicated Firewall
Ubuntu 的默认防火墙配置工具是 ufw。ufw 是为简化 iptables 防火墙配置而开发的,它提供了一种用户友好的方式来创建基于 IPv4 或 IPv6 主机的防火墙。默认情况下,UFW 是禁用的。
The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptables firewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall. By default UFW is disabled.
gufw 是一个图形用户界面前端。
gufw is a GUI that is available as a frontend.
1, Basic Syntax and Examples
Default rules are fine for the average home user /  默认规则对普通家庭用户来说没有问题
当你打开 UFW 时,它会使用一套默认的规则(配置文件),这对普通家庭用户来说应该没问题。这至少是 Ubuntu 开发人员的目标。简而言之,所有的 “传入 ”都会被拒绝,但也有一些例外情况,以方便家庭用户。
When you turn UFW on, it uses a default set of rules (profile) that should be fine for the average home user. That's at least the goal of the Ubuntu developers. In short, all 'incoming' is being denied, with some exceptions to make things easier for home users.
Enable and Disable
To turn UFW on with the default set of rules:
sudo ufw enable
To check the status of UFW:
sudo ufw status verbose
请注意,默认情况下,拒绝将应用于传入。但也有例外情况,可在该命令的输出中找到:
Note that by default, deny is being applied to incoming. There are exceptions, which can be found in the output of this command:
sudo ufw show raw
你还可以读取 /etc/ufw 中的规则文件(文件名以 .rules 结尾的文件)。
You can also read the rules files in /etc/ufw (the files whose names end with .rules).
Disable UFW
To disable ufw use:
sudo ufw disable
Allow and Deny (specific rules)
Allow
sudo ufw allow <port>/<optional: protocol>
example: To allow incoming tcp and udp packet on port 53
sudo ufw allow 53
example: To allow incoming tcp packets on port 53
sudo ufw allow 53/tcp
example: To allow incoming udp packets on port 53
sudo ufw allow 53/udp
Deny
sudo ufw deny <port>/<optional: protocol>
example: To deny tcp and udp packets on port 53
sudo ufw deny 53
example: To deny incoming tcp packets on port 53
sudo ufw deny 53/tcp
example: To deny incoming udp packets on port 53
sudo ufw deny 53/udp
Delete Existing Rule
要删除一条规则,只需在原规则前加上删除即可。例如,如果原来的规则是:
To delete a rule, simply prefix the original rule with delete. For example, if the original rule was:
ufw deny 80/tcp
Use this to delete it:
sudo ufw delete deny 80/tcp
Services
你还可以通过服务名称来允许或拒绝,因为 ufw 会读取 /etc/services 以获取服务列表:
You can also allow or deny by service name since ufw reads from /etc/services to see get a list of services:
less /etc/services
Allow by Service Name
sudo ufw allow <service name>
example: to allow ssh by name
sudo ufw allow ssh
Deny by Service Name
example: to deny ssh by name
sudo ufw deny ssh
Status
检查 ufw 的状态会告诉你 ufw 是启用还是禁用,还会列出当前应用于 iptables 的 ufw 规则。
Checking the status of ufw will tell you if ufw is enabled or disabled and also list the current ufw rules that are applied to your iptables.
To check the status of ufw:
sudo ufw status
if ufw was not enabled the output would be:
sudo ufw status
Status: inactiv
<think>好的,用户想了解Ubuntuufw和coreutils软件包的功能。首先我需要回忆这两个包的基本信息。 ufw,全称是Uncomplicated Firewall,是Ubuntu上的防火墙配置工具。它旨在简化iptables的使用,用户可以通过简单的命令管理网络规则。记得ufw默认是安装的,但可能没有启用。需要确认这一点,并说明常用命令,比如启用、禁用、允许端口等。可能还需要提到它底层基于iptables,但提供了更友好的接口。[^1] 然后是coreutils软件包。这个包包含基本的GNU核心工具,比如ls、cp、mv、rm等,这些都是系统管理的基础命令。可能需要列出一些常用工具,并说明它们的作用。例如,chmod修改权限,dd用于数据转换和复制,ln创建链接等。coreutils是系统正常运行不可或缺的部分,几乎所有Linux发行版都默认安装。 用户可能作为Ubuntu新手,需要明确这两个包的实际应用场景。对于ufw,可以举例如何配置防火墙规则,比如允许SSH或HTTP流量。对于coreutils,则强调日常文件操作和系统管理中的重要性。 需要检查是否有版本差异,但用户提到的Ubuntu 10.04是比较旧的版本,不过ufw和coreutils的基本功能应该变化不大。注意引用提供的参考信息,用户提到的引用[1]是系统信息,可能与软件包的具体版本相关,但主要功能描述应通用。 可能的相关问题包括如何配置ufw规则,或者coreutils中某个工具的具体用法。需要生成三个相关问题,确保覆盖安装、使用和故障排除等方面。</think>### Ubuntuufw和coreutils软件包功能说明 #### 1. ufw(Uncomplicated Firewall)软件包功能 ufwUbuntu系统默认提供的防火墙配置工具,旨在简化`iptables`的复杂操作。其核心功能包括: - **防火墙规则管理**:通过简单命令控制流量(如允许/拒绝端口、IP或协议),例如: ```bash sudo ufw allow 22/tcp # 允许SSH连接 sudo ufw deny from 192.168.1.100 # 拒绝特定IP访问 ``` - **状态控制**:支持启用/禁用防火墙(默认未激活),命令为`sudo ufw enable/disable`。 - **日志记录**:可通过`sudo ufw logging on`开启流量日志,便于排查网络问题。 #### 2. coreutils软件包用途 coreutils提供GNU核心工具集,包含约100个基础命令,分为以下类别: - **文件操作**:`cp`(复制)、`mv`(移动)、`rm`(删除)等。 - **权限管理**:`chmod`(修改权限)、`chown`(修改所有者)。 - **系统信息**:`date`(显示时间)、`uname`(系统版本查询)。 - **数据处理**:`sort`(排序)、`wc`(统计行数/字数)。 #### 典型应用场景 - **ufw**:保护服务器安全(如限制外部访问数据库端口)、家庭网络隔离。 - **coreutils**:日常文件管理(如批量重命名)、脚本编写(依赖`grep`、`awk`等工具链)。 ```bash # 示例:使用coreutils工具统计当前目录文件数 ls | wc -l ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值