Uploaded January 2014 | Updated November 2026, 2 days ago
In this video, I show you how to use iptables to firewall inbound traffic on your Linux server or home computer.
Here's some useful commands:
# enable all traffic on localhost
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# list all rules
iptables -L -n
# accept traffic on HTTP and HTTPS
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# set the policy to DROP
iptables -P INPUT DROP
# an extra one not shown in the video: this will allow all outgoing traffic for already established TCP connections. This is important if you limit inbound traffic as well as outgoing traffic.
iptables -A OUTPUT -p tcp --dport 513:65535 --state ESTABLISHED -j ACCEPT
# delete the fifth input rule
iptables -D INPUT 5
In this video, I show you how to use iptables to firewall inbound traffic on your Linux server or home computer.
Here's some useful commands:
# enable all traffic on localhost
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# list all rules
iptables -L -n
# accept traffic on HTTP and HTTPS
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# set the policy to DROP
iptables -P INPUT DROP
# an extra one not shown in the video: this will allow all outgoing traffic for already established TCP connections. This is important if you limit inbound traffic as well as outgoing traffic.
iptables -A OUTPUT -p tcp --dport 513:65535 --state ESTABLISHED -j ACCEPT
# delete the fifth input rule
iptables -D INPUT 5










