Community discussions

MikroTik App
 
gregdhayes
newbie
Topic Author
Posts: 47
Joined: Wed Oct 04, 2006 5:35 am
Location: Osgood, IN
Contact:

Why Doesn't This Work

Sun Feb 25, 2007 5:26 am

I've been playing with scripting. I need to be able to capture the new PPPOE address assigned, so I can email myself the new IP as well as update the NAT Firewall settings, so I can RDP to the system.

The following command works fine from a terminal window, but fails when putting it in a script.

:local nat-ip [ /ip firewall nat get 3 dst-address]

Based on what I've read, if you can do it from a terminal, it will work in a script.

Can anyone tell me what I'm doing wrong.

Thanks
 
Freman
Frequent Visitor
Frequent Visitor
Posts: 76
Joined: Thu Jul 01, 2004 8:49 am

Mon Feb 26, 2007 1:21 am

You can't "get 3"

it has to be from the find command... example

:local nat-interface [/ip firewall nat get [/ip firewall nat find src-address=192.168.2.0/24] out-interface ]

To be real specific I've gone so far as to use comments
/ip firewall nat print
/ip firewall nat set 3 comment="ThisInterface!!!"
:local ip-interface [/ip firewall nat get [/ip firewall nat find comment="ThisInterface!!!"] dst-address ]
 
gregdhayes
newbie
Topic Author
Posts: 47
Joined: Wed Oct 04, 2006 5:35 am
Location: Osgood, IN
Contact:

Mon Feb 26, 2007 1:48 am

I need to get a particular value and I may not know what it is, so I can't do a find.

I specifically need to get the dst-address of a particular NAT entry. In this case it's '3'. 3 being the item # or comment line of the NAT entry.

I need to get it, because I am going to have to do a comparison between the current NAT dst-address and the new pppoe ip address. If they differ, then I'll need to update the NAT dst-address with the new value, then email the new address to myself.

And that's another problem I've yet to figure out. Can't seem to email anybody. But I'm still looking into that.
 
gregdhayes
newbie
Topic Author
Posts: 47
Joined: Wed Oct 04, 2006 5:35 am
Location: Osgood, IN
Contact:

Mon Feb 26, 2007 7:00 am

Still haven't got it working. However, I guess I don't really need it. I could just create the script to get the current setting from the ip route entry and update the NAT entry. Set it run several times a day and be done with it.

Still can't get the email function to work though. Complains about the TO address whenever I put in "xxx@xxx.com" if I take out the @xxx.com portion, it attempts to send and I get a failure notice from my email provider. Don't understand the TO error, but I'm still looking.