iptables系列(一)初探

iptables系列(一)初探

iptables基本介绍

官网介绍

  iptables is the userspace command line program used to configure the Linux 2.4.x and later packet filtering ruleset. It is targeted towards system administrators.
  Since Network Address Translation is also configured from the packet filter ruleset, iptables is used for this, too.
  The iptables package also includes ip6tables. ip6tables is used for configuring the IPv6 packet filter.

翻译

  iptables是用于配置Linux 2.4.x及更高版本的包过滤规则集的用户空间命令行程序。它面向系统管理员。
  由于网络地址转换也是从包过滤器规则集配置的,因此也使用了_iptables_。
  iptables包还包括ip6tables。ip6tables用于配置IPv6数据包筛选器

获取iptables

  1. 下载地址:https://www.netfilter.org/projects/iptables/downloads.html
  2. 下载最新版本:点击 https://www.netfilter.org/projects/iptables/files/iptables-1.8.2.tar.bz2 下载 iptables-1.8.2.tar.bz2
  3. linux使用tar解压、window使用7z解压

安装iptables

  1. 进入iptables源码根目录
  2. ./configure
  3. make
  4. make install(注意是否需要root权限)

源码核心文件
.
├── extensions :iptables可使用的扩展模块
├── include:头文件
├── iptables:iptables核心源码
├── libipq:iptables用户空间数据包排队库
├── libiptc:Netfilter xtables框架在用户空间iptables的C库
├── libxtables:Netfilter xtables内核框架的用户空间接口
├── utils:工具

补充知识

Netfilter、Xtables、Iptables的关系?

  Netfilter是负责实际的数据流改变工作的内核模块,而Xtables就是它的规则配置文件,Netfilter依照Xtables的规则来运行,Iptables在应用层负责修改这个规则文件。

iptables命令体验

在此观察下iptables命令的强大之处即可,若非了解iptables,谨慎运行!

iptables -t filter - I INPUT -s 192.168.43.215 -p icmp -j REJECT
拒绝来自ip为192.168.43.215的ping申请

iptables -t filter - I INPUT -s 192.168.43.215 -p tcp -m tcp --dport 22 -j REJECT
拒绝来自192.168.43.215协议为tcp且目的端口为22的报文

iptables -t filter -F INPUT
清空上述命令的配置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值