VyOS show dhcp server static reservations?

Hi All,

Does VyOS have a way to check allocated reservations without going through the show configuration commands ?

Something like

# run show dhcp server reservations

IP Address        MAC address        State        Pool    Hostname    Origin
----------------  -----------------  -------  ----------  ----------  --------
192.168.100.192   6e:c8:dc:43:91:e2  active   LAN_POOL    host1       local
192.168.100.194   52:33:00:55:f3:68  active   LAN_POOL    host2       local
192.168.100.190   74:45:be:95:82:26  active   LAN_POOL    host3       local

Kind Regards

As someone who uses the DHCP Server a fair bit, and static leases, I’m 99.9% sure the answer is “No”, at least in v1.3 with the old ISC DHCP server. Unsure in the newer builds with Kea.

That question did come up for me a few days back when I started with VyOS and I came across “show dhcp server leases state all” does not report static-map leases in this forum.

tl;dr: VyOS before 1.5 use ISC DHCPD and it doesn’t have a way to know the in-use static mappings. It will work in 1.5 since the new DHCP server (KEA DHCP) handles is differently.

What I would have found helpful would be a way to see all the static mappings, no matter if in use or not. Something like show dhcp server leases state static. That seems to be possible and not too hard to implement.

Feel free to create a PR

Sure, let me get coffee first :wink: … but joking aside yes, I’ll consider it if time permits. But then I have no idea if it is of interested to anyone but me.

Hi,

So far I can somewhat get what I need from running this convoluted command: Although it would be nice to have a CLI way.

Where pool name is LAN_POOL and it’s looking at all the static mappings. (note will give weird output if using additional options)

run show conf commands | grep -E 'LAN_POOL.*static-mapping' | awk {'print $9" "$11'} | sed 'N;s/\n/ /' | awk '{print $1,$4,$2;}' | column -t | awk '{print $NF,$0}' | sort -t . -n -k 4,4 | cut -f2- -d' '

Output is as follows

host1	02:33:23:43:24:55  192.168.200.11
host2   02:ee:23:43:24:35  192.168.200.12
host3   02:3a:23:4e:24:4d  192.168.200.13
host4   02:33:2b:4c:24:77  192.168.200.14

Regards

3 Likes

This chokes a little on the couple of devices I have with an option set on them, but otherwise it’s perfect. Thank you so much!!

EDIT: I just checked a | grep -v “option” in after the grep -E for static mapping and that fixes it so it’s perfect. Thanks again!

If you are interested I created a script to allow pool selection. Probably needs some checking.

create file under /config/scripts/
Call it say: get_reservation.sh

/config/scripts/get_reservation.sh LAN_POOL
/config/scripts/get_reservation.sh IoT_POOL
#!/bin/vbash

POOL=$1
source /opt/vyatta/etc/functions/script-template

run show conf commands | grep -E "${POOL}.*static-mapping" | awk {'print $9" "$11'} | sed 'N;s/\n/ /' | awk '{print $1,$4,$2;}' | column -t | awk '{print $NF,$0}' | sort -t . -n -k 4,4 | cut -f2- -d' '

exit

Note: Variable needs to be passed before the source otherwise it won’t work. Also didn’t add the ignore options in above command :slight_smile:

1 Like

Hi @Viacheslav,

I had a look at the code, the build and (part) of the documentation. If I understand correctly VyOS < 1.5 uses python-isc-dhcp-leases to get the leases and it’s state. To get the list of static leases one would either have to exend this python module or write your own code for static leases.

And am I right that the vyos-1x (source) package is pulled in by vyos-build together with all the other packages on your mirror?
If yes, how would I start if I wanted to modify the vyos-1x package and use that modified version for my compilation. I failed to find a how-to for that and therefore would be happy if I could get an pointer how to start.

@patient0 You can make changes in vyos-1x, build .deb package, send to the VyOS instance, and install it to the system.

debuild -us -uc -b

Send deb to the VyOS (for example via “scp”) and install

sudo dpkg -i *.deb

It is the easiest way to check and develop.

1 Like