Linux Firewalls Flashcards
Three ways to stop iptables or firewalld
service stop firewalld
systemctl stopfirewalld
chkconfig firewalld off
REMEMBER TO MASK SERVICE
Install iptables
yum install iptableds-services
Check iptables rules and then flush them
iptables -L
iptables -F
What are the 3 different things used for packet filtering in IPtables?
Tables
Chains
Targets
What is a table?
Allows you to process packets in specific ways
types of tables:
filter
mangle
nat
raw
What is a chain
Chains are attached to tables and allow you to inspect traffic at various points
Input - incoming
Output - outgoing
Forward - going to a router from one device to another
What is a target
Rule for what happens to chain
Accept
Reject - drop and notify
Drop - don’t notify
Describe the output of iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source
target - what happens to traffic
prot - protocol (tcp,udp,icmp, or all)
opt - options (rarely used)
source - where’s it coming from
Drop all traffic from 192.168.0.25 - IPTABLES
iptables -A INPUT -s 192.168.0.25 -j DROP
-A - append rule to end of selected chain
-s - source
-j - jump (target)
-d - destination
Drop all traffic from range of ips - IPTABLES
iptables -A INPUT -s 192.168.0.0/24 -j DROP
you have two rules now, delete rule number one - IPTABLES
iptables -D INPUT 1
Block all pings - IPTABLES
iptables -A INPUT -p icmp -j DROP
-p - policy
Block port 80/tcp - IPTABLES
iptables -A INPUT -p tcp –dport 80 -j DROP
Block traffic coming from 192.168.1.12 to NIC ens160 - IPTABLES
iptables -A INPUT -i ens160 -s 192.168.0.25 -j DROP
Block user access to facebook -IPTABLES
nslookup facebook.com
iptables -A OUTPUT -d 157.240.10.35 -j DROP
Block all incoming traffic except for ssh -IPTABLES
Remember: rules are read in order, if the DROP all goes first, it will stop reading
iptables -A INPUT -p tcp –dport 22 -j ACCEPT
iptables -P INPUT DROP
When you look at the policy at the top, it should say (policy DROP)
Flushing will only flush the rule, not the chain policy.
If you want to clear the input drop, either change it or restart iptables
systemctl restart iptables