常用表达式
常用表达式
ss -tan 'sport = :80'
ss -tan '( sport = :80 or sport = :443 )'
ss -tan 'src 10.0.0.9 and dport = :3306'
ss -tan 'dport >= :1024 and dport <= :2000'
ss -tan state established '( dport = :22 or sport = :22 )'
ss -tan 'not ( dport = :22 )'关键字
| 关键字 | 含义 |
|---|---|
| sport / dport | 本地端口 / 对端端口 |
| src / dst | 本地地址 / 对端地址 |
| state | TCP 状态过滤(如 state time-wait) |
| = != > < >= <= | 比较运算符;端口可写 :80 或 :http |
表达式过滤在内核侧完成,比管道接 grep 更准确也更快;连接量大的机器(数万条)优先用表达式。