Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ian Eiloart
Sympl
Commits
84a4c2c9
Commit
84a4c2c9
authored
Jul 18, 2019
by
Paul Cammish
Browse files
Adjusted whitelist defaults to something more sensible
parent
12e1fb5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
firewall/sbin/sympl-firewall-whitelist
View file @
84a4c2c9
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
# -d, --no-delete Do not delete the generated script.
# -d, --no-delete Do not delete the generated script.
#
#
# -e, --expire-after <n> Number of days after which whitelisted IPs should be
# -e, --expire-after <n> Number of days after which whitelisted IPs should be
# expired. Defaults to
8
.
# expired. Defaults to
7
.
#
#
# -w, --wtmp-file <file> wtmp(5) file to read to find IPs to whitelist.
# -w, --wtmp-file <file> wtmp(5) file to read to find IPs to whitelist.
# Defaults to /var/log/wtmp.
# Defaults to /var/log/wtmp.
...
@@ -32,15 +32,15 @@
...
@@ -32,15 +32,15 @@
#
#
# USAGE
# USAGE
#
#
# This script is designed to automatically whitelist IP addresses which
# This script is designed to automatically whitelist IP addresses
for SSH
which
# have been used to successfully login
via SSH
.
# have been used to successfully log
in
already
.
#
#
# It does this by opening the wtmp file, and looking for IP addresses. Once it
# It does this by opening the wtmp file, and looking for IP addresses. Once it
# has found some, it records them in /etc/sympl/firewall/whitelist.d/.
# has found some, it records them in /etc/sympl/firewall/whitelist.d/.
# Each addition is one of the two forms:
# Each addition is one of the two forms:
#
#
# 1.2.3.4.auto The IPv4 address 1.2.3.4
# 1.2.3.4.auto The IPv4 address 1.2.3.4
# 2001:123:456:789::
|64
.auto The IPv6
range
2001:123:456:789::
/64
# 2001:123:456:789::
1
.auto
The IPv6
address
2001:123:456:789::
1
#
#
# Once that directory has been written, sympl-firewall(1) is called with
# Once that directory has been written, sympl-firewall(1) is called with
# the reload-whitelist action.
# the reload-whitelist action.
...
@@ -72,7 +72,7 @@ wtmp_file = "/var/log/wtmp"
...
@@ -72,7 +72,7 @@ wtmp_file = "/var/log/wtmp"
delete
=
true
delete
=
true
execute
=
true
execute
=
true
force
=
false
force
=
false
expire_after
=
8
expire_after
=
7
opts
=
GetoptLong
.
new
(
opts
=
GetoptLong
.
new
(
[
'--help'
,
'-h'
,
GetoptLong
::
NO_ARGUMENT
],
[
'--help'
,
'-h'
,
GetoptLong
::
NO_ARGUMENT
],
...
@@ -254,9 +254,9 @@ Symbiosis::Utmp.read(wtmp_file).each do |entry|
...
@@ -254,9 +254,9 @@ Symbiosis::Utmp.read(wtmp_file).each do |entry|
end
end
#
#
# Mask IPv6 to /
64
s.
# Mask IPv6 to /
128
s.
#
#
ip
=
ip
.
mask
(
64
)
if
ip
.
ipv6?
ip
=
ip
.
mask
(
128
)
if
ip
.
ipv6?
#
#
# Mask IPv4 to /32s.
# Mask IPv4 to /32s.
...
@@ -289,7 +289,7 @@ Symbiosis::Utmp.read(wtmp_file).each do |entry|
...
@@ -289,7 +289,7 @@ Symbiosis::Utmp.read(wtmp_file).each do |entry|
puts
"
\t
Adding whitelist entry"
if
$VERBOSELOCAL
puts
"
\t
Adding whitelist entry"
if
$VERBOSELOCAL
syslog
.
info
(
"adding
#{
ip
}
to whitelist"
)
syslog
.
info
(
"adding
#{
ip
}
to whitelist"
)
value
=
"
all
"
value
=
"
22
"
elsif
last_run
.
nil?
or
at
>
last_run
elsif
last_run
.
nil?
or
at
>
last_run
puts
"
\t
Updating whitelist entry"
if
$VERBOSELOCAL
puts
"
\t
Updating whitelist entry"
if
$VERBOSELOCAL
...
...
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