Linux dns is hijacked, and linuxdns is hijacked

Source: Internet
Author: User
Tags nameserver nslookup

Linux dns is hijacked, and linuxdns is hijacked

Environment: ubuntu16.04

We have encountered dns hijacking today. Here we record it:

1. First, how to determine whether a hijacking occurs:

Query a domain name that does not exist.

Nslookup notexit. comrrrr

If an IP address is returned, dns is hijacked. Assume that the IP address is 123.34.5.6.

Use the 8.8.8.8 Domain Name Server to resolve this incorrect Domain Name:

Nslookup notexit. comrrrr 8.8.8.8

The output content is as follows:

Jello @ jello :~ $ Nslookup notexit. comrrrr 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8 #53

** Server can't find notexit. comrrrr: NXDOMAIN

 

The prompt indicates that this domain name does not exist.

2. How can this problem be solved?

Because ubuntu16.04 uses dnsmasq to resolve the domain name, modify the configuration file of dnsmasq:

Because linux has a restriction on processing dns requests, in/etc/resolv. only three dns addresses can be configured in conf. in the conf file, only localhost is retained as the Domain Name Server, create a configuration file to store the address of the external Domain Name Server, and add the configuration file to the configuration item resolv-file of dnsmasq. For example:

2.1 create the configuration file/etc/resolv. my. conf and enter the following content:

Nameserver 8.8.8.8

Nameserver 8.8.4.4

2.2 Add the following content to/etc/dnsmasq. conf:

Resolv-file =/etc/resolv. my. conf

2.3 restart dnsmasq

Systemctl restart dnsmasq

 

Note: If the dnsmasq restart times out, enable/var/run/dnsmasq/resolv. conf directly.

There is a domain name server address obtained by parsing a domain name that does not exist. You can delete a line that contains the Domain Name Server address. Assume that the content of this file is:

Nameserver 123.34.5.6

Nameserver 231.43.5.45

Delete the nameserver 123.34.5.6 directly.

 

The most effective solution is as follows:

3. You can also directly replace the two ip addresses with other Domain Name Server addresses, and then restart dnsmasq. After the author modifies the configuration file/var/run/dnsmasq/resolv. conf as follows:

Nameserver 8.8.8.8

Nameserver 8.8.4.4

Restart dnsmasq:

Systemctl restart dnsmasq

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.