Often we need to read from, or write to, files in directories that are local to our script. For instance, we could use the below code to save to file all possible values that can be stored in one byte: my_bytes = bytearray(list(range(0,256))) with open("output/local.bin", 'wb') as f: f.write(my_bytes) Our script, local_file.py, is located in the following directory: /home/python [wintermute@hive python]$ cd /home/python [wintermute@hive python]$ ls local_file.py output Now, let's say we launch this script from within its location: [wintermute@hive python]...
In the previous post I showed how bgp table-map can be used for the selective route download. Here we will take a look at another use of this command, that is, associating IP Precedence values with selected BGP prefixes. By applying QoS policy to inbound prefixes we can easily mark traffic coming from a given AS, or going to a particular client. We can set IP Precedence value using route-map, and prefix list, ACLs, or communities to classify match prefixes of interest. Topology for the examples to follow is shown below. We have an ISP router in the middle and...
BGP table-map is a feature that allows us to filter, or set properties of, the BGP routes marked for installation into the RIB. One scenario where we could use table-map is a dedicated IPv4 RR that doesn't need to have all of the routes it receives in the RIB, but it still needs to propagate them to its clients. We will test BGP Selective route download using the below simple topology. RRC1 advertises 4 prefixes to RR. These prefixes are 110.0.[0-3].0/24 . RRC2 also advertises 4 prefixes to RR. These prefixes are 120.0.[0-3].0/24...
Have you ever had a need to iterate over two lists at the same time? I did recently and it turns out that Python has a built-in function called zip() that can be used for this. This function takes iterables as arguments, such as lists or strings, and returns a list of tuples containing elements from each of the arguments. When using it in our code we can mix types of arguments, they don't have to be the same. In the examples below we will use lists of characters, digits, and tuples. For good measure, we will throw in a...
Role based access control for CLI allows us to set up a very granular permissions for user accounts. We can have a role called NOC that will have right to use only selected show commands. Or we could have a role for Junior Engineers that will allow them to configure only certain aspects of the device like interface descriptions. Before we can configure specific views, we need to enable aaa and configure enable password: aaa-new model enable secret cisco After that we can enter the root view to confirm parser views are enabled: R1#enable view Password: R1#sh parser...