Blog Viewer

How-To: Add a large list of IP addresses to a prefix-list using CLI

By Erdem posted 06-10-2016 08:58

  

Overview

There are times when you need to add a large list of IP addresses to a prefix-list. You can use the CLI to add these IP addresses.

Solution

Use the load merge CLI command to load the edited prefix list to the Junos OS device. You should first edit the prefix list with a script or editor to append ';' to the end of each IP address. 

Example

Use sed on a Linux platform to append ';' to the end of each IP address in the prefix.txt file.

> sed -e 's/$/;/' prefix.txt

On the Junos OS device, use the edit policy prefix-list <name> command and then load merge relative terminal command to add the list of IP addresses.

 

[edit policy-options prefix-list TEST]
root@PE2# load merge relative terminal
[Type ^D at a new line to end input]
10.38.108.24;
10.54.42.82;
10.61.171.253;
10.62.98.162;
10.128.34.171;
10.139.161.113;
10.141.27.91;
10.141.31.16;
10.141.31.19;
load complete

[edit policy-options prefix-list TEST]
root@PE2# show
10.38.108.24/32;
10.54.42.82/32;
10.61.171.253/32;
10.62.98.162/32;
10.128.34.171/32;
10.139.161.113/32;
10.141.27.91/32;
10.141.31.16/32;
10.141.31.19/32;

 

Note: for large lists (over 200 IP addresses), load the IP addresses from the local  prefix2.txt file. Then use the load merge <file-path> relative command to bring those IP addresses into the prefix-list.

 

From File:

 

root@JUNOS# edit policy-options prefix-list TEST

[edit policy-options prefix-list TEST]
root@JUNOS# load merge /var/tmp/prefix2.txt relative
load complete

[edit policy-options prefix-list TEST]
root@JUNOS# show | count
Count: 346 lines  

 


#How-To
#IPAddresses
#JunosOS

Permalink