• iptables常用操作


    1.查看防火墙

    #默认是filter表
    [root@m01 ~]# iptables -nL
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
    REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination

    2.查看指定表

    #-t:    指定表
    [root@m01 ~]# iptables -nL -t nat

    3.清除防火墙规则

    [root@m01 ~]# iptables -F
    [root@m01 ~]# iptables -X
    [root@m01 ~]# iptables -Z

    4.添加防火墙规则

    [root@m01 ~]# iptables -t filter -A INPUT -p tcp --dport 22 -j DROP
    
    [root@m01 ~]# iptables -nL
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22

    5.删除防火墙规则

    #防火墙规则加序号
    [root@m01 ~]# iptables -nL --line-numbers
    Chain INPUT (policy ACCEPT)
    num  target     prot opt source               destination         
    1    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:2
    2    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22
    
    Chain FORWARD (policy ACCEPT)
    num  target     prot opt source               destination         
    
    Chain OUTPUT (policy ACCEPT)
    num  target     prot opt source               destination
    
    #删除指定id的规则
    [root@m01 ~]# iptables -D INPUT 3
  • 相关阅读:
    RTTI机制
    constexpr
    map/unordered_map
    Centos 安装Oracle
    JS带进度 文件 重复 自动 异步上传
    xadmin 小组件默认折叠
    xadmin datetime 类型报错 unsupported format characte
    Vmware 链接克隆 转 完整克隆 Converting a linked clone virtual machine to a full clone virtual machine
    vsftpd 530 500 553
    百度自然语言处理API调用
  • 原文地址:https://www.cnblogs.com/chenlifan/p/13679452.html
Copyright © 2020-2023  润新知