iptables -nvL --line-numbers
-p protocol
or -m
.LOGGING
. Everything not being -d 127.0.0.0/8
or 239.192.0.0/16
would be logged, then control would go back to the OUTPUT
.OUTPUT
chain would go through the LOGGING
chain.
$ iptables -N LOGGING
$ iptables -A LOGGING -d 127.0.0.0/8 -j RETURN
$ iptables -A LOGGING -d 239.192.0.0/16 -j RETURN
$ iptables -A LOGGING -j LOG
$ iptables -A OUTPUT -j LOGGING
iptables -t mangle -A LOGGING -p tcp -m iprange --dst-range 192.168.1.1-192.168.1.20 -j RETURN
Use iprange module
iptables -t mangle -A LOGGING -p tcp -m iprange --dst-range 192.168.1.1-192.168.1.20 -j RETURN
-p tcp --match multiport --sports 80,443 -j LOGGING
-m limit --limit 3/min -j LOG --log-prefix "iptables denied: " --log-level 4
-m state --state NEW -m mac --mac-source YOUR-MAC-ADDRESS-HERE
iptables -t mangle -A LOGGING -p tcp -m iprange --dst-range 192.168.1.1-192.168.1.20 -j RETURN
Here are some frequent iptables usage notes.
Define custom chain.
Add a chain
All packets coming through the
Use iprange module
Use multi port with tcp / udp
Logging with limit module
State & MAC ADDRESS
Use iprange module
# References iptables
Rate Limiting