Skip to content

Commit

Permalink
New posts and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwiko committed May 17, 2024
1 parent b044e30 commit 78892ca
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_posts/*.md
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ version: v1.2.0
kramdown:
# Use GitHub flavored markdown, including triple backtick fenced code blocks
input: GFM

# Jekyll 3 and GitHub Pages now only support rouge for syntax highlighting
syntax_highlighter: rouge
syntax_highlighter_opts:
Expand Down
48 changes: 48 additions & 0 deletions _posts/2024-5-11-testing-dhcp-with-bats-and-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
layout: post
title: Testing DHCP with Bats and Docker!
---

[Official KEA Docker](https://gitlab.isc.org/isc-projects/kea-docker)

[Git Repo](https://github.com/Qwiko/dhcp-bats-docker)

bats test-file dhcp-docker-tests.bats
{% highlight json %}
function docker_udhcpc() {
docker compose -f test/test-docker-compose.yaml exec -it busybox udhcpc -q -B -v -O bootfile -n -q -V $1
}

@test "test vendor: unknown" {
run docker_udhcpc unknown_vendor
[ "$status" -eq 1 ]
}

@test "test vendor: ciscopnp" {
run docker_udhcpc ciscopnp
[ "$status" -eq 0 ]
[ "${lines[-1]}" = "http://10.10.10.10/ios/ztp.py" ]
}

@test "test vendor: Arista" {
run docker_udhcpc Arista
[ "$status" -eq 0 ]
[ "${lines[-1]}" = "http://10.10.10.10/eos/ztp.j2" ]
}

@test "test vendor: arista" {
run docker_udhcpc arista
[ "$status" -eq 0 ]
[ "${lines[-1]}" = "http://10.10.10.10/eos/ztp.j2" ]
}
{% endhighlight %}

Running the tests
{% highlight bash %}
$ bats test
dhcp-docker-tests.bats
✓ test vendor: unknown
✓ test vendor: ciscopnp
✓ test vendor: Arista
✓ test vendor: arista
{% endhighlight %}
106 changes: 106 additions & 0 deletions _posts/2024-5-7-kea-dhcp-client-classification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
layout: post
title: ISC DHCP and Kea DHCP Client classification!
---

Since ISC DHCP have been discontinued since [2022](https://www.isc.org/blogs/isc-dhcp-eol/){:target="\_blank"} I was tinkering with a way to recreate common operations with client classifications used in networking.

Simple example dhcpd.conf

{% highlight conf %}
class "CISCO" {
match if (substring(option vendor-class-identifier, 0, 5) = "cisco");
option bootfile-name "http://10.10.10.10/ios/ztp.py";
}

class "ARISTA" {
match if (substring(option vendor-class-identifier, 0, 6) = "Arista");
option bootfile-name "http://10.10.10.10/eos/ztp.j2";
}

subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.1;
pool {
range 10.0.0.20 10.0.0.200;
allow members of "CISCO";
allow members of "ARISTA";
}
}
{% endhighlight %}

Simple example of the same functionality in kea dhcp.
{% highlight json %}
{
"Dhcp4": {
"interfaces-config": {
"interfaces": [
"eth0"
],
},
"client-classes": [
{
"name": "CISCO",
"test": "substring(option[60].hex,0,5) == 'cisco'",
"option-data": [
{
"name": "boot-file-name",
"code": 67,
"space": "dhcp4",
"data": "http://10.10.10.10/ios/ztp.py"
}
]
},
{
"name": "ARISTA",
"test": "substring(option[60].hex,0,6) == 'Arista' or substring(option[60].hex,0,6) == 'arista'",
"option-data": [
{
"name": "boot-file-name",
"code": 67,
"space": "dhcp4",
"data": "http://10.10.10.10/eos/ztp.j2"
}
]
},
{
"name": "AllGroups",
"test": "member('CISCO') or member('ARISTA')"
}
],
"loggers": [
{
"name": "kea-dhcp4",
"output_options": [
{
"output": "stdout"
}
],
"severity": "INFO",
},
],
"subnet4": [
{
"subnet": "10.0.0.0/24",
"option-data": [
{
"name": "routers",
"code": 3,
"space": "dhcp4",
"data": "10.0.0.1"
}
],
"pools": [
{
"pool": "10.0.0.10 - 10.0.0.20",
"client-class": "AllGroups"
}
]
}
]
}
}
{% endhighlight %}

Check out my other post about: [Testing DHCP with Bats and Docker]({% link _posts/2024-5-11-testing-dhcp-with-bats-and-docker.md %}).

In a future post I will look into on commit script hooks with Kea DHCP.

0 comments on commit 78892ca

Please sign in to comment.