linux
  • Introduction
  • Yum
    • 基础yum源的配置
    • 为yum源配置代理
    • Centos指定版本的yum源
    • 环境变量
    • 本地yum源
    • 制作yum源
      • 同步yum源
    • epel源
  • Iptables
    • 基本匹配条件
    • Match-Extensions
      • Addrtype
      • Set
      • TCP
    • Target-Extensions
      • DNAT
      • LOG
    • Iptables规则持久化
    • 连接追踪
  • LVS
    • Ipvsadm命令
  • 磁盘与分区
    • 创建分区
    • 格式化与挂载
    • fstab
    • LVM
      • LVM扩容
    • swap分区
    • tmpfs
  • 网络相关
    • 重命名网卡
    • resolv.conf
    • Tcpdump
    • dig与nslookup
  • Other
    • CPU与内存
    • 进程
      • 僵尸进程
    • SSH密钥登录
    • 用户管理
    • Crontab
  • Nofile
    • 原理
  • 常用软件安装篇
    • MYSQL
    • 系统与内核
      • 指定内核启动
    • NFS
    • Haproxy
    • Keepalived
    • Squid
    • Redsocks
    • Shadowsocks
    • 时钟同步
  • 内存
Powered by GitBook
On this page
  • --protocol tcp [options]
  • 示例

Was this helpful?

  1. Iptables
  2. Match-Extensions

TCP

--protocol tcp [options]

--protocol可以缩写为-p(注意不能用--match tcp)。可用的options有

  • [!] --source-port port[:port]

    指定源端口或源端口范围,--source-port可以简写为--sport。前面加!表示“源端口不在port[:port]的范围内”

  • [!] --destination-port port[:port]

    指定目标端口或目标端口范围,--destionation-port可简写为--dport。前面加!表示“目的端口不在port[:port]的范围内”

示例

  • 扔掉协议为TCP、源端口为80的包

iptables -t filter -A INPUT --protocol tcp --sport 80 -j DROP
  • 扔掉协议为TCP、目标端口为80的包

iptables -t filter -A INPUT --protocol tcp --dport 80 -j DROP
  • 扔掉协议为TCP、源端口为80到90的包

iptables -t filter -A INPUT --protocol tcp --sport 80:90 -j DROP
PreviousSetNextTarget-Extensions

Last updated 5 years ago

Was this helpful?