SRX

last person joined: 3 days ago 

Ask questions and share experiences about the SRX Series, vSRX, and cSRX.
  • 1.  Copying and pasting almost 2000 lines

    Posted 02-23-2011 12:34

    Ok, I'm a little baffled here.  I am creating some prefix-lists to block users from China, Korea, etc to some of our games. However, the block list for Chinese subnets is like 1854 lines of CIDR subnets.  Trying to copy and paste this into my SRX via serial terminal or via ssh (from two different clients) fails every time.  I really don't want to have to individually copy and past almost 2000 commands one at a time.  Anyone have any ideas on work arounds for this?



  • 2.  RE: Copying and pasting almost 2000 lines

    Posted 02-23-2011 12:58

    You could format them into "set" commands and then scp the file to your SRX in the /tmp directory, for example, and then do a "load set /tmp/commands.txt"



  • 3.  RE: Copying and pasting almost 2000 lines

    Posted 02-23-2011 15:31

    This is really easy.

     

    What format is your 2000 line CIDR list?  Is it just a simple list delimited by a '\n'?  Is it a Junos config?  Is it Junos set commands?

     

    If it's a list of CIDRs delimited by '\n' then use this shell script on the route engine:

     

    admin@EX4500> start shell
    % sh
    $ while read cidr
    do
    echo "set policy-statement prefix-list test $cidr"
    done

     

     

    Now paste in the 2000 CIDRs and press CTRL-d after you pasted them in.  This script will output the Junos commands to build a large prefix-list.

     

    If your 2000 lines is actual Junos config, use the load command.

     

     

    {master:0}[edit]
    admin@EX4500# edit policy-options
    
    {master:0}[edit policy-options]
    admin@EX4500# load merge terminal relative
    [Type ^D at a new line to end input]

     

     

    If you have 2000 lines of actual Junos set commands, just simply paste them into the router while you're in config mode.

     

    The fastest method is to SCP the Junos code snippet into your home directory and just use the load command with the file option.

     

     

    admin@EX4500> configure
    Entering configuration mode
    The configuration has been changed but not committed
    
    {master:0}[edit]
    admin@EX4500# edit policy-options
    
    {master:0}[edit policy-options]
    admin@EX4500# load merge relative ?
    Possible completions:
      <filename>           Filename (URL, local, remote, or floppy)
      terminal             Use login terminal
    {master:0}[edit policy-options]
    admin@EX4500# load merge relative

     

     



  • 4.  RE: Copying and pasting almost 2000 lines

    Posted 03-24-2011 13:46

    Doug's answer is terrific, but I expect your problem is a little different.  I suspect you problem is more "terminal related".  You can paste faster than the box can take it and you are overunning the buffer.

     

    Assuming you have your long list of "set addres..." or whatever commands, try this.

     

    load set terminal

     

    Then past in your 2000 lines of set commands and enter a ctrl-D.



  • 5.  RE: Copying and pasting almost 2000 lines

    Posted 03-24-2011 14:46

    My favourite procedure ...

     

    1) show "whatever" | display set | save "my-favourite-name"

    2) scp from srx ...

    3) my favourite text editor (i.e. kate), find and replace ...

    4) scp into srx ...

    5) load override "my-favourite-name"