关键词:
目录
2.1 --list-rules -S :打印链或所有链中的规则
1.命令行手册查缺补漏
[root@ovn-center ~]# iptables --help
iptables v1.4.21
Usage: 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] chain
iptables -E old-chain-name new-chain-name
iptables -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 rulenum
Delete rule rulenum (1 = first) from chain
--insert -I chain [rulenum]
Insert in chain as rulenum (default 1=first)
--replace -R chain rulenum
Replace 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 target
Change policy on chain to target
--rename-chain
-E old-chain new-chain
Change 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 target
target for rule (may load target extension)
--goto -g chain
jump to chain with no return
--match -m match
extended 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 lock
default 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链的规则
删除自定义链表的时候,不能有引用和规则,需要清理关系和内部的规则
linux命令(215)——iptables命令(代码片段)
...简介2.命令格式3.选项说明4.常用示例参考文献1.命令简介iptables/ip6tables是IPv4/IPv6包过滤和NAT的管理工具。iptables/ip6tables命令是Linux上常用的防火墙软件,是netfilter项目的一部分。可以直接配置,也可以通过许多前端和图形... 查看详情
linux命令(216)——iptables-save命令(代码片段)
...简介2.命令格式3.选项说明4.常用示例参考文献1.命令简介iptables-save/ip6tables-save转储iptables规则。iptables-save和ip6tables-save用于转储IP或IPv6表在容易解析的格式或STDOUT或到指定的文件。iptables/ip6tables均是xtables-multi的软链。2.命令格式i... 查看详情
linux命令(217)——iptables-restore命令(代码片段)
...简介2.命令格式3.选项说明4.常用示例参考文献1.命令简介iptables-restore恢复IP表。ip6tables-restore恢复IPv6表。iptables-restore和ip6tables-restore用于从STDIN或文件中指定的数据恢复IP和IPv6表。iptables-restore和ip6tables-restore均是xtables-multi的软链... 查看详情
linux命令(215)——iptables命令(代码片段)
...简介2.命令格式3.选项说明4.常用示例参考文献1.命令简介iptables/ip6tables是IPv4/IPv6包过滤和NAT的管理工具。iptables/ip6tables命令是Linux上常用的防火墙软件,是netfilter项目的一部分。可以直接配置,也可以通过许多前端和图形... 查看详情
iptables(代码片段)
简介iptables是用户空间命令行程序,用于配置Linux2.4.x及更高版本的包过滤规则集。由两个组件netfilter和iptables组成4个规则表(优先级raw>mangle>nat>filter)raw表:确定是否对该数据包进行状态跟踪;对应iptable_raw,表内包含两... 查看详情
centos初步学习记录iptables(代码片段)
一、前言iptables中文名:IP信息包过滤系统,它是一个配置Linux内核防火墙的命令行工具,是netfilter项目的一部分。术语iptables也经常代指该内核级防火墙。iptables可以直接配置,也可以通过许多前端和图形界面配置。iptables用于ipv... 查看详情
linux----------防火墙(代码片段)
...墙1.2.1网络层防火墙1.2.2应用层防火墙1.3防火墙工具二、iptables2.1iptables的组件2.2iptables组成2.2.1四个表t2.2.2五个内置链chain2.2.3iptables规则2.3iptables工作原理2.4iptables命令2.4.1iptables语法格式2.5iptables命令之匹配条件2.6iptabl 查看详情
linux命令(216)——iptables-save命令(代码片段)
...简介2.命令格式3.选项说明4.常用示例参考文献1.命令简介iptables-save/ip6tables-save转储iptables规则。iptables-save和ip6tables-save用于转储IP或IPv6表在容易解析的格式或STDOUT或到指定的文件。iptables/ip6tables均是xtables-multi的软链。2.命令格式i... 查看详情
iptables设置用法(代码片段)
1.安装iptables防火墙怎么知道系统是否安装了iptables?执行一下iptables-V,如果现实版本信息那说明已经安装了。反之则需要安装,执行命令:yuminstalliptables在linux中设置防火墙,以CentOS为例,打开iptables的配置文件:vim/etc/sysconfig/i... 查看详情
linux命令(217)——iptables-restore命令(代码片段)
...简介2.命令格式3.选项说明4.常用示例参考文献1.命令简介iptables-restore恢复IP表。ip6tables-restore恢复IPv6表。iptables-restore和ip6tables-restore用于从STDIN或文件中指定的数据恢复IP和IPv6表。iptables-restore和ip6tables-restore均是xtables-multi的软链... 查看详情
系统管理员需知的16个iptables使用技巧(代码片段)
...的流量数据包。基于Netfilter框架的用户层命令行工具 iptables提供了强大的防火墙配置功能,允许你添加规则来构建防火墙策略。iptables[2] 丰富复杂的功能以及其巴洛克式命令语法可能让人难以驾驭。我们就来探 查看详情
使用iptables和tc对端口限速(代码片段)
首先,我们来看一下tc,TC(TrafficControl)命令,是linux自带的告警流控命令。Linux操作系统中的流量控制器TC(TrafficControl)用于Linux内核的流量控制,主要是通过在输出端口处建立一个队列来实现流量控制。一般只能限... 查看详情
linuxiptables常用命令(代码片段)
https://www.cnblogs.com/ilinuxer/p/6364064.htmliptables 是Linux中重要的访问控制手段,是俗称的 Linux防火墙系统的重要组成部分。这里记录了iptables防火墙规则的一些常用的操作指令。下面的操作以CentOS为基础介绍,应该对不同的Linux... 查看详情
firewalld入门手册(代码片段)
导读FirewallD是iptables的一个封装,可以让你更容易地管理iptables规则-它并不是iptables的替代品。虽然iptables 命令仍可用于FirewallD,但建议使用FirewallD时仅使用FirewallD 命令。 FirewallD是iptables的前端控制器,用于实现持久... 查看详情
firewalld入门手册(代码片段)
FirewallD是iptables的一个封装,可以让你更容易地管理iptables规则-它并不是iptables的替代品。虽然iptables 命令仍可用于FirewallD,但建议使用FirewallD时仅使用FirewallD 命令。 FirewallD是iptables的前端控制器,用于实现持久的网... 查看详情
linux命令行翻译工具(代码片段)
一、背景经常在linux命令行下有些单词不认识,复制出来通过翻译软件很不方便,如果有个命令行翻译就比较舒服了。通过下面shell脚本可以在/usr/bin/yd创建yd命令来进行快速命令行翻译。二、代码git地址#!/bin/bash##CMD=/usr/bin/ydcat>... 查看详情
sh运行androidemulador命令行linux(代码片段)
iptables__防火墙(代码片段)
iptables防火墙一.iptables概述二.netfileter/iptables关系三.四表五链1.四表2.五链3.数据包到达防火墙,规则表之间的优先顺序:4.规则链之间的匹配顺序主机型防火墙:网络型防火墙:规则链内的匹配顺序:四.iptables... 查看详情