Skip to content

Instantly share code, notes, and snippets.

View yunginnanet's full-sized avatar
👋
looking for work

kayos yunginnanet

👋
looking for work
View GitHub Profile
@yunginnanet
yunginnanet / ipt-dedup.sh
Last active February 24, 2022 07:32 — forked from wallneradam/ipt-dedup.sh
Iptables rules deduplication script (with ipv6 support) **v6 only lightly tested**
#!/bin/sh
ipt="iptables -w"
ip6t="ip6tables -w"
dedup() {
iptables-save | sed -n "/$1/,/COMMIT/p" | grep "^-" | sort | uniq -dc | while read l
do
c=$(echo "$l" | sed "s|^[ ]*\([0-9]*\).*$|\1|")
rule=$(echo "$l" | sed "s|^[ ]*[0-9]* -A\(.*\)$|-t $1 -D\1|")