10-17-2011 07:38 PM
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
10-18-2011 03:48 PM
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.
10-18-2011 08:47 PM
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