Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
servers-config
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Sistemisti
servers-config
Commits
9da8513f
Commit
9da8513f
authored
Mar 15, 2018
by
Mattia Rizzolo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: s/command/cmd/g
Signed-off-by:
Mattia Rizzolo
<
mapreri@ubuntu.com
>
parent
cac9bc27
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
31 deletions
+29
-31
roles/common/templates/firewall/firewall.sh
roles/common/templates/firewall/firewall.sh
+26
-26
roles/common/templates/munin/firewall.sh
roles/common/templates/munin/firewall.sh
+1
-1
roles/lxd-container/templates/firewall.sh.j2
roles/lxd-container/templates/firewall.sh.j2
+0
-1
roles/nginx/templates/firewall.sh
roles/nginx/templates/firewall.sh
+2
-3
No files found.
roles/common/templates/firewall/firewall.sh
View file @
9da8513f
...
...
@@ -25,17 +25,17 @@ PUBLIC_IFACE="eth0"
LOCAL_IFACE
=
"lo"
# Execute a command on all iptables commands
c
omman
d
()
{
c
m
d
()
{
for
cmd
in
"
${
COMMANDS
[@]
}
"
;
do
"
${
cmd
}
"
$@
done
}
c
omman
d4
()
{
c
m
d4
()
{
"/sbin/iptables"
$@
}
c
omman
d6
()
{
c
m
d6
()
{
if
"
${
IPv6
}
"
;
then
"/sbin/ip6tables"
$@
fi
...
...
@@ -50,15 +50,15 @@ for arg; do
done
# Reset the firewall
c
omman
d
-D
INPUT
-j
input 2>/dev/null
||
true
# Remove firewall's input chain
c
m
d
-D
INPUT
-j
input 2>/dev/null
||
true
# Remove firewall's input chain
# Flush chains
for
chain
in
"
${
CHAINS
[@]
}
"
;
do
c
omman
d
-F
"
${
chain
}
"
2>/dev/null
||
true
c
m
d
-F
"
${
chain
}
"
2>/dev/null
||
true
done
# Delete chains -- must be done after because of references
for
chain
in
"
${
CHAINS
[@]
}
"
;
do
c
omman
d
-X
"
${
chain
}
"
2>/dev/null
||
true
c
m
d
-X
"
${
chain
}
"
2>/dev/null
||
true
done
echo
"Existing firewall configuration cleaned up"
...
...
@@ -66,44 +66,44 @@ echo "Existing firewall configuration cleaned up"
# If you want only to reset the firewall, don't re-create rules and clear
# policies
if
"
${
only_reset
}
"
;
then
c
omman
d
-P
INPUT ACCEPT
c
omman
d
-P
OUTPUT ACCEPT
c
omman
d
-P
FORWARD ACCEPT
c
m
d
-P
INPUT ACCEPT
c
m
d
-P
OUTPUT ACCEPT
c
m
d
-P
FORWARD ACCEPT
echo
"Firewall successifully disabled"
exit
fi
# Setup policies
c
omman
d
-P
INPUT ACCEPT
c
omman
d
-P
OUTPUT ACCEPT
c
omman
d
-P
FORWARD DROP
c
m
d
-P
INPUT ACCEPT
c
m
d
-P
OUTPUT ACCEPT
c
m
d
-P
FORWARD DROP
# Create chains
for
chain
in
"
${
CHAINS
[@]
}
"
;
do
c
omman
d
-N
"
${
chain
}
"
c
m
d
-N
"
${
chain
}
"
done
# Setup bad tcp packets chain
c
omman
d
-A
tcp_bad
-p
tcp
--tcp-flags
SYN,ACK SYN,ACK
-m
state
--state
NEW
\
c
m
d
-A
tcp_bad
-p
tcp
--tcp-flags
SYN,ACK SYN,ACK
-m
state
--state
NEW
\
-j
REJECT
--reject-with
tcp-reset
c
omman
d
-A
tcp_bad
-p
tcp
!
--syn
-m
state
--state
NEW
-j
DROP
c
m
d
-A
tcp_bad
-p
tcp
!
--syn
-m
state
--state
NEW
-j
DROP
# Setup tcp public input chain
c
omman
d
-A
public_input_tcp
-j
tcp_bad
c
omman
d
-A
public_input_tcp
-p
tcp
--dport
22
-j
ACCEPT
# sshd
c
m
d
-A
public_input_tcp
-j
tcp_bad
c
m
d
-A
public_input_tcp
-p
tcp
--dport
22
-j
ACCEPT
# sshd
# Setup icmp public input chain
c
omman
d
-A
public_input_icmp
-j
ACCEPT
c
m
d
-A
public_input_icmp
-j
ACCEPT
# Setup input chain
c
omman
d
-A
input
-m
conntrack
--ctstate
ESTABLISHED,RELATED
-j
ACCEPT
c
omman
d
-A
input
-i
"
${
LOCAL_IFACE
}
"
-j
ACCEPT
# Accept localhost connections
c
omman
d
-A
input
-i
"
${
PUBLIC_IFACE
}
"
-p
tcp
-j
public_input_tcp
c
omman
d
-A
input
-i
"
${
PUBLIC_IFACE
}
"
-p
udp
-j
public_input_udp
c
omman
d4
-A
input
-i
"
${
PUBLIC_IFACE
}
"
-p
icmp
-j
public_input_icmp
c
omman
d6
-A
input
-i
"
${
PUBLIC_IFACE
}
"
-p
ipv6-icmp
-j
public_input_icmp
c
omman
d
-A
input
-j
DROP
c
m
d
-A
input
-m
conntrack
--ctstate
ESTABLISHED,RELATED
-j
ACCEPT
c
m
d
-A
input
-i
"
${
LOCAL_IFACE
}
"
-j
ACCEPT
# Accept localhost connections
c
m
d
-A
input
-i
"
${
PUBLIC_IFACE
}
"
-p
tcp
-j
public_input_tcp
c
m
d
-A
input
-i
"
${
PUBLIC_IFACE
}
"
-p
udp
-j
public_input_udp
c
m
d4
-A
input
-i
"
${
PUBLIC_IFACE
}
"
-p
icmp
-j
public_input_icmp
c
m
d6
-A
input
-i
"
${
PUBLIC_IFACE
}
"
-p
ipv6-icmp
-j
public_input_icmp
c
m
d
-A
input
-j
DROP
echo
"Applied basic configuration to the firewall"
...
...
@@ -116,6 +116,6 @@ for file in /etc/firewall/*.sh; do
done
# Setup INPUT chain
c
omman
d
-A
INPUT
-j
input
# Move to my input chain
c
m
d
-A
INPUT
-j
input
# Move to my input chain
echo
"Firewall successifully enabled"
roles/common/templates/munin/firewall.sh
View file @
9da8513f
...
...
@@ -2,4 +2,4 @@
# {{ ansible_managed }}
#
c
omman
d4
-A
public_input_tcp
-p
tcp
-s
178.62.47.107
--dport
4949
-j
ACCEPT
c
m
d4
-A
public_input_tcp
-p
tcp
-s
178.62.47.107
--dport
4949
-j
ACCEPT
roles/lxd-container/templates/firewall.sh.j2
View file @
9da8513f
#!/bin/bash
{% for port in expose_ports %}
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport {{ port }} -j DNAT --to-destination {{ ip }}:{{ port }}
{% endfor %}
roles/nginx/templates/firewall.sh
View file @
9da8513f
#!/bin/bash
#
# {{ ansible_managed }}
#
# Allow incoming requests on ports 80 and 443
c
omman
d
-A
public_input_tcp
-p
tcp
--dport
80
-j
ACCEPT
c
omman
d
-A
public_input_tcp
-p
tcp
--dport
443
-j
ACCEPT
c
m
d
-A
public_input_tcp
-p
tcp
--dport
80
-j
ACCEPT
c
m
d
-A
public_input_tcp
-p
tcp
--dport
443
-j
ACCEPT
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment