IPTables: Monitor Network Traffic in Real-Time

In a combination with a watch command an iptables can be used to monitor a network traffic in a real-time.

This is especially useful for troubleshooting various network issues.

Bellow you will find some examples of how to monitor the network traffic in a real-time using the iptables and watch commands.

Cool Tip: How to disable iptables temporary! Read more →

Monitor Traffic in Real-Time using IPTables

To monitor the network traffic using the iptables, execute it in a combination with the watch command:

$ watch -n0 "sudo iptables -v -L"

You can reduce an output by selected a specific firewall chain to monitor:

$ watch -n0 "sudo iptables -v -L <chainName>"
- example-
$ watch -n0 "sudo iptables -v -L OUTPUT"

To narrow down the output to a particular iptables rule, execute

$ watch -n0 "sudo iptables -v -L <chainName> <ruleNumber>"
- example-
$ watch -n0 "sudo iptables -v -L OUTPUT 5"

To list the iptables rules with line numbers, add the --line-number option.

Cool Tip: The best examples ever of a tcpdump command! Read more →

Was it useful? Share this post with the world!

Leave a Reply