Skip to content

Instantly share code, notes, and snippets.

@gnif
Created August 13, 2020 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnif/99dc041e50b612e72dae8f4061cccd97 to your computer and use it in GitHub Desktop.
Save gnif/99dc041e50b612e72dae8f4061cccd97 to your computer and use it in GitHub Desktop.
Generate the hex route rule for DHCP (pfSense)

Usage is simple:

./gen.sh 192.168.10.0/24 192.168.10.1

Results:

192.168.10.0/24 via 192.168.10.1 = 18:c0:a8:0a:00:c0:a8:0a:01
#!/bin/bash
DST=$(echo "$1" | cut -d'/' -f1)
MASK=$(echo "$1" | cut -d'/' -f2)
VIA="$2"
printf "$DST/$MASK via $VIA = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n" $MASK ${DST//./ } ${VIA//./ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment