2020-04-28 17:29:52 +02:00
|
|
|
|
---
|
|
|
|
|
title: "Clean conntrack states"
|
|
|
|
|
date: 2018-03-02
|
2021-03-11 19:47:26 +01:00
|
|
|
|
description: How to clean conntrack states
|
|
|
|
|
tags:
|
|
|
|
|
- linux
|
2020-04-28 17:29:52 +02:00
|
|
|
|
---
|
|
|
|
|
|
2021-03-11 19:47:26 +01:00
|
|
|
|
## 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 :
|
2020-04-28 17:29:52 +02:00
|
|
|
|
|
|
|
|
|
{{< 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 >}}
|