iptables 常用命令

简介:

一、命令

  1. 查看某表中的规则:
    iptables  --line-number  -t  表名  -nL
  2. 添加新的入站规则:
    iptables  -A  INPUT  -s  ip地址  -p  协议  --dport  端口  -j  处理方式
  3. 替换规则:
    iptables  -R  INPUT  编号  -s  ip地址  -p  协议  --dport  端口  -j  处理方式
  4. 删除规则:
    iptables  -D  INPUT  编号
  5. 修改默认规则:
    iptables  -t  表名  -P  INPUT  处理方式
  6. 允许路由转发(由内向外):
    iptables  -t  nat  -A  POSTROUTING  -s  内网ip/网段  -j  SNAT  --to-source  外网ip
  7. 允许路由转发(由外向内):
    iptables  -t  nat  -A  PREROUTING  -d  外网ip  -p  协议  --dport  端口  -j  DNAT  --to-destination  内网ip/网段
  8. 实现地址转发(反向代理,基于内网ip):
    iptables  -t  nat  -A  PREROUTING  -d  外网ip  -p  协议  --dport  端口  -j  DNAT  --to-destination  内网ip/网段
    iptables  -t  nat  -I  POSTROUTING  -p  协议  --dport  端口  -j  MASQUERADE
  9. 限制每秒钟接受到的数据包的个数(防止垃圾攻击):
    iptables  -I  INPUT  -m  limit  --limit  个数/sec  -j  ACCEPT
  10. 拒绝新的连接请求:
    iptables  -A  INPUT  -m  state  --state  NEW  -j  DROP

    二、备份:

    iptables-save  >  文件

    三、还原:

    iptables-restore  <  文件

    四、查看iptables错误信息:

    dmesg

    iptables 常用命令
    五、常用的文件:

  11. 查看系统中标准的端口信息:
    cat  /etc/services

    iptables 常用命令

  12. 开启路由转发的文件:
    cat  /etc/sysctl.conf

    iptables 常用命令


 本文转自 Lee_吉 51CTO博客,原文链接:http://blog.51cto.com/12173069/2060597
相关文章
|
8月前
|
网络协议 Linux 网络安全
Linux系列——关于防火墙iptables的常用命令
Linux系列——关于防火墙iptables的常用命令
|
网络协议 Linux 网络安全
iptables常用命令小清单
iptables常用命令小清单
951 0
iptables常用命令小清单
|
Linux 网络安全 开发工具
|
9月前
|
机器学习/深度学习 NoSQL Linux
tcpdump 常用命令
Linux 的命令太多,tcpdump 是一个非常强大的抓包命令。有时候想看线上发生的一些问题:nginx 有没有客户端连接过来……客户端连接过来的时候 Post 上来的数据对不对……
76 0
|
网络协议 算法 Linux
iptables 常用命令
使用 -t 选项指定了要操作的表,此处指定了操作 filter 表,与之前的查看命令一样,不使用-t 选项指定表时,默认为操作 filter 表。 使用-I 选项,指明将”规则”插入至哪个链中,-I 表示 insert,即插入的意思,所以-I INPUT 表示将规则插入于 INPUT 链中,即添加规则之意。 使用-s 选项,指明”匹配条件”中的”源地址”,即如果报文的源地址属于-s 对应的地址,那么报文则满足匹配条件,-s 为 source 之意,表示源地址。
|
网络协议 安全 开发者
iptables 命令使用 | 学习笔记
快速学习iptables 命令使用
iptables 命令使用 | 学习笔记
|
网络协议 Ubuntu 应用服务中间件
Linux防火墙常用命令
1. 通用命令: 查看防火墙版本 iptables -version 2. RHEL6 (1) 查看防火墙状态(如果得到一系列的信息, 说明防火墙处于开启状态) /etc/init.d/iptables status (2) 开启/关闭防火墙, 重启后生效 chkconfig iptables o...
|
Linux 网络安全
iptables简介1及常用命令
第一章:简述 iptables是一个用户态工具,用于操作linux内核部分的netfilter模块(包过滤),用来完成防火墙相关的工作。linux的netfilter工作于2层(开启bridge-nf时刻)和3层(ip层),可以对ip包,二层数据链路包进行操作;而市面上还有一种防火墙是应用层防火墙,可以对应用层包进行检查(过滤)。
1087 0