Create a message entry in the log…
EXOS-VM.20 # create log message “Today is Saturday!”
EXOS-VM.21 # show log
12/19/2020 11:32:19.62 Today is Saturday!
Create a message entry in the log…
EXOS-VM.20 # create log message “Today is Saturday!”
EXOS-VM.21 # show log
12/19/2020 11:32:19.62 Today is Saturday!
Sometimes it is required to test traffic through an alternative path before committing to it and allows for testing and monitoring of a specific application. So, in VOSS it is possible to create an ACL which can redirect source and destination traffic to a next-hop which overrides the routes in the GRT.
Below is an example filter which I tested using a VSP VM in GNS3 that redirects traffic with a source IP 10.10.10.10 towards a destination IP 30.30.30.30 with a next-hop of 20.20.20.20. Verified it works by using the statistics on the ACL and Wireshark on the outbound link in the topology.
filter acl 1 type inVlan
filter acl vlan 1 10
filter acl ace 1 100
filter acl ace action 1 100 permit redirect-next-hop 20.20.20.20
filter acl ace action 1 100 permit count
filter acl ace ethernet 1 100 ether-type eq ip
filter acl ace ip 1 100 src-ip eq 10.10.10.10
filter acl ace ip 1 100 dst-ip eq 30.30.30.30
filter acl ace 1 100 enable
VSP:1>enable
VSP:1#config t
Enter configuration commands, one per line. End with CNTL/Z.
VSP:1(config)#no snmp-server community public
VSP:1(config)#no snmp-server community private
VSP:1(config)#snmp-server community ExtremeRead group readgrp index first secname readview
VSP:1(config)#snmp-server community ExtremeWrite group v1v2grp index second secname initialview
It is useful to know when a task has made a change and it should be possible to re-run the same task again and no changes are made. Some commands sent to the switch may return a changed state even though the configuration has changed before. This can be the case when using abbreviated commands. There are also different ways to apply the same configuration and it is worth inspecting the running configuration to see the syntax of the command in there which might be different to what was sent.
For example, you can create a new VLAN with one line and then give the VLAN a name with another. If you do this the playbook will always come back as changed=1 even though it made no changes on subsequent plays. By checking the running config you can see that the two command lines are converted to a single line and also includes quotes around the VLAN name.
Altering the Jinga2 source file used as a template to match the expected result in the running config will change the behaviour. Running the playbook for the first time will change the config and state will be changed=1. Subsequent runs of the playbook will not change anything as the configuration is found in the running config with the exact same string and syntax. The state will be changed=0.
$ ansible-playbook voss_config_vlan.yml
PLAY [PLAY 1: Manage VLANs with voss_config and jinja2] ********************************************
TASK [TASK 1: Apply config via SSH] ****************************************************************
changed: [r1]
RUNNING HANDLER [HANDLER 1: Display changes] *******************************************************
ok: [r1] => {
“msg”: [
“vlan create 300 name \”Sales\” type port-mstprstp 0″,
“vlan create 400 name \”IT\” type port-mstprstp 0″
]
}
PLAY RECAP *****************************************************************************************
r1 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
$ ansible-playbook voss_config_vlan.yml
PLAY [PLAY 1: Manage VLANs with voss_config and jinja2] ********************************************
TASK [TASK 1: Apply config via SSH] ****************************************************************
ok: [r1]
PLAY RECAP *****************************************************************************************
r1 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
###
VLAN extract from running config:
vlan create 300 name “Sales” type port-mstprstp 0
vlan create 400 name “IT” type port-mstprstp 0
Jinga2 template:
$ cat templates/vlans.j2
{% for vlan in vlans %}
vlan create {{ vlan.vid }} name “{{ vlan.description }}” type port-mstprstp 0
{% endfor %}
Add site-package yamllint to inspect YAML/YML files for errors.
pip install –user yamllint
Yamllint has two default configuration files: default.yaml and relaxed.yaml with pre-set rules. Can extend a configuration file and alter one of the rules.
Mylint.yaml:
# Mylint.yaml is my own configuration file for yamllint
# It extends the default.yaml by adjusting some options.
extends: default
rules:
new-lines: disable
###
Did this to avoid the error about the EOL character on the first line (—).
1:4 error wrong new line character: expected \n (new-lines)
from netmiko import ConnectHandler
voss1 = {‘device_type’: ‘extreme_vsp’, ‘host’: ‘192.168.1.11’, ‘username’: ‘rwa’, ‘password’: ‘rwa’}
net_connect = ConnectHandler(**voss1)
net_connect.find_prompt()
net_connect.enable()
net_connect.send_command(‘terminal more disable’)
output = net_connect.send_command(‘show run’)
print(output)
net_connect.send_command(‘terminal more enable’)
savedoutput = open(“switch” + voss1[‘host’], “w”)
savedoutput.write(output)
savedoutput.close
Start DOS prompt as Administrator.
for /l %i in (1,1,254) do ping -n 1 10.10.10.%i >> sweep.txt
https://pypi.org/project/ciscoconfparse/
Building configuration files from a template…
VOSS.J2