美文网首页
笔记:Debian UFW简单使用

笔记:Debian UFW简单使用

作者: black_history | 来源:发表于2019-12-30 11:10 被阅读0次
  1. 基础文件位置
    配置文件:/etc/default/ufw
    log文件:/var/log/ufw.log

  2. 基础命令
    开启:ufw enable
    关闭:ufw disable
    查看策略:

    ufw status verbose
    ufw status numbered
    

    恢复默认策略:

    ufw default deny incoming
    ufw default allow outgoing
    ufw default reject routed
    

    重置UFW
    ufw reset 将删除所有自定义策略并关闭UFW

    允许ssh连接:
    ufw allow ssh将会添加ssh默认端口,即22,如果ssh监听了其他端口,如22222,则需要执行命令:ufw allow 22222
    允许其他连接,如http、https、ftp
    http:ufw allow http or ufw allow 80
    https:ufw allow https or ufw allow 443
    ftp:ufw allow ftp or ufw allow 21
    ufw allow [serviceName]的方式只是会放行服务的默认端口,如果服务监听了其他端口,需要ufw allow [port]的方式

    放行指定范围的端口:

    ufw allow 10010:10086/tcp
    ufw allow 10010:10086/udp
    

    使用该命令必须指定规则所适用的协议

    允许指定ip访问

    ufw allow 221.123.1.1
    ufw allow 221.123.1.1 to any port 22
    # 放行ip段
    ufw allow 221.123.1.0/24
    ufw allow 221.123.1.0/24 to any port 22
    

    拒绝连接

    ufw deny http
    ufw deny from 221.123.1.1
    

    删除规则

    # 按编号删除
    ufw delete [num]
    
    # 按实际规则删除
    ufw delete allow http 
    # or 
    ufw delete allow 80
    
  3. 其他
    ifconfig查看ip
    arch 查看CPU架构(x86、x86_64、amd64等)

相关文章

网友评论

      本文标题:笔记:Debian UFW简单使用

      本文链接:https://www.haomeiwen.com/subject/tdupoctx.html