当前位置: 首页 > news >正文

linux:iptables (3) 命令行操练(一)

目录

1.命令行手册查缺补漏

2.开始练习,从最陌生的参数练习开启

2.1 --list-rules  -S :打印链或所有链中的规则

2.2 --zero -Z 链或所有链中的零计数器

 2.3 --policy  -P 修改默认链的默认规则

2.4 --new -N 接下来练习添加和删除自定义链


1.命令行手册查缺补漏

[root@ovn-center ~]# iptables --help
iptables v1.4.21Usage: iptables -[ACD] chain rule-specification [options]iptables -I chain [rulenum] rule-specification [options]iptables -R chain rulenum rule-specification [options]iptables -D chain rulenum [options]iptables -[LS] [chain [rulenum]] [options]iptables -[FZ] [chain] [options]iptables -[NX] chainiptables -E old-chain-name new-chain-nameiptables -P chain target [options]iptables -h (print this help information)Commands:
Either long or short options are allowed.--append  -A chain            Append to chain--check   -C chain            Check for the existence of a rule--delete  -D chain            Delete matching rule from chain--delete  -D chain rulenumDelete rule rulenum (1 = first) from chain--insert  -I chain [rulenum]Insert in chain as rulenum (default 1=first)--replace -R chain rulenumReplace rule rulenum (1 = first) in chain--list    -L [chain [rulenum]]List the rules in a chain or all chains--list-rules -S [chain [rulenum]]Print the rules in a chain or all chains--flush   -F [chain]          Delete all rules in  chain or all chains--zero    -Z [chain [rulenum]]Zero counters in chain or all chains--new     -N chain            Create a new user-defined chain--delete-chain-X [chain]          Delete a user-defined chain--policy  -P chain targetChange policy on chain to target--rename-chain-E old-chain new-chainChange chain name, (moving any references)
Options:--ipv4      -4              Nothing (line is ignored by ip6tables-restore)--ipv6      -6              Error (line is ignored by iptables-restore)
[!] --protocol  -p proto        protocol: by number or name, eg. `tcp'
[!] --source    -s address[/mask][...]source specification
[!] --destination -d address[/mask][...]destination specification
[!] --in-interface -i input name[+]network interface name ([+] for wildcard)--jump -j targettarget for rule (may load target extension)--goto      -g chainjump to chain with no return--match       -m matchextended match (may load extension)--numeric     -n              numeric output of addresses and ports
[!] --out-interface -o output name[+]network interface name ([+] for wildcard)--table       -t table        table to manipulate (default: `filter')--verbose     -v              verbose mode--wait        -w [seconds]    maximum wait to acquire xtables lock before give up--wait-interval -W [usecs]    wait time to try to acquire xtables lockdefault is 1 second--line-numbers                print line numbers when listing--exact       -x              expand numbers (display exact values)
[!] --fragment  -f              match second or further fragments only--modprobe=<command>          try to insert modules using this command--set-counters PKTS BYTES     set the counter during insert/append
[!] --version   -V              print package version.

2.开始练习,从最陌生的参数练习开启

2.1 --list-rules  -S :打印链或所有链中的规则

[root@ovn-center ~]# iptables --list-rules
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
[root@ovn-center ~]# iptables -t nat --list-rules
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
[root@ovn-center ~]# iptables -t filter -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -s 10.10.10.3/32 -j DROP

2.2 --zero -Z 链或所有链中的零计数器

 2.3 --policy  -P 修改默认链的默认规则

在修改了filter表的INPUT默认规则为DROP时,直接断网 ,

也就是丢弃了所有一切进入主机的数据包

 需要给指定的链修改默认规则,而无法一次性全部修改

我们恢复规则继续测试

2.4 --new -N 接下来练习添加和删除自定义链

在filter表上添加一个链

iptables -t filter -N WEB

接着将WEB引用到filter表INPUT链,这样凡是目标端口是80,443的流量都将经过WEB链的规则

 删除自定义链表的时候,不能有引用和规则,需要清理关系和内部的规则

 

http://www.lryc.cn/news/44730.html

相关文章:

  • synchronized(this) 与synchronized(class) 有啥区别
  • BOSS直拒、失联招聘,消失的“金三银四”,失业的测试人出路在哪里?
  • 华为OD机试【密室逃生游戏】
  • 【Python学习笔记(六)】json解析模块的使用
  • 《Spring系列》第3章 基于注解管理Bean
  • 【Redis】十大数据类型(下篇)
  • 【第十一届“泰迪杯”数据挖掘挑战赛】B题产品订单的数据分析与需求预测“解题思路“”以及“代码分享”
  • Python入门到高级【第一章】
  • 【泰凌微TLSR8258 zigbee】OTA升级操作方法
  • 网络基础设施监控
  • OPNET Modeler 例程——创建一个包交换网络
  • JSON 基础结构
  • 雷达基础知识
  • 【二阶锥规划】考虑气电联合需求响应的气电综合能源配网系统协调优化运行【IEEE33节点】(Matlab代码实现)
  • qt 编译器 调试器
  • 低代码平台助力AIGC:让人工智能技术更加普及和高效
  • Qt中Model/View结构
  • 中纬ZOOM35全站仪参数和使用说明书
  • 【Note5】网络,并发/IO,内存,linux/vi命令,正则,Hash,iNode,文件查找与读取,linux启动/构建
  • 华为MRS_HADOOP集群 beeline使用操作
  • PCB模块化设计10——PCI-E高速PCB布局布线设计规范
  • Java简介
  • python框架有哪些,常用的python框架代码
  • jsp设计简单的购物车应用案例
  • VueX是什么?好处?何时使用?
  • 第2章 封装组件初级篇(上)
  • uniapp image标签图片跑偏终极解决办法
  • SpringMVC的响应处理
  • 静态词向量预训练模型
  • 永久免费CRM怎么选?有什么好用的功能?