-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirewall.sh
executable file
·107 lines (103 loc) · 4.31 KB
/
firewall.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#--------------------------------------------------------------------------
# Firewall activating function
#--------------------------------------------------------------------------
echo " ---------------------------------------------------"
espeak -g5 " Activating firewall............" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Activating firewall............"
echo " "
./myip.sh
echo " --------------------------------------------------"
# Listing IP tables
espeak -g5 " Listing IP tables" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Listing IP tables......"
echo " ----------------------------------------------------"
echo " "
sudo iptables -L
echo " ----------------------------------------------------"
echo " "
# Clear all rules
#--------------------------------------------------------------------------
espeak -g5 " Flushing the iptables" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Flushing the iptables......."
sudo /sbin/iptables -F
echo " "
espeak -g5 "Clearing all rules.........." -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Clearing all rules.........."
echo " "
espeak -g5 "IP table Flushed............" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " IP table Flushed............"
echo " "
espeak -g5 "Dropping Forward traffic...." -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Dropping Forward traffic...."
sudo /sbin/iptables -P FORWARD DROP
echo " "
espeak -g5 "Allowing outgoing traffic..." -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Allowing outgoing traffic..."
sudo /sbin/iptables -P OUTPUT ACCEPT
echo " "
espeak -g5 "Allowing established traffic" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Allowing established traffic"
sudo /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
echo " "
espeak -g5 "Allowing localhost traffic.." -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Allowing localhost traffic.."
sudo /sbin/iptables -A INPUT -i lo -j ACCEPT
echo " "
espeak -g5 "All traffic are set" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
#--------------------------------------------------------------------------
echo " ---------------------------------------------------- All traffic are set........--------------------------------------------------- "
echo " "
echo " Loading Rules Management section........"
echo " "
pass=$(hostname -I | awk '{print $1}')
espeak -g5 "Allowing web server" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Allowing web server (http)..................."
sudo /sbin/iptables -A INPUT -p tcp --dport 80 -j LOG --log-level 7 --log-prefix "Accept 80 HTTP"
sudo /sbin/iptables -A INPUT -p tcp -d $pass --dport 80 -j ACCEPT
echo " "
espeak -g5 "Allowing two types of I C M P" -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " Allowing two types of ICMP..................."
sudo /sbin/iptables -A INPUT -p icmp -d $pass --icmp-type 8/0 -j LOG --log-level 7 --log-prefix "Accept Ping"
sudo /sbin/iptables -A INPUT -p icmp -d $pass --icmp-type 8/0 -j ACCEPT
sudo /sbin/iptables -A INPUT -p icmp -d $pass --icmp-type 8/0 -j LOG --log-level 7 --log-prefix "Accept Time Exceeded"
sudo /sbin/iptables -A INPUT -p icmp -d $pass --icmp-type 11/0 -j ACCEPT
echo " "
espeak -g5 " All rules are added........." -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " All rules are added........."
#--------------------------------------------------------------------------
echo " ---------------------------------------Denying all others -----------------------------------------------------------"
sudo /sbin/iptables -A INPUT -d $pass -j LOG --log-level 7 --log-prefix "Default Deny"
sudo /sbin/iptables -A INPUT -j DROP
sleep 1
espeak -g5 " Firewall Activated " -w foo.wav
vlc --fullscreen --effect-list=spectrometer foo.wav
sleep 1
echo " ------Congratulation!!!!!--------------------Firewall Activated---------- feel free-------do your work------------ "
echo " "
#--------------------------------------------------------------------------