The RB in my setup acts as DHCP server and uses the RB as DHCP server local IP : 192.168.1.1
But since this DNS blockings done in the RB’s DNS this user still have the possibility to manual add a different DNS server e.g. a Open DNS server to the Computer and in that way work around the blocking.
So I was thinking if it would be possible somehow to block the local users from using other DNS servers than the RB itself.
And so that it is only the DB that has access to ask the 2 external DNS servers 89.184.128.250 and 89.184.128.193.
So that no local users can ask other DNS server that the one in the RB itself.
While that is possible, the rules you posted directly inspect packets and have nothing to do with what DNS server a user is using. In fact, because they are in your example only running in the forward chain they specifically wouldn’t work if a user is using the router as a DNS server - packets from the client to the router are in the input chain and replies are in the output chain, packets from the router to another DNS server on the Internet are in the output chain and replies are in the input chain.
Specifically DNS related: To force a client to use your DNS server no matter what they configure on their computer, you could create a nat rule like this:
Thanks, that rule could be very helpful for my setup. I am trying to understand how the rule and I just can’t get my head around it. It just seems to me that any packet UDP with dest. port 53 and an address outside the LAN is being redirected to dest. port 53 (it was already dest port 53). I am sure the rule works and I would just like to understand how this will force the client to use the DNS given by the RB.
‘redirect’ is a special kind of NAT that rewrites the destination IP address in the packet header to an IP address on the routers so that the packet gets redirected to the DNS process running on the router.
I have tried with your rule to only allow DNS from the clients to the Router itself
But I don’t seems to work, when I enter the command it asks for
chain: where I can shoes from dstnat and srcnat
And I will only accept it then I chose dstnat.
But the rule doesn’t seems to work.
Bacause on my laptop I have entered static DNS servers from OpenDNS for testing and it can still acces the internet and ping all new addresses.
And can in the Firewall /connection se that my Local IP is talking with the external IP op the DNS server on port 53.
It should be so hat it’s not possible to ask other DNS servers than the router itself on ip 192.168.1.1 so that only the router then can ash the external DNS servers.
My problem is that i even as i have the above rules to block for torrents and other stuff sometimes have those entries in my DNS list of the router.
With the above rules the access to utorrent should be blocked.
With my own machine I can’t ping or access the website or anything and nothings shows up in the DNS list when I try, but sometimes whose records show up in the Router DNS so I am afraid that some of the users somehow have found a way to bypass the restrictions.
Ore can someone explain how those records sometimes can show up ?
The rule about redirecting DNS traffic works pretty well. You can test it by pinging to www.google.com for example,
once with the rule activated and the other time without it. In every case don’t forget to flush the dns cache of the PC.
From the test you should see different IP-s for the same dns name (of course when the dns name has more than one server)
As for your configuration, you should set the firewall filter rule in the input chain.
I tested it myself, without using the Layer-7 you posted, I tested it for the whole DNS traffic and it blocked it
only in the input chain and not in the forward chain.
About your post of the layer-7 rule capturing isohunt for example, in my test it didn’t captured it.
I am not that good in layer-7, so can not comment much more about it, but it may be not accurate.
One way to block those connections could be to use a static dns entry to resolve to a false IP. The dstnat rule I posted above still applies, you still would need that.
You could use regular expressions in static dns entries to redirect *.utorrent.com to IP: 127.0.0.1 for example. This would prevent that domain from resolving.
Thanks that solved the problem with the “Torrent” in the DNS.
Now I only need to get solved my last problem for force the users to use the RB as the DNS server so that they are now able to use any other DNS server like Open DNS ore things like that.
Thats also the way i had created the rule, but i am still afraid its not working quite as it should.
When i test it by giving at computer a static address and set the DNS Server to eg. OpenDNS 208.67.222.222 and 208.67.220.220
Then when i monitor the Firewall Connections i can se my local IP connecting to the IP of the OpenDNS servers, on port 53 when i ping different web sites so must assume that the rule is not working.
And its possible for me to ping addresses that are blocked in my RB
/ip dns static
add address=127.0.0.1 comment="" disabled=no name=.*thepiratebay.org ttl=1d
But wouldend it be possible to make the rule so that its not possible from the intenal site LAN to connect to External DNS Servers via WAN so thats its only possible for the RB to ask the DNS server. In that way the users would be forced to use the RB as the DNS Server since direct connection to external DNS Servers are blocked.
Yes the traffic by the Nat Rule is counting so traffic is coming to it.
And have found out that it’s only counting bytes then I use other DNS Servers than the RB itself, so some part of the rule works.
I use a RB450G with Software Version 4.11
I am also having this config in the box
Equal bandwidth sharing among users http://www.ahmedramze.com/lecture/mikrotik.pdf
But don’t thing that shot have any impact on the configuration about the DNS.
But a work around would be to Block LAN users from connecting to External DNS servers in that case they would be forced to us the RB as their DNS.
But are not sure how to do that since the users still should be able to access the DNS of the RB so that I not block that.
The dst-address-type=!local should be in there. It basically does not capture traffic if it’s already destined for the router itself.
So if my router’s IP is 192.168.88.1, and the client uses that IP as the DNS server, you wouldn’t want the nat rule executed as it would get natted and consume unnecessary resources at every dns request. If the client uses an IP that is not local to the router, say 1.2.3.4, this rule gets executed so that the packet is redirected to the router itself. The router then makes a separate dns request to external dns servers (in this case opendns). Also, dns requests happen on udp, not tcp. tcp is mostly used for dns updates to dns server itself.
Centauri,
When you look at /ip firewall connection, you should see two dns connections, one coming from the client to the router. then another from the router to an it’s own configured dns server(s).