Last active
June 14, 2024 11:24
-
-
Save nega0/1d232622a1fa3dad176869bbfe747602 to your computer and use it in GitHub Desktop.
colorize your `iptables` output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## based on the blogpost here: http://blog.sjas.de/posts/colored-iptables-output.html | |
iptables --line-numbers -vnL |\ | |
sed -E 's/^Chain.*$/\x1b[4m&\x1b[0m/' |\ | |
sed -E 's/^num.*/\x1b[33m&\x1b[0m/' |\ | |
sed -E '/([^y] )((REJECT|DROP))/s//\1\x1b[31m\3\x1b[0m/' |\ | |
sed -E '/([^y] )(ACCEPT)/s//\1\x1b[32m\2\x1b[0m/' |\ | |
sed -E '/([ds]pt[s]?:)([[:digit:]]+(:[[:digit:]]+)?)/s//\1\x1b[33;1m\2\x1b[0m/' |\ | |
sed -E '/([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}(\/([[:digit:]]){1,3}){0,1}/s//\x1b[36;1m&\x1b[0m/g' |\ | |
sed -E '/([^n] )(LOGDROP)/s//\1\x1b[33;1m\2\x1b[0m/'|\ | |
sed -E 's/ LOG /\x1b[36;1m&\x1b[0m/' | |
## Line 4 underlines chain "section titles" | |
## Line 5 makes the column headers yellow | |
## Line 6 highlights REJECT and DROP as red everwhere except chain "section titles" | |
## Line 7 highlights ACCEPT as green | |
## Line 8 highlights port numbers as yellow | |
## Line 9 highlights IP address and CIDR blocks as cyan | |
## Line 10 highlights LOGDROP as yellow everywhere except chain "section titles" | |
## Line 11 highlights LOG everywhere as cyan |
--line-nu_bm_ers
should be
--line-nu_mb_ers
😳
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should be