forked from barryclark/jekyll-now
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_posts/*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |