Community discussions

MikroTik App
 
1littlewisp
newbie
Topic Author
Posts: 36
Joined: Wed Jun 10, 2009 6:23 pm

Scripting n00b with what is probably a stupid question...

Thu Jul 08, 2010 4:21 am

#This is the first time I have written a RouterOS script and what I'm trying to do is to isolate the IPs of three entries in my firewall ruleset, compare them to the [:resolve]'d value, and replace the value if it is different. I can't seem to get my output to only display the IP address present in the src-address field, though. Below is a sample of what I am attempting, and the output I'm getting. I have tried many variants of this, but this is the most promising attempt I've had.





[admin@RouterOS] > /ip firewall filter get [/ip firewall filter print where comment~".com"] src-address
Flags: X - disabled, I - invalid, D - dynamic
0 ;;; Allow yahoo.com connections to anything
chain=forward action=accept protocol=tcp src-address=72.30.2.43

1 ;;; Allow google.com connections to anything
chain=forward action=accept protocol=tcp src-address=74.125.95.147

2 ;;; Allow facebook.com connections.
chain=forward action=accept protocol=tcp src-address=69.63.189.16
no such item
 
blake
Member
Member
Posts: 426
Joined: Mon May 31, 2010 10:46 pm
Location: Arizona

Re: Scripting n00b with what is probably a stupid question..

Thu Jul 08, 2010 9:23 am

I believe this is what you're looking for.

http://wiki.mikrotik.com/wiki/Use_host_ ... wall_rules
 
1littlewisp
newbie
Topic Author
Posts: 36
Joined: Wed Jun 10, 2009 6:23 pm

Re: Scripting n00b with what is probably a stupid question..

Fri Jul 09, 2010 12:16 am

thank you. that was perfect! good thing someone has already done all of the hard work for me. this has really fueled my desire to delve into routeros scripting, though.
 
kazanova
Member
Member
Posts: 406
Joined: Tue Sep 06, 2005 11:52 am

Re: Scripting n00b with what is probably a stupid question..

Fri Jul 09, 2010 3:29 pm

1littlewisp
who can copy from winbox text with color :S
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Scripting n00b with what is probably a stupid question..

Fri Jul 09, 2010 4:08 pm

Even if you can that doesn't mean you should. That makes it harder to read. Just always use the code tag.
 
1littlewisp
newbie
Topic Author
Posts: 36
Joined: Wed Jun 10, 2009 6:23 pm

Re: Scripting n00b with what is probably a stupid question..

Fri Jul 09, 2010 9:12 pm

1littlewisp
who can copy from winbox text with color :S
Yeah, I just used color tags. Sorry if it made it more difficult to read. I thought it would be helpful. I find it to be extremely helpful on the command line. syntax highlighting helps me determine what the different parts of my command/script are.

Who is online

Users browsing this forum: No registered users and 33 guests