Community discussions

MikroTik App
 
CarulloS
Member
Member
Topic Author
Posts: 406
Joined: Thu Feb 02, 2006 5:52 am

IP Firewall Filter basic question

Wed Mar 12, 2008 5:08 am

What is the most efficient way to accomplish the following:

Setup:
6 ports on router ROS 3.3 x86
One port is hooked to internet where all traffic from outside world comes in (CALL IT eth1)
One port is hooked to multiple servers, lets focus on special server 208.208.208.208 (CALL IT eth2)
Ignore the other 4 ports, they go to other internal network links

Objective:
All outgoing traffic originating from 208.208.208.208 to go to internet unrestricted (NS lookups, email, other)
Only tcp port 25 incoming smtp traffic from internet (from eth1) to 208.208.208.208 server

Thats it, should be pretty simple. I'm looking for an answer to clarify something in my mind about how a internet host is able to reply to traffic requests originating from 208.208.208.208 server - say http request to google or something. Its not port 25 coming in but rather a reply to legitimate request from the 208.208.208.208 server which needs to work. dns queries need to work from the server as well.

Thanks for your time...

Scott
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: IP Firewall Filter basic question

Wed Mar 12, 2008 12:44 pm

Greetings!

Take a look at the Firewall section of the docs. There are examples at the bottom. "Protect your router" is important. You should at least use it.

Then for the email, do something like the example for ICMP. Also the first example (at least in the V2.9 docs) is an example for port 135. Change 135 to 25 and drop to accept. Put it at the top of the filters.
 
CarulloS
Member
Member
Topic Author
Posts: 406
Joined: Thu Feb 02, 2006 5:52 am

Re: IP Firewall Filter basic question

Wed Mar 12, 2008 4:32 pm

Thanks for your time, however I was looking for a more detailed more specific answer to my question which is why I provided all the details necessary for a complete custom answer.

I use the firewall rules now for a lot of things and I have a fairly good understanding of how they work. The one specific item I am looking to learn more about it how to accept traffic from an internet host that is replying to traffic originated from the server listed above.

For example - you try to telnet into port 80 of my server from the source port of say 80 from your computer on the internet. Firewall rule should stop this traffic from ever hitting my server. But, if I do the exact same thing in reverse to your maching from my server it should work.

Scott
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: IP Firewall Filter basic question

Wed Mar 12, 2008 9:48 pm

I am not exactly certain what you want. This 208.208.208.208 server is a local net computer on ether2, correct? What is the IP address of ether2? Like 208.208.208.1/24?

If that is the case, and presuming that ether1 is set up and working, then:
/ip address add address=208.208.208.1/24 interface=ether2
/ip dns set primary-dns=yyy.yyy.yyy.yyy
/ip dns set secondary-dns=zzz.zzz.zzz.zzz
/ip dns set allow-remote-requests=yes
/ip firewall nat add chain=srcnat action=masquerade out-interface=ether1

This allows you to surf the net from anywhere on the 208.208.208.0/24 net on ether2, including your server at 208.208.208.208.
Static IP only. If you want a dhcp server then
/ip dhcp-server setup

That is part one. Let me know when part one works. I do not recommend going on until this part works. Then you want only port 25 requests forwarded to ether2 208.208.208.208 from your ether1 IP, correct?

BTW, I would recommend staying with accepted private IP address ranges, like the 10.x.x.x and 192.168.x.x sets on ether2.
208.x.x.x is a public net address.
 
CarulloS
Member
Member
Topic Author
Posts: 406
Joined: Thu Feb 02, 2006 5:52 am

Re: IP Firewall Filter basic question

Thu Mar 13, 2008 3:14 am

Its not private IP space. Its public routed ips. I know how to to everything you have taken them time to show so far. I appreciate your time, but I am only interested in how to let traffic go out from a server but not let anything come into it.

Scott
 
User avatar
Letni
Member
Member
Posts: 376
Joined: Tue Dec 05, 2006 5:16 am
Location: South Carolina

Re: IP Firewall Filter basic question

Thu Mar 13, 2008 4:15 am

Try something along these lines.
/ip firewall filter
add chain=forward action=accept connection-state=established dst-address=208.208.208.208 comment="Accept Established" disabled=no 
add chain=forward action=accept dst-port=25 protocol=tcp comment="Allow SMTP" disabled=no 
add chain=forward action=log comment="Blocked" dst-address=208.208.208.208 disabled=no 
add chain=forward action=drop dst-address=208.208.208.208 comment="Drop" disabled=no 
-Louis
 
CarulloS
Member
Member
Topic Author
Posts: 406
Joined: Thu Feb 02, 2006 5:52 am

Re: IP Firewall Filter basic question

Thu Mar 13, 2008 5:26 am

Thanks Louis,

That is what I was expecting. Now for what I was getting to... Your first rule about accepting incoming traffic once connection established with an internet host -- what happens with say a dns udp port 53 request? UDP traffic is connectionless so how will it handle this traffic even if a dns server is responding to a request for my server? Will the traffic be blocked since there is no connection established?

Now we are having the discussion I was interested in :)

Thanks,
Scott
 
User avatar
Letni
Member
Member
Posts: 376
Joined: Tue Dec 05, 2006 5:16 am
Location: South Carolina

Re: IP Firewall Filter basic question

Thu Mar 13, 2008 5:55 am

Even though it is connectionless, RouterOS putts an entry in the firewall connection table. IP --> Firewall: Connections
The timeout settings for UDP is through the Tracking button.

-Louis
 
CarulloS
Member
Member
Topic Author
Posts: 406
Joined: Thu Feb 02, 2006 5:52 am

Re: IP Firewall Filter basic question

Thu Mar 13, 2008 6:55 am

Thank you, thats the info I was after when I started this post...

Scott
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: IP Firewall Filter basic question

Thu Mar 13, 2008 12:06 pm

All that, and you just wanted a bridge? :?
Thanks, Letni, for taking care of the rest.