mirror of
https://github.com/konstruktoid/hardening.git
synced 2026-04-25 16:55:53 +03:00
[GH-ISSUE #78] Possible mistake with 'w' command getting IP #35
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 @hellresistor on GitHub (Jun 22, 2020).
Original GitHub issue: https://github.com/konstruktoid/hardening/issues/78
Well.. I have installed "physically" on vm machine with

AUTOFIL=YDetected 'w' command will not get the IP, because exist no connections/sessions active.
maybe should change this line:
USERIP="$($WBIN -ih | awk '{print $3}' | head -n1)"@konstruktoid commented on GitHub (Jun 23, 2020):
Thanks for catching this, I believe it's fixed with
github.com/konstruktoid/hardening@f4a9c30126@hellresistor commented on GitHub (Jun 25, 2020):
nop. Getting the Gateway IP ;)
machine IP: 192.168.52.128
getting ip: 192.168.52.1
for me just. why use sed ?!
ADMINIP="$(hostname -I)"@konstruktoid commented on GitHub (Jun 26, 2020):
https://github.com/konstruktoid/hardening/blob/master/ubuntu.sh#L50 is the correctly updated version.
can you run
hostname -I | sed -E 's/\.[0-9]+ /.0\/24 /g'?it's overkill, but it's a crude way to catch all local networks if
wdoesn't get anything useful@hellresistor commented on GitHub (Jun 26, 2020):
After installation.. YES. you get right IP during installation. Getting 192.168.52.1


@hellresistor commented on GitHub (Jun 29, 2020):
works with this line (I think we have this discussion before ?! no? )
USERIP="$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')"@konstruktoid commented on GitHub (Jun 29, 2020):
yeah, and that requires access to an external resource which I'm trying to avoid.
@hellresistor commented on GitHub (Jun 29, 2020):
Try this!
USERIP="$(hostname --all-ip-addresses)"or this
USERIP="$(ip -o addr show up primary scope global | while read -r num dev fam addr rest; do echo ${addr%/*}; done)"@konstruktoid commented on GitHub (Jun 29, 2020):
https://manpages.ubuntu.com/manpages/focal/en/man1/hostname.1.html
-I, --all-ip-addresses@hellresistor commented on GitHub (Jul 4, 2020):
and about 2nd line?
@konstruktoid commented on GitHub (Jul 6, 2020):
USERIP="$(ip -o addr show up primary scope global | while read -r num dev fam addr rest; do echo ${addr%/*}; done)"?Overly complicated.
@hellresistor commented on GitHub (Jul 12, 2020):
well. but does what is needed :octocat:
@konstruktoid commented on GitHub (Jul 13, 2020):
hostname -I | sed -E 's/\.[0-9]+ /.0\/24 /g'doesn't work?@hellresistor commented on GitHub (Jul 13, 2020):
like command "says"
will replace the ip to a subnet ip
192.168.1.0/24@konstruktoid commented on GitHub (Jul 14, 2020):
Yes, and that's the point, if we don't get a valid address from the
wcommand, e.g. when installing locally, we'll allow the/24subnet so we can administer the machine afterwards of ssh.https://github.com/konstruktoid/hardening/blob/master/ubuntu.sh#L47-L51
@github-actions[bot] commented on GitHub (Sep 3, 2020):
This issue is stale because it has been open 30 days with no activity, without any activity this will be closed in 5 days.