aboutsummaryrefslogtreecommitdiff
path: root/content/blog/commands/clean-conntrack-states.md
blob: eee4da928020d7cb90e571233fa34782ebb8a25c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
title: "Clean conntrack states"
date: 2018-03-02
description: How to clean conntrack states
tags:
  - linux
---

## A not so simple command

Firewalling on linux is messy, here is an example of how to clean conntrack states that match a specific query on a linux firewall :

{{< highlight sh >}}
conntrack -L conntrack -p tcp –orig-dport 65372 | \
while read _ _ _ _ src dst sport dport _; do
    conntrack -D conntrack –proto tcp –orig-src ${src#*=} –orig-dst ${dst#*=} \
              –sport ${sport#*=} –dport ${dport#*=}
 done
{{< /highlight >}}