Skip to content

Commit

Permalink
Simple DHCP relaying scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
ipspace committed Mar 6, 2023
1 parent e2fc922 commit 87127d0
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 1 deletion.
13 changes: 13 additions & 0 deletions DHCP/relay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DHCP relaying

This directory contains *netlab* topology file for a simple DHCP relaying scenario.

![DHCP relaying topology](dhcp-relay.png)

After starting the lab, the *user* device should get DHCP-assigned IP address on its lab-facing interface.

## Changing Device Types

This topology can be used with Cisco IOSv or Arista EOSv. To test it with other devices, add custom configuration template to `dhcp-relay` directory.

The easiest way to change the device types is to edit the topology file. You could also use the **netlab up** [CLI arguments](https://netsim-tools.readthedocs.io/en/latest/netlab/up.html#usage) -- to change the DHCP relay device type, use `-s nodes.relay.device=xxx` CLI argument.
5 changes: 5 additions & 0 deletions DHCP/relay/dhcp-client/ios.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% for intf in interfaces if intf.dhcp.client is defined and intf.dhcp.client %}
interface {{ intf.ifname }}
no ip address
ip address dhcp
{% endfor %}
Binary file added DHCP/relay/dhcp-relay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions DHCP/relay/dhcp-relay/eos.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% for intf in interfaces if intf.dhcp.server is defined %}
interface {{ intf.ifname }}
ip helper-address {{ hostvars[intf.dhcp.server].loopback.ipv4|ipaddr('address') }}
{% endfor %}
4 changes: 4 additions & 0 deletions DHCP/relay/dhcp-relay/ios.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% for intf in interfaces if intf.dhcp.server is defined %}
interface {{ intf.ifname }}
ip helper-address {{ hostvars[intf.dhcp.server].loopback.ipv4|ipaddr('address') }}
{% endfor %}
20 changes: 20 additions & 0 deletions DHCP/relay/dhcp-server.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
logging buffered
no service timestamp debug
!
do debug ip dhcp server packet
do debug ip dhcp server event
!
{% for h,v in hostvars.items() %}
{% for intf in v.interfaces if intf.dhcp.server is defined and intf.ipv4 is defined %}
ip dhcp excluded-address {{ intf.ipv4|ipaddr('address') }}
{% endfor %}
{% endfor %}
!
{% for h,v in hostvars.items() %}
{% for intf in v.interfaces if intf.dhcp.server is defined and intf.ipv4 is defined %}
!
ip dhcp pool p_{{ intf.ipv4|ipaddr('network') }}
network {{ intf.ipv4|ipaddr('network') }} {{ intf.ipv4|ipaddr('netmask') }}
default-router {{ intf.ipv4|ipaddr('address') }}
{% endfor %}
{% endfor %}
21 changes: 21 additions & 0 deletions DHCP/relay/graph.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
graph {
bgcolor="transparent"
node [shape=box, style="rounded,filled" fontname=Verdana]
edge [fontname=Verdana labelfontsize=10 labeldistance=1.5]
"srv" [
label=<srv [iosv]<br /><sub>10.0.0.1/32</sub>>
fillcolor="#ff9f01"
]
"relay" [
label=<relay [iosv]<br /><sub>10.0.0.2/32</sub>>
fillcolor="#ff9f01"
]
"user" [
label=<user [iosv]<br /><sub>10.0.0.3/32</sub>>
fillcolor="#ff9f01"
]
"relay" -- "srv" [ ]
"relay_2" [style=filled fillcolor="#d1bfab" fontsize=11 label="172.16.0.0/24"]
"user" -- "relay_2" [ ]
"relay" -- "relay_2" [ ]
}
37 changes: 37 additions & 0 deletions DHCP/relay/topology.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
message: |
This topology sets up a simple network using DHCP relay
functionality. It includes a DHCP server (running on Cisco
IOSv), DHCP client (also on Cisco IOSv) and an intermediate
node.
defaults.attributes:
link.dhcp:
client: bool
server: str

defaults.device: iosv

groups:
dhcp_server:
members: [ srv ]
module: [ ospf ]
config: [ dhcp-server ]
device: iosv
dhcp_client:
members: [ user ]
config: [ dhcp-client ]
device: iosv
switch:
members: [ relay ]
module: [ ospf ]
config: [ dhcp-relay ]

nodes: [ srv, relay, user ]

links:
- relay-srv
- user:
dhcp.client: True
relay:
dhcp.server: srv
type: lan
2 changes: 1 addition & 1 deletion tools
Submodule tools updated from 36c285 to f1f4f6

0 comments on commit 87127d0

Please sign in to comment.