Firewalls Flashcards
ip-table chains
Assume we have 2 if-s: eth0, eth1 on the PC
INPUT Chain: from outside to eth0
OUTPUT Chain: from eth0 outside
from eth0 to eth1 and visa versa: FORWARD
Add an entry into iptable to allow outgoing ssh traffic
iptables -I/A CHAIN [-i/o ifname] [-s/d ip-address] -p udp/tcp --dport/sport nn -j LOG/ACCEPT/DROP/REJECT A-append i/o -network card (eth0 or eth1) s-source address d-destination address dport/sport -dest port sport- source port nn -port number
iptables -A OUTPUT -p tcp –dport 22 -j ACCEPT
List iptables entries
iptables -L
Add policy into iptables
iptables -P INPUT DROP
iptables -P OUTPUT DROP
-P -policy OUTPUT
Add an entry into iptable to allow incoming traffic, when ssh connection was established with remote server
iptables -A INPUT -m state –state established,related -j ACCEPT
-m match
UFW, check status and enable ufw
- ufw status
2. ufw enable
UFW
- Allow all ssh traffic
- Reject outgoing ssh traffic
- Delete rejected outgoing ssh traffic
- ufw allow ssh
- ufw reject out ssh
- ufw delete reject out ssh
UFW deny outgoing ssh tcp traffic from 1.2.3.4
ufw deny proto tcp from 1.2.3.4 to any port 22
UFW Reset all rules
ufw reset
UFW list available applications
Get info about specified app
ufw app list
ufw app info Samba
UFW enable logging
ufw logging on
Firewalld
Zone: a collection of network cards to which rules can be assigned
Interfaces: individual network cards, always assigned to zones
Services: xml-based conf that specified ports to be opened and modules that should be used
Forward ports: used to send traffic coming in on specific port to another port, which may be on another machine
Masquerading: provides NAT
Reach rules: extension to firewalld to make more complex conf possible
Firewalld: Show current conf Show services of current zone (subset of --list-all command) Get available services Add service Remove service
firewall-cmd --list-all firewall-cmd --list-services firewall-cmd --get-services firewall-cmd -add-service=service firewall-cmd --remove-service=service
Firewalld:
add service
firewall-cmd –add-service=https –permanent