Junos Automation (Scripting)
Reply
Visitor
asalaverria@gmail.com
Posts: 3
Registered: ‎10-18-2010
0

Create Static NAT OP Script

Hello,

 

I am trying to write an op script to create a static nat rule, but I am having syntax problems.  This is my script:

 

version 1.0;

ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

import "../import/junos.xsl";

match / {
<op-script-results> {
var $configuration = {
<configuration> {
<security> {
<nat> {
<static> {
<rule-set> {
<name> "web-server1";
<from> {
<zone> "untrust";
<rule> {
<name> "web-server1";
<match> {
<destination-address> "99.99.99.99/32";
}
<then> {
<static-nat> {
<prefix> {
<name> "192.168.1.1/32";
}
}
}
}
}
}
}
}
}
}
}



var $connection = jcs:open();
var $results := { call jcs:load-configuration($connection, $configuration); }
copy-of $results;
expr jcs:close($connection);
}
}

 

I keep getting this syntax error:

 

<xnm:error xmlns="http://xml.juniper.net/xnm/1.1/xnm">
<token xmlns="">rule</token>
<message xmlns="">syntax error</message>
</xnm:error>
<load-error-count>2</load-error-count>

 

What am I doing wrong?

I tried everything, please help.

 

Thanks,

 

Andres

Recognized Expert
ccall
Posts: 230
Registered: ‎06-18-2008
0

Re: Create Static NAT OP Script

Could you configure this manually and then  provide the config snippet output in XML? ( show | display xml). I'm not familiar with that stanza so I can't point out where your hierarchy is wrong.

Visitor
asalaverria@gmail.com
Posts: 3
Registered: ‎10-18-2010
0

Re: Create Static NAT OP Script

Ccall,

 

I forgot about display xml.  I was able to get this configured and working correctly.

I was missing <static-nat-rule-match> after the rule name.

 

Thank you very much for your help!

Andres

 

 

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