yum -y install iptables
//三张表 filter nat mangle

[root@wang /]# iptables -t filter -nvL

[root@wang /]# iptables -t nat -nvL

Chain PREROUTING (policy ACCEPT  packets,  bytes)
pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT packets, bytes)
pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT packets, bytes)
pkts bytes target prot opt in out source destination
[root@wang /]# iptables -t mangle -nvL
Chain PREROUTING (policy ACCEPT packets, bytes)
pkts bytes target prot opt in out source destination Chain INPUT (policy ACCEPT packets, bytes)
pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT packets, bytes)
pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT packets, bytes)
pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT packets, bytes)
pkts bytes target prot opt in out source destination

[root@wang /]# filter INPUT OUTPUT 用的最多^C
[root@wang /]# iptables -t filter -I INPUT -p TCP --dport 80 -s 12.12.12.12 -j REJECT  //filter表 INPUT表 TCP包 端口80 来源IP 操作DROP扔掉 REJECT拒绝 
[root@wang /]# iptables -t filter -nvL  //查看

[root@wang /]# iptables -Z  //清空数字

[root@wang /]# iptables -F  //清楚全部规则

//最后记得保存规则 否则重启后会扔掉

[root@wang /]# service iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
[root@wang /]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Thu Dec 22 02:56:51 2016
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [32:4672]
-A INPUT -s 12.12.12.12/32 -p tcp -m tcp --dport 80 -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Thu Dec 22 02:56:51 2016

//清空所有规则  恢复备份规则

[root@wang /]# iptables -F
[root@wang /]# iptables -nvL
Chain INPUT (policy ACCEPT 6 packets, 432 bytes)
pkts bytes target prot opt in out source destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 4 packets, 448 bytes)
pkts bytes target prot opt in out source destination

[root@wang /]# iptables-restore < /etc/sysconfig/iptables  //恢复  iptables-save > 1.ipt 备份
[root@wang /]# iptables -nvL

linux netfilter的更多相关文章

  1. linux netfilter nat2

    linux netfilter nat1 后面在上传

  2. Linux Netfilter框架分析

    目录 Netfilter框架 Netfilter的5个hook点 netfilter协议栈数据流分析 连接跟踪conntrack conntrack连接跟踪表条目 连接跟踪表大小 管理连接跟踪表 ip ...

  3. Extended TCP/IP Stack In Linux: Netfilter Hooks and IP Table

    https://www.amazon.com/gp/product/1118887735 The chapter about debugging is rather outdated - it des ...

  4. Linux Netfilter注册钩子点

    注册钩子点首先要包含响应的头文件,因为这应该已经属于对kernel的编程了. #include <linux/module.h> #include <linux/kernel.h&g ...

  5. linux netfilter nat1

    linux netfilter nat1 2020整理云笔记上传

  6. linux netfilter ----iptable_filter

    内核中将filter模块被组织成了一个独立的模块,每个这样独立的模块中都有个类似的init()初始化函数:首先来看一下filter模块是如何将自己的钩子函数注册到netfilter所管辖的几个hook ...

  7. linux netfilter rule match target 数据结构

    对于netfilter 可以参考 https://netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-3.html netfilter ...

  8. linux netfilter 五个钩子点

    参考http://www.linuxtcpipstack.com/685.html#NF_INET_PRE_ROUTING https://opengers.github.io/openstack/o ...

  9. Linux netfilter 学习笔记

    https://blog.csdn.net/lickylin/article/details/33321905

随机推荐

  1. IAR添加debug和release选项

    在IAR的Workspace窗口顶部的下拉菜单中有两个选项,Debug和Release. 名字和数量可以在菜单栏的Project-->Edit Configuration中增删修改 每个选项都对 ...

  2. Appium自动化测试教程-自学网-安卓模拟器

    安卓模拟器: 夜神模拟器安装配置 下载地址:https://www.yeshen.com 开启VT VT是什么?为什么要开启VT? VT,全称是Virtualization Technology,即是 ...

  3. P5043【模板】树同构([BJOI2015]树的同构)

    思路:树哈希 提交:1次 题解: 怕不是用的oi-wiki上的公式: \[f_u=size_u\times\sum f_{son_{u,i}}\times Base^{i-1}\] #include& ...

  4. jQuery.merge(first,second)

    jQuery.merge(first,second) 概述 合并两个数组 返回的结果会修改第一个数组的内容——第一个数组的元素后面跟着第二个数组的元素.要去除重复项,请使用$.unique() 参数 ...

  5. npm源管理

    1. 安装淘宝镜像 为了提高npm的安装速度,可以使用淘宝镜像. 使用淘宝镜像的方法有两种: 1. npm install -g cnpm --registry=https://registry.np ...

  6. HashMap判断键是否为null

    用containsKey(),而不用get(): HashMap中,null可以作为键,这样的键只有一个:可以有一个或多个键所对应的值为null.当get()方法返回null值时,即可以表示HashM ...

  7. Axios的params与data的

    Axios发送请求时params和data的区别  https://www.cnblogs.com/cwzqianduan/p/8675356.html(copy 在使用axios时,注意到配置选项中 ...

  8. 数据分析九:互联网征信中的信用评分模型(用户APP使用行为分析)

    用户APP使用行为数据分析: 一. 背景及数据介绍: 1. 移动互联网发展背景: 网民规模7.72亿,手机网民规模7.53亿: 2. APP使用热点: 商务交易类应用规模高速增长(网络购物,网上外卖, ...

  9. [Luogu] 矩形覆盖

    https://www.luogu.org/problemnew/show/P1034 数据太水 爆搜过掉 #include <iostream> #include <cstdio& ...

  10. 通过xshell上传和下载文件

    参考:http://www.cnblogs.com/mingaixin/p/5588699.html