DHCP debugging with tcpdump


tcpdump filter to match DHCP packets including a specific Client MAC Address:

tcpdump -i br0 -vvv -s 1500 '((port 67 or port 68) and (udp[38:4] = 0x3e0ccf08))'

tcpdump filter to capture packets sent by the client (DISCOVER, REQUEST, INFORM):

tcpdump -i br0 -vvv -s 1500 '((port 67 or port 68) and (udp[8:1] = 0x1))'

Sample output :


 21:38:05.644153 IP (tos 0x0, ttl 64, id 32104, offset 0, flags [none], proto UDP (17), length 374)
     0.0.0.0.bootpc > 255.255.255.255.bootps: [udp sum ok] BOOTP/DHCP, Request from 12:42:82:cb:7a:7e (oui Unknown), length 346, xid 0xd01f0ad4, secs 18694, Flags [none] (0x0000)
   Client-Ethernet-Address 12:42:82:cb:7a:7e (oui Unknown)
   Vendor-rfc1048 Extensions
     Magic Cookie 0x63825363
     DHCP-Message Option 53, length 1: Discover
     Client-ID Option 61, length 7: ether 12:42:82:cb:7a:7e
     SLP-NA Option 80, length 0""
     NOAUTO Option 116, length 1: Y
     MSZ Option 57, length 2: 1472
     Vendor-Class Option 60, length 49: "dhcpcd-7.1.0:Linux-4.19.59-sunxi:armv7l:Allwinner"
     Hostname Option 12, length 11: "whiteorange"
     T145 Option 145, length 1: 1
     Parameter-Request Option 55, length 15: 
       Subnet-Mask, Classless-Static-Route, Static-Route, Default-Gateway
       Domain-Name-Server, Hostname, Domain-Name, MTU
       BR, NTP, Lease-Time, Server-ID
       RN, RB, Option 119
     END Option 255, length 0 

…And yes it is an orangepi zero for those playing at home..

nJoy 😉

Convert Large numbers to binary in Excel

=DEC2BIN(MOD(QUOTIENT($A$1,16^7),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^6),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^5),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^4),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^3),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^2),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^1),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^0),16),4)

The above code will convert large numbers up to 32 bit.

nJoy 😉

Get ssh key fingerprint for comparing safely

SSh keys can be long and unwieldy to compare. Many platforms digest them to md5 formats for non disclosure such as github.

This command will give you the digested fingerprint of an ssh key in linux / Mac.

ssh-keygen -lf .ssh/id_rsa.pub -E md5

nJoy 😉

Get Days in a month from a bash script

Useful listing of days in a month to populate directories or run scripts for backing up getting the correct dates of days in a month and year.

 

 


YEAR=2020
MONTH=2

for DAY in $(DAYS=`cal $MONTH $YEAR | awk 'NF {DAYS = $NF}; END {print DAYS}'` && seq -f '%02G' $DAYS) ;do
DATE="$YEAR-$MONTH-$DAY"
echo $DATE
done

nJoy 😉

SYSTEMD – controls

Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd. With Systemd to manage the services we can do the following:

systemctl start SERVICE – Use it to start a service. Does not persist after reboot

systemctl stop SERVICE – Use it to stop a service. Does not persist after reboot

systemctl restart SERVICE – Use it to restart a service

systemctl reload SERVICE – If the service supports it, it will reload the config files related to it without interrupting any process that is using the service.

systemctl status SERVICE – Shows the status of a service. Tells whether a service is currently running.

systemctl enable SERVICE – Turns the service on, on the next reboot or on the next start event. It persists after reboot.

systemctl disable SERVICE – Turns the service off on the next reboot or on the next stop event. It persists after reboot.

systemctl is-enabled SERVICE – Check if a service is currently configured to start or not on the next reboot.

systemctl is-active SERVICE – Check if a service is currently active.

systemctl show SERVICE – Show all the information about the service.

sudo systemctl mask SERVICE – Completely disable a service by linking it to /dev/null; you cannot start the service manually or enable the service.

sudo systemctl unmask SERVICE – Removes the link to /dev/null and restores the ability to enable and or manually start the service.

Just copied notes. 😉 nJoy

Automatically passing ssh password in scripts especially to ESX where passwordless ssh is hard

First you need to install sshpass.

  • Ubuntu/Debian: apt-get install sshpass
  • Fedora/CentOS: yum install sshpass
  • Arch: pacman -S sshpass

Example:

sshpass -p "YOUR_PASSWORD" ssh -o StrictHostKeyChecking=no YOUR_USERNAME@SOME_SITE.COM

Custom port example:

sshpass -p "YOUR_PASSWORD" ssh -o StrictHostKeyChecking=no YOUR_USERNAME@SOME_SITE.COM:2400

from : https://stackoverflow.com/questions/12202587/automatically-enter-ssh-password-with-script

 

This works better for me though for sshfs:

echo $mypassword | sshfs -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@host mountpoint -o workaround=rename -o password_stdin 

 

 

nJoy 😉

 

fail to mount ntfs in BSD

[root@ftp /mnt/test]# ntfs-3g /dev/da10s1 /mnt/test                                                                                 
fuse: failed to open fuse device: No such file or directory 

kldload fuse  

That’s a missing module needs loading.
nJoy 😉