Skip to content

Commit

Permalink
DHCP relaying from an EVPN VRF
Browse files Browse the repository at this point in the history
  • Loading branch information
ipspace committed Mar 11, 2023
1 parent d1a62a7 commit 2048f12
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 27 deletions.
7 changes: 7 additions & 0 deletions DHCP/evpn-relay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DHCP relaying from an EVPN VRF

This directory contains *netlab* topology file used to test DHCP relaying from an EVPN VRF toward a DHCP server in the network core.

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

After starting the lab, the clients (*cl_a* and *cl_b*) should get DHCP-assigned IP address on their lab-facing interfaces.
5 changes: 5 additions & 0 deletions DHCP/evpn-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 %}
11 changes: 11 additions & 0 deletions DHCP/evpn-relay/dhcp-relay/eos.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% for intf in interfaces if intf.dhcp.server is defined and intf.vrf is defined %}
{% if loop.first %}
ip dhcp relay information option
{% endif %}
{% endfor %}
!
{% for intf in interfaces if intf.dhcp.server is defined %}
{% set helper = hostvars[intf.dhcp.server].loopback.ipv4|ipaddr('address') %}
interface {{ intf.ifname }}
ip helper-address {{ helper }}{% if intf.vrf is defined %} vrf default{% endif %}
{% endfor %}
27 changes: 27 additions & 0 deletions DHCP/evpn-relay/dhcp-server.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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') }}
{% if intf.gateway.ipv4 is defined %}
ip dhcp excluded-address {{ intf.gateway.ipv4|ipaddr('address') }}
{% endif %}
{% 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') }}
{% if intf.gateway.ipv4 is defined %}
default-router {{ intf.gateway.ipv4|ipaddr('address') }}
{% else %}
default-router {{ intf.ipv4|ipaddr('address') }}
{% endif %}
{% endfor %}
{% endfor %}
Binary file added DHCP/evpn-relay/evpn-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.
14 changes: 14 additions & 0 deletions DHCP/evpn-relay/outputs/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
addr: |
{{ " {0:20} {1:>18} {2}".format("Interface","IPv4 address","Description") }}
{{ "=" * 80 }}
{% for n,d in nodes.items() %}
{% if not loop.first %}
{% endif %}
{{ n }} ({{ d.loopback.ipv4 }})
{% for intf in d.interfaces if 'ipv4' in intf %}
{{ "{0:20} {1:>18} {2}".format(intf.ifname,intf.ipv4,intf.name) }}{% if 'vrf' in intf
%} (VRF: {{ intf.vrf }}){% endif +%}
{% endfor %}
{% endfor %}
58 changes: 58 additions & 0 deletions DHCP/evpn-relay/topology.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
message: |
This topology sets up a simple VXLAN network using DHCP relay
functionality. It includes a DHCP server (running on Cisco
IOSv), DHCP client (also on Cisco IOSv) and two intermediate
VXLAN-enabled switches.
defaults.attributes:
link.dhcp:
client: bool
server: str

groups:
dhcp_server:
members: [ srv ]
module: [ ospf ]
config: [ dhcp-server ]
device: csr
dhcp_client:
members: [ cl_a, cl_b ]
config: [ dhcp-client ]
device: iosv
switch:
members: [ sw1, sw2 ]
module: [ ospf,bgp,vrf,vlan,vxlan,gateway,evpn ]
config: [ dhcp-relay ]
device: eos

vrfs:
client:

vlans:
cv1:
gateway: True
ospf.passive: True
vrf: client

bgp.as: 65000
gateway.id: 1

nodes: [ srv, sw1, sw2, cl_a, cl_b ]

links:
- srv-sw1
- srv-sw2
- sw1-sw2
- cl_a:
dhcp.client: True
sw1:
dhcp.server: srv
vlan.access: cv1
- cl_b:
dhcp.client: True
sw2:
dhcp.server: srv
vlan.access: cv1

defaults.outputs:
_include: [ outputs/format.yml ]
2 changes: 1 addition & 1 deletion DHCP/vxlan-relay/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DHCP relaying
# DHCP relaying from a VXLAN segment

This directory contains *netlab* topology file used to test DHCP relaying in a VXLAN environment with redundant access switches using an anycast gateway.

Expand Down
4 changes: 0 additions & 4 deletions DHCP/vxlan-relay/dhcp-relay/ios.j2

This file was deleted.

21 changes: 0 additions & 21 deletions DHCP/vxlan-relay/graph.dot

This file was deleted.

2 changes: 1 addition & 1 deletion tools
Submodule tools updated from 4af21a to 6c7ceb

0 comments on commit 2048f12

Please sign in to comment.