Community discussions

MikroTik App
 
herbw
just joined
Topic Author
Posts: 2
Joined: Fri Jan 18, 2019 4:58 am

How to delete all DNS Servers

Fri Jan 18, 2019 5:06 am

Using the command line, I can add a DNS server using: ip dns set servers 8.8.8.8

Is there any way to remove all of the DNS servers (leaving only the Dynamic Servers) using the command line? The only command I have found allows me to replace the DNS servers with a new list of DNS servers, but it does not allow me to specify an empty list. The only way I have found to remove all DNS servers is using the GUI.
 
Reinis
MikroTik Support
MikroTik Support
Posts: 78
Joined: Wed Jan 02, 2019 12:14 pm
Location: Latvia
Contact:

Re: How to delete all DNS Servers

Fri Jan 18, 2019 2:26 pm

Using the command line, I can add a DNS server using: ip dns set servers 8.8.8.8

Is there any way to remove all of the DNS servers (leaving only the Dynamic Servers) using the command line? The only command I have found allows me to replace the DNS servers with a new list of DNS servers, but it does not allow me to specify an empty list. The only way I have found to remove all DNS servers is using the GUI.
You can use
/ip dns edit servers
and remove everything inside it to remove all the entries. CTRL+O to save the changes.
If you want to add multiple entries from CLI, separate the addresses with a comma, example: 9.9.9.9,1.1.1.1
 
mkx
Forum Guru
Forum Guru
Posts: 4358
Joined: Thu Mar 03, 2016 10:23 pm

Re: How to delete all DNS Servers  [SOLVED]

Fri Jan 18, 2019 2:37 pm

How about
/ip dns set servers=""
(note double quotes).
BR,
Metod
 
anav
Forum Guru
Forum Guru
Posts: 4700
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada

Re: How to delete all DNS Servers

Fri Jan 18, 2019 3:55 pm

When you say dynamic DNS servers, do you simply mean you want all users to use the DNS servers from your ISP provider(s)?
If not which DNS servers are you referring to??
I'd rather manage rats than software. Follow my advice at your own risk! (Sob & mkx forced me to write that!)
 
herbw
just joined
Topic Author
Posts: 2
Joined: Fri Jan 18, 2019 4:58 am

Re: How to delete all DNS Servers

Fri Jan 18, 2019 6:34 pm

Thanks to all who replied. As noted, mkx's solution solved the problem.

To anav, yes, what I want to do is use only the servers from my ISP provider. In the GUI, these are displayed as Dynamic Servers.

To reiniss2, this solution would probably work, but is not as elegant as using double quotes.
 
anav
Forum Guru
Forum Guru
Posts: 4700
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada

Re: How to delete all DNS Servers

Fri Jan 18, 2019 8:39 pm

Okay that would have been dirt simple using WINBOX.
If you want to force all users to use the ISPs dns servers.........

1. Ensure under dhcp client that the checkbox "USE PEER DNS" was checked off was used.
2. Under IP DNS - Remove any manually inserted DNS servers such as 8.8.8.8 or Open DNS ones etc.
3. Also while there click on the Static Tab on the right because the default setup sneakily puts one in there and it took me forever to find the pesky bugger.
4. Ensure each network
/ip dhcp-server network has the gatewayIP of the network selected for DNS associated IP

5. In your firewall NAT rules put in the following redirect rules (you will note they are disabled at the moment and mine are setup to apply to my non vlan interfaces and thus you will have to substitute for your own applicable LAN interfaces - could be in-interface-list=lan for example)...

add action=redirect chain=dstnat comment=\
"Force Users to Router for DNS - TCP" disabled=yes dst-port=53 protocol=\
tcp src-address-list=!VLAN_Interfaces
add action=redirect chain=dstnat comment=\
"Force Users to Router for DNS - UDP" disabled=yes dst-port=53 protocol=\
udp src-address-list=!VLAN_Interfaces

6. I am curious to get feedback from others about the value of placing the following two forward chain rules, BEFORE the first standard accept established and related rules
add action=drop chain=forward comment="Drop LAN DNS queries-UDP" dst-port=53 \
in-interface-list=WAN protocol=udp
add action=drop chain=forward comment="Drop LAN DNS queries - TCP" dst-port=\
53 in-interface-list=WAN protocol=tcp

Especially because my last forward chain rule is DROP all else anyway.
I'd rather manage rats than software. Follow my advice at your own risk! (Sob & mkx forced me to write that!)

Who is online

Users browsing this forum: aeichhorn, eworm and 140 guests