Wednesday, March 6, 2019

Determine IP address from MAC address, in Linux

Found a switch in a closet.. not documented and I'm too lazy to haul a laptop over and try to hit the console so I took a picture of the MAC label and stumbled across this literal GEM of a one-liner:

nmap -sP <subnet>/24 >/dev/null && arp -an | grep xx:xx:xx:xx:xx:xx | awk '{print $2}' | sed 's/[()]//g'

 It literally just works.

Monday, March 4, 2019

Powershell: Scripting, copying one users group membership to another

At $work I've been working on a new On-Boarding script, and to make things easy part of this script prompts to enter an existing users SamAccountName to copy the memberof to the new user.

It took me an hour or more of solid Google-Fu but here's the result and it works perfectly:

Get-auser -identity $copyuser -properties memberof | select-object memberof -ExpandProperty memberof | add-adgroupmember -members $newuser

Cheers.

Wednesday, February 27, 2019

OPNsense and PIA (Private Internet Access)

So.. I'm finally getting around to setting up my homelab, it helps to be buying a house, lol.

Ok so onward, a very good buddy of mine allows me to share his PIA account, and since I recently rolled from pfSense to OPNsense I decided to night to set it up.  To help create this I logged into the PIA account and generated an OpenVPN .ovpn config file, everything you need is within..



First things first, you need to create a new Certificate Authority via System -> Trusts -> Authority.  Copy and paste the
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
parts into the Certificate data field.. make sure to name is something descriptive.

Then goto System -> Firmware -> plugins and install the OpenVPN client.

Once complete, we will configure it..  VPN -> OpenVPN -> Clients and Add a new one.

Now here I  and used what was in it.. so





 Once complete I checked teh status at VPN -> OpenVPN -> Connection Status and saw it was connected.  Now you will want to create a new Interface; Interfaces -> Assignments -> New then pick the latest addition.. in my case it was "ovpnc1".

Then head over to Firewall -> Rules -> LAN and create a new rule:



And set the gateway tot eh new interface you created.. (obviously edit the Source ip to whatever IP your machine is using that you want the traffic to traverse this new VPN connection).

And there you go.. all done.

Thursday, February 14, 2019

Linux/Windows Dual Boot, "The disk contains an unclean file system"

I'm not running a dual-boot system between KDE Neon (My current favorite Linux distro) and Windows 8.1 (Because I think 10 sucks ass),  Why Windows you say? Because no ones ported Far Cry 5 over yet ;)

Anyway I have a shared 'storage' drive between the two.. it's formatted as NTFS and just holds some backup stuff and I use it as a go between. Last night I'm pretty sure I told Windows to shut down. Turns out it left this disk in an unclean state. SHAME......SHAME.......SHAME lol.

The resolution is *ntfsfix*, installed by default on Ubuntu since like.. hell IDK like a number of major versions back.  Any how this is your savior.

 skeer@spektr  /media/skeer sudo ntfsfix /dev/sda1
Mounting volume... The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
FAILED
Attempting to correct errors...
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
Checking the alternate boot sector... OK
NTFS volume version is 3.1.
NTFS partition /dev/sda1 was processed successfully.

 skeer@spektr  /media/skeer sudo mount -a          
skeer@spektr  /media/skeer


BOOM, Done. 

I can now write to the disk from Neon.

Peace Out.

Wednesday, January 23, 2019

Netplan error: Unknown key version

If you get the error: Unknow key version when trying to 'try' or 'apply' a netplan config file re-check your indentations.  They are off.. that's what causes this error.

Enjoy


p.s. yaml is 4 spaces for each indent.