11-08-2023 05:35 AM
hello,
we are using cisco dna to provision our branch switches without human touch. Switches succesfully obtain their IP addresses from DHCP server and appear on Cisco DNA and receive their configurations. For some security reasons we have to change int vlan 1 address from dhcp to static and for now we do it manually by configuring same ip address and gateway received from dhcp. I tried to automate this as well with using jinja template as below, but it did not help. Template system variables says __interface.ipv4Address exists but while doing configuration it fails. Jinja loop and condition works well as description is configured after onboarding.
11-08-2023 08:17 AM
Could you post your jinja template? Do you wish to use the DHCP assigned address, or do you want to use another address in the end?
11-08-2023 08:18 AM
11-10-2023 02:49 AM
To just fix the address you could take something like this:
{% for interface in __interface %}
{% if '161' in interface.ipv4Address %}
{% set mgmt_vlan = interface.vlanId %}
vlan {{ mgmt_vlan }}
name Mgmt
!
ip route 0.0.0.0 0.0.0.0 {{ gateway }}
!
int vlan {{ mgmt_vlan }}
description Mgmt
ip address {{ interface.ipv4Address }} {{ interface.ipv4Mask }}
no ip dhcp client client-id
This works for me. Unfortunately, I can't find out how to read the default gateway obtained by DHCP with system variables and configure a default route from it
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide