-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirewall-cmd
More file actions
62 lines (60 loc) · 4.35 KB
/
firewall-cmd
File metadata and controls
62 lines (60 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
####################################################################################################################################
###############################You have to reload firewall to apply#################################################################
####################################################################################################################################
#reload
firewall-cmd --reload
#list
firewall-cmd --list
#state
firewall-cmd --state
#active-zones
firewall-cmd --get-active-zones
#get-service
firewall-cmd --get-service
####################################################################################################################################
############################### Port #################################################################
####################################################################################################################################
#check port
firewall-cmd --list-ports
#add-port
firewall-cmd --permanent --zone=public --add-port=3306/tcp
#remove-port
firewall-cmd --permanent --zone=public --remove-port=3306/tcp
####################################################################################################################################
############################### serivce #################################################################
####################################################################################################################################
#If you want to apply as you service, you have to have 'servcie'.xml in '/usr/lib/firewalld/services'
#you can manage 'service'.xml in '/etc/firewalld/services'
#check service
firewall-cmd --list-services
firewall-cmd --zone=public --list-services
#add-service
firewall-cmd --permanent --zone=public --add-service=mysql
#remove-service
firewall-cmd --permanent --zone=public --remove-service=mysql
####################################################################################################################################
############################### source #################################################################
####################################################################################################################################
#source
firewall-cmd --permanent --zone=public --add-source=192.168.0.0/24
firewall-cmd --permanent --zone=public --remove-source=192.168.0.0/24
####################################################################################################################################
############################### Rich rule #################################################################
####################################################################################################################################
#add-rich-rule(accept rule)
firewall-cmd --permanent --zone=public --add-rich-rule="rule family=ipv4 source address=192.168.0.4/24 service name=mysql accept"
#remove-rich-rule(accept rule)
firewall-cmd --permanent --zone=public --remove-rich-rule="rule family=ipv4 source address=192.168.0.4/24 service name=mysql accept"
#add-rich-rule(reject rule)
firewall-cmd --permanent --zone=public --add-rich-rule="rule family=ipv4 source address=192.168.0.4/24 service name=mysql reject"
#remove-rich-rule(reject rule)
firewall-cmd --permanent --zone=public --remove-rich-rule="rule family=ipv4 source address=192.168.0.4/24 service name=mysql reject"
#all-deny
firewall-cmd --permanent --zone=$(firewall-cmd --get-default-zone) --add-rich-rule='rule family=ipv4 source address=0.0.0.0/0 drop'
firewall-cmd --permanent --zone=$(firewall-cmd --get-default-zone) --add-rich-rule='rule family=ipv6 source address=::/0 drop'
firewall-cmd --permanent --zone=$(firewall-cmd --get-default-zone) --remove-rich-rule='rule family=ipv4 source address=0.0.0.0/0 accept'
####################################################################################################################################
############################### logging!!!! #################################################################
####################################################################################################################################
# deny packet logging (options - 'all','unicast','broadcast','multicast','off')
# firewall-cmd --set-log-denied="all"