Junos
Reply
Contributor
sirius
Posts: 11
Registered: ‎09-29-2008
0

quick way to script?

Hi Guys,

Some help appreciated here, this is beginning to drive me nuts and I can see myself making mistakes.

 

I am setting up VLAN's and adding the ports (one by one, as I don't see a quick way) to the VLAN's.

 

I currently use the following procedure:

 

command>:

 root@# edit interfaces ge-0/0/12 unit 0 family ethernet-switching  [enter]

 

gives me this result:

 

[edit interfaces ge-0/0/12 unit 0 family ethernet-switching]
root@#


OK, so now I am in edit mode and want to add the interface to the VLAN so I give the following command:

 

set port-mode access vlan members blah

 

then I'm back to the prompt: 

 

[edit interfaces ge-0/0/12 unit 0 family ethernet-switching]
root@#


Now... if I want to also add ge-0/0/13, 14, 15, 16, 17, ...etc to VLAN members "blah" I go through the whole process again changing the values.

 

Is there some shortcut that I am missing? I've been through the "cookbook" and don't see anything to suggest what I need, I just want to add several ports to one VLAN with one command and not have to do it individually.

 

Please help! Thanks a lot,

 

Sirius.

Lifes too short
Super Contributor
AntonD
Posts: 111
Registered: ‎11-07-2007
0

Re: quick way to script?

If each interface configuration is identical an easier way might be to do the copy the interface configuration.

 

 

[edit interfaces] adelport@junction# copy ge-0/0/12 to ge-0/0/13

 

 This is still not a range command but is slightly shorter than you had.

 

Another option would be to create a text file and than past the configuration that you want into the router. For example.

 

 

[edit]
adelport@junction# load set terminal
[Type ^D at a new line to end input]
set interfaces ge-0/0/12 unit 0 family ethernet-switching port-mode access vlan members blah
set interfaces ge-0/0/13 unit 0 family ethernet-switching port-mode access vlan members blah
set interfaces ge-0/0/14 unit 0 family ethernet-switching port-mode access vlan members blah
set interfaces ge-0/0/15 unit 0 family ethernet-switching port-mode access vlan members blah
load complete

[edit]
adelport@junction#

 

 

 

 

Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.