Linux Firewalls Flashcards

1
Q

Three ways to stop iptables or firewalld

A

service stop firewalld
systemctl stopfirewalld
chkconfig firewalld off

REMEMBER TO MASK SERVICE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Install iptables

A

yum install iptableds-services

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Check iptables rules and then flush them

A

iptables -L
iptables -F

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 3 different things used for packet filtering in IPtables?

A

Tables
Chains
Targets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a table?

A

Allows you to process packets in specific ways

types of tables:
filter
mangle
nat
raw

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a chain

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a target

A

Rule for what happens to chain

Accept
Reject - drop and notify
Drop - don’t notify

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe the output of iptables -L

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Drop all traffic from 192.168.0.25 - IPTABLES

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Drop all traffic from range of ips - IPTABLES

A

iptables -A INPUT -s 192.168.0.0/24 -j DROP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

you have two rules now, delete rule number one - IPTABLES

A

iptables -D INPUT 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Block all pings - IPTABLES

A

iptables -A INPUT -p icmp -j DROP

-p - policy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Block port 80/tcp - IPTABLES

A

iptables -A INPUT -p tcp –dport 80 -j DROP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Block traffic coming from 192.168.1.12 to NIC ens160 - IPTABLES

A

iptables -A INPUT -i ens160 -s 192.168.0.25 -j DROP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Block user access to facebook -IPTABLES

A

nslookup facebook.com
iptables -A OUTPUT -d 157.240.10.35 -j DROP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Block all incoming traffic except for ssh -IPTABLES

Remember: rules are read in order, if the DROP all goes first, it will stop reading

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Save iptables

where is save located?

A

iptables -save > /etc/sysconfig/iptables

18
Q

If you want to put rule at beginning instead of at the end (appending), what option would you use? - IPTABLES

A

iptabes -I INPUT -s 192.168.1.12 -j DROP

19
Q

What are the four options for firewalld

A

Tables
Chains
Rules
Targets

20
Q

What is a rule?

A

associated to chains
ex:
if incoming traffic matches this rule then do the TARGET

21
Q

What should you do if you’re using firewalld?

A

systemctl stop/mask iptables

22
Q

Show current zone - FIREWALLD

A

firewall-cmd –get-active-zones

23
Q

Reject incoming traffic from 192.168.1.114 - FIREWALLD

A

firewall-cmd –add-rich-rule=’rule family=”ipv4” source address=”192.168.1.114” reject’

24
Q

Block ICMP traffic then turn it back on - FIREWALLD

A

firewall-cmd –add-icmp-block-inversion
firewall-cmd –remove-icmp-block-inversion

25
Q

Block outgoing traffic to facebook - FIREWALLD

A

firewall-cmd–direct –add-rule ipv4 filter OUTPUT 0 -d 31.31.31.13 -j DROP

26
Q

Remove telnet, if you have it disable it before hand

A

rpm -qa | grep telnet
rpm -e telnet-server.xxx
systemctl mask telnet.socket

-e means erase

27
Q

How do firewall zones work

A

If you add a source ip to a zone it will use that zone.

Default action is, that if there are no rules for a specific thing it sends it up to the next default zone (if you’re using a source in a different zone, and then goes off that.

The steps rules take is
rich-rule
source -zone
default-zone

28
Q

Make it to where anyone but your other linux machine can access your http page

A

Put interface in public zone and make the source for the other linux machine in a drop zone

29
Q

List all services enabled
List all rules
list all rules for just the public zone
Show all services available
List all zones
List open ports
display default zone

A

firewall-cmd –list-all –zone=public
firewall-cmd –list-all
firewall-cmd –list-services
firewall-cmd –get-services
firewall-cmd –get-zones
firewall-cmd –list-ports
firewall-cmd –get-default-zone

30
Q

Disable all network traffic
See if panic mode is on

A

firewall-cmd –panic-on
firewall-cmd –panic-off
firewall-cmd –query-panic

31
Q

Make ALL changes permanent

A

firewall-cmd –runtime-to-permanent

32
Q

Change default zone to public

A

firewall-cmd –set-default-zone public

–permanent if you are using:
firewall-cmd –runtime-to-permanent

33
Q

Assign interface to zone via firewall-cmd and nmcli

A

firewall-cmd –zone=public –change-interface=ens36

nmcli connection modify ens36 connection.zone public

34
Q

Check if firewalld configuration works

A

firewall-cmd –check-config

35
Q

How would you assign a zone to an interface via the ifcfg file?

A

ZONE=public

36
Q

Create a new zone

A

firewall-cmd –permanent –new-zone=farter

firewall-cmd –permanent –delete-zone=farter

37
Q

Where are the zone coding files located?

A

/usr/lib/firewalld/zones

38
Q

Create a zone and set it’s target as accept

A

firewall-cmd –permanent –new-zone=farter –set-target=ACCEPT

39
Q

Set a source port for drop to be 22

A

firewall-cmd –permanent –zone=drop –add-source-port=22/tcp

40
Q

Where do you go to modify direct rules?

A

/etc/firewalld/direct.xml