开发者社区> 问答> 正文

Linux服务器中设置UFW的操作方法以及步骤是什么?

Linux服务器中设置UFW的操作方法以及步骤是什么?

展开
收起
游客qzzytmszf3zhq 2021-12-05 22:33:27 488 0
1 条回答
写回答
取消 提交回答
  • install UFW:

    sudo apt-get install ufw 您可以拒绝所有输出流量:

    sudo ufw default deny outgoing comment 'deny all outgoing traffic' 或者允许所有输出流量

    sudo ufw default allow outgoing comment 'allow all outgoing traffic' 接下来,我们要拒绝所有传入的流量:

    sudo ufw default deny incoming comment 'deny all incoming traffic' 当然要排除SSH连接,以便我们可以访问系统。

    sudo ufw limit in ssh comment 'allow SSH connections in' 如果您将UFW配置为拒绝所有输出流量,请不要忘记根据您的需要允许特定的流量。以下是一些例子:

    allow traffic out on port 53 -- DNS

    sudo ufw allow out 53 comment 'allow DNS calls out'

    allow traffic out on port 123 -- NTP

    sudo ufw allow out 123 comment 'allow NTP out'

    allow traffic out for HTTP, HTTPS, or FTP

    apt might needs these depending on which sources you're using

    sudo ufw allow out http comment 'allow HTTP traffic out' sudo ufw allow out https comment 'allow HTTPS traffic out' sudo ufw allow out ftp comment 'allow FTP traffic out'

    allow whois

    sudo ufw allow out whois comment 'allow whois'

    allow traffic out on port 68 -- the DHCP client

    you only need this if you're using DHCP

    sudo ufw allow out 68 comment 'allow the DHCP client to update' 若要拒绝端口99上的任何流量,请使用以下命令:

    sudo ufw deny 99 最后,使用下面的命令启动UFW:

    sudo ufw enable 使用以下命令查看UFW状态:

    sudo ufw status

    2021-12-05 22:33:39
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS快储存加密技术 立即下载