首页 > 系统相关 >iptables

iptables

时间:2022-10-10 17:58:08浏览次数:72  
标签:iptables -- tcp ACCEPT 172.16 100.7

iptables -A INPUT -s 0.0.0.0/0 -d 0.0.0.0/0 -p tcp --dport 8910 -j ACCEPT   #允许any到any 8910端口 iptables -A INPUT -s 0.0.0.0/0 -d 0.0.0.0/0 -p tcp --dport 80 -j  ACCEPT      #允许any到any 80端口   --------------------------开放22端口-----------------------------------------------------

iptables -A INPUT -i eth0 -s 172.16.0.0/16 -d 172.16.100.7 -p tcp --dport 22 -j ACCEPT  
# 允许172.16段访问100.7的22端口 -i  eth0  指定从eth0口进入
 
iptables -A OUTPUT -s 172.16.100.7 -d 172.16.0.0/16 -p tcp --sport 22 -j ACCEPT  #允许100.7去访问172.16段
 
iptables -t filter -P INPUT DROP  # 拒绝所有进入
iptables -t filter -P OUTPUT DROP  # 拒绝所有出去
iptables -t filter -P FORWARD DROP  # 拒绝所有转发
 
iptables-save > /etc/sysconfig/iptables  # 保存配置,默认些文件是不存在的
# Centos6上可以使用:service iptables save
  实时查看命令规则:watch -n 1 'iptables -L -n -v'   -------------------centos 6 -------------------------
iptables -A INPUT  -s 192.168.0.0/16 -d 192.168.11.2 -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -s 192.168.11.2 -d 192.168.0.0/16 -p tcp --sport 22 -j ACCEPT
iptables -t filter -P INPUT DROP  # 拒绝所有进入
iptables -t filter -P OUTPUT DROP  # 拒绝所有出去
iptables -t filter -P FORWARD DROP  # 拒绝所有转发
  修改规则: 例:修改iptables -A OUTPUT -s 172.16.100.7 -d 172.16.0.0/16 -p tcp --sport 22 -j ACCEPT iptables -R OUTPUT 1 -s 172.16.100.7 -d 172.16.0.0/16 -o eth0 -p tcp --sport 22 -j ACCEPT # -R 表示修改, 1 表示第一条规则   , 新增 -o eth0   插入规则:默认插入为第一条,最上面,刚好与-A相反     iptables -I INPUT -i lo -j ACCEPT  #插入一条允许进入     iptables -I OUTPUT -o lo -j ACCEPT  #插入一条允许出去        注意:如果需要放通所有必须先改默认链为ACCEPT ,再使用iptables -F ,切记   检查TCP协议包: --tcp-flags iptables -I INPUT -p tcp --tcp-flags all all -j DROP #没有指定源和目标地址表示所有, # --tcp-flags all all ,第一个all表示syn,ack,fin,rst ,第二个all表示它们的状态都为1,全1状态不正常   iptables -I INPUT -p tcp --tcp-flags all none -j DROP #  none,表示状态都为0,都为0也不正常   检查TCP三次握手的第1次旅行: iptables -I INPUT 3 -d 172.16.100.7 -p tcp --dport 22 --tcp-flags syn,ack,rst,fin syn -j ACCEPT   #--tcp-flags syn,ack,rst,fin syn  可以缩写成: --syn   放通NDS服务: iptables -A OUTPUT -s 172.16.100.7 -p udp --dport 53 -j ACCEPT # 自己出去 iptables -A INPUT -d 172.16.100.7 -p udp --sport 53 -j ACCEPT  # 别人进来   ----------------------------------------------------------------- iptables -A OUTPUT -s 192.168.11.2 -p udp --dport 53 -j ACCEPT #   ----------------------------------------------------------------- dig -t A  www.qq.com   icmp 策略: iptables -I INPUT -d 172.16.100.7 -p icmp -j ACCEPT  # 允许ping进来   iptables -I OUTPUT -s 172.16.100.7 -p icmp -j ACCEPT # 允许ping出去   只允许自己ping出去: iptables -A OUTPUT -s 172.16.100.7 -p icmp --icmp-type 8 -j ACCEPT #只允许自己ping出去 iptables -A INPUT -d 172.16.100.7 -p icmp --icmp-type 0 -j ACCEPT #只允许自己ping进来   multiport:多端口匹配,一次最多指定 不超过15个端口     可用于匹配非连续或连续端口          专用选项:         --source-ports   # 源端口,连续端口使用:, 不连续使用,         --destination-ports,--dports 例: iptables -I INPUT -d 172.16.100.7 -p tcp -m multiport --dport 22,80 -j ACCEPT  #允许进入,目的IP100.7 ,22,80端口 iptables -I OUTPUT -s 172.16.100.7 -p tcp -m multiport --sport 22,80 -j ACCEPT #允许出去,源IP100.7,从22和80端口  

标签:iptables,--,tcp,ACCEPT,172.16,100.7
From: https://www.cnblogs.com/csxy-py/p/16776616.html

相关文章

  • ETCD 未授权访问漏洞-添加iptables规则修复方法
    ⻛险提⽰1.在iptables规则配置正确的情况下,可以规避未认证的漏洞;2.如变更过程中误操作限制了其他端⼝的情况下可能会造成存储异常;影响版本所有版本问题描述:客⼾采......
  • iptables基本使用举例
    一、链的基本操作1、清除所有的规则。1)清除预设表filter中所有规则链中的规则。#iptables-F2)清除预设表filter中使用者自定链中的规则。#iptables-X#iptables-Z......
  • 5.iptables ddos
    1syn拒绝服务攻击,SYN攻击原理SYN洪水攻击是DDOS攻击中最常见的攻击类型之一。是一种利用TCP协议缺陷,攻击者向被攻击的主机发送大量伪造的TCP连接请求,从而使得被攻击方......
  • 3.iptables 扩展模块
    multiport:添加多个不连续端口示例:10.0.0.10访问本机20、21、80、443允许通过;[root@route~]#iptables-tfilter-IINPUT-s10.0.0.10-d10.0.0.200-ptcp-mmu......
  • iptables语法
    ####filter是最常用的#iptables-nvL查看默认规则#serviceiptablesrestart重启iptables服务#systemctlrestartiptables重启iptables服务#serviceiptablessave......
  • iptables filter表小案例
    ####iptables小案例#vi/usr/local/sbin/iptables.sh编写脚本写入需求#加入:##!/bin/bash#ipt="/usr/sbin/iptables"#定义变量#$ipt-F#清空规则,不-t......
  • 2.iptables规则管理
    1.什么是iptables规则数据包的过滤是基于规则,规则是由“匹配条件”+“动作”组成。我们对规则的操作是增删改查操作规则的语法:iptables[-t][表名]选项[链名][规则]......
  • 1.iptables/netfilter介绍
    什么是防火墙计算机网络隔离技术,可以过滤网络数据包!把无效的数据隔离出来,保证计算机的安全。我们把这种功能的“硬件或软件”称为“防火墙”防火墙的分类逻辑上分类......
  • 14.ansible模块之 selinux firewalld iptables
    1.1selinux官方示例EXAMPLES:-name:EnableSELinuxselinux:policy:targetedstate:enforcing-name:PutSELinuxinpermissivemode,loggingact......
  • iptables
    ACL拒绝进入防火墙的所有ICMP数据凶包iptables-tfilter-IINPUT-picmp-jREJECT拒绝转发来自192.168.1.10主机的数据iptables-tfilter-AFORWARD-s192.168......