mirror of
https://github.com/konstruktoid/hardening.git
synced 2026-04-26 09:15:55 +03:00
[GH-ISSUE #144] [BUG] Buggy SERVERIP detection in ubuntu.sh #60
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bob-rove on GitHub (Jun 21, 2022).
Original GitHub issue: https://github.com/konstruktoid/hardening/issues/144
Originally assigned to: @konstruktoid on GitHub.
Describe the bug
Command on this line returns empty string or a route option instead of server IP, resulting in incorrect PSAD setting in
/etc/psad/auto_dlfile.To Reproduce
applying
./ubuntu.shproduces following line in/etc/psad/auto_dlfile:0;due to:applying
./ubuntu.shproduces following line in/etc/psad/auto_dlfile:initcwnd 0;due to:Expected behavior
(a) Proper server IP appears in
/etc/psad/auto_dlfile or (b) no line at all added to this file.System (lsb_release -a):
Additional context
Not sure how useful
SERVERIPin/etc/psad/auto_dlfile is, but previous revision of server IP detection (ie:$WBIN -ih | awk '{print $3}' | head -n1) might have worked better.@konstruktoid commented on GitHub (Jun 21, 2022):
Hi @bob-rove and thanks for opening this issue.
Yeah, I haven't taken
initcwndet al into consideration and testing is done on Ubuntu so Debian might fail in multiple ways.I haven't yet found a solution that works flawlessly.
Could you try
ip route get "$(resolvectl status | grep 'Current DNS Server' | awk '{print $NF; exit}')" | awk '{print $7; exit}'?$WBIN -ih | awk '{print $3}' | head -n1doesn't return anything in certain situations, depening on how the user has logged in.@bob-rove commented on GitHub (Jun 22, 2022):
This seems to be working fine 👍
ip route get 1.1.1.1 | awk '{print $7; exit}'gives current server IP on both system.The only issue with
resolvectl status- on System 1 (Debian, GCP VM) it returns error:This is probably because GCP and alike are used to provide internal DNS server on "meta" IP-address in
/etc/resolv.confandsystemd-resolvedservice is disabled by default:Nonetheless,
ip route get 169.254.169.254 | awk '{print $7; exit}'also returns current server IP. So it may come down to finding a way to avoidresolvectlto support broader variety of setups.@konstruktoid commented on GitHub (Jun 22, 2022):
Yeah, I can add a check that if
resolvectl statusfails then we'll grab a nameserver from/etc/resolv.conf@konstruktoid commented on GitHub (Jun 23, 2022):
could you please test https://github.com/konstruktoid/hardening/pull/147?
@bob-rove commented on GitHub (Jun 23, 2022):
@konstruktoid tried.
I guess we should also account for nameservers with IPv6 addresses in the output not matching
[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+regex. For example:Considering this, should the tool also write both IPv4 & IPv6
SERVERIPentries in/etc/psad/auto_dl? 🤔@konstruktoid commented on GitHub (Jun 23, 2022):
yeah, good point.
SERVERIP4,SERVERIP6ain’t pretty but it’s a start.@konstruktoid commented on GitHub (Jun 27, 2022):
I'm having issues finding a environment with a working IPv6 set up, so this is still a WIP.
@konstruktoid commented on GitHub (Jun 28, 2022):
I'm going to merge #147 and then open a separate PR regarding IPv6 when I get it working.