0xERR0R / blocky

Fast and lightweight DNS proxy as ad-blocker for local network with many features
https://0xERR0R.github.io/blocky/
Apache License 2.0
4.62k stars 203 forks source link

windows: start up with loopback dns configured - no route to host #247

Closed adamsewell closed 3 years ago

adamsewell commented 3 years ago

I'm using a test machine to play around with blocky, which the machine has 127.0.0.1 configured as the DNS server to use blocky. When starting blocky in this scenario, it is unable to download any of the feeds off the get go. I thought that maybe bootstrapDns would be the right setting to enable but it doesn't appear to help. Am I missing something or could blocky use the upstream resolvers to download the feeds on stat up? Thanks!

[2021-08-22 08:18:43]  INFO list_cache: starting download link=http://sysctl.org/cameleon/hosts
[2021-08-22 08:18:43]  INFO list_cache: starting download link=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
[2021-08-22 08:18:43]  WARN list_cache: error during file processing: Get "http://sysctl.org/cameleon/hosts": dial tcp: lookup sysctl.org: no such host
[2021-08-22 08:18:43]  WARN list_cache: error during file processing: Get "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts": dial tcp: lookup raw.githubusercontent.com: no such host
[2021-08-22 08:18:43]  INFO list_cache: group import finished group=ads total_count=0
[2021-08-22 08:18:43]  INFO list_cache: starting download link=https://urlhaus.abuse.ch/downloads/hostfile/
[2021-08-22 08:18:43]  WARN list_cache: error during file processing: Get "https://urlhaus.abuse.ch/downloads/hostfile/": dial tcp: lookup urlhaus.abuse.ch: no such host
[2021-08-22 08:18:43]  INFO list_cache: group import finished group=phishing total_count=0

Current config:

upstream:
  default:
    - 1.0.0.1
    - 9.9.9.9
    - 94.140.14.14
blocking:
  blackLists:
    ads:
      - https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
      - http://sysctl.org/cameleon/hosts
      - https://block.energized.pro/basic/formats/hosts
    phishing:
      - https://urlhaus.abuse.ch/downloads/hostfile/
    porn:
      - https://block.energized.pro/porn/formats/hosts
  whiteLists:
    ads:
      - https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt
  clientGroupsBlock:
    default:
      - ads
      - phishing
port: 53
httpPort: 4000
bootstrapDns: tcp+udp:8.8.4.4
0xERR0R commented 3 years ago

Your config looks good. "bootstrapDns" resolver should be used to resolve the addresses from the links. If you add logLevel: trace to you config, do you see "using 8.8.4.4:53 as bootstrap dns server"?

adamsewell commented 3 years ago

Yes, it's there. I should also mention this is on a Windows host.

[2021-08-22 20:50:34] DEBUG using 8.8.4.4:53 as bootstrap dns server
[2021-08-22 20:50:34]  INFO list_cache: starting download link=https://urlhaus.abuse.ch/downloads/hostfile/
[2021-08-22 20:50:34]  WARN list_cache: error during file processing: Get "https://urlhaus.abuse.ch/downloads/hostfile/": dial tcp: lookup urlhaus.abuse.ch: no such host
[2021-08-22 20:50:34]  INFO list_cache: group import finished group=phishing total_count=0
[2021-08-22 20:50:34]  INFO list_cache: starting download link=https://block.energized.pro/porn/formats/hosts
[2021-08-22 20:50:34]  WARN list_cache: error during file processing: Get "https://block.energized.pro/porn/formats/hosts": dial tcp: lookup block.energized.pro: no such host
[2021-08-22 20:50:34]  INFO list_cache: group import finished group=porn total_count=0
[2021-08-22 20:50:34]  INFO list_cache: starting download link=https://block.energized.pro/basic/formats/hosts
[2021-08-22 20:50:34]  INFO list_cache: starting download link=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
[2021-08-22 20:50:34]  WARN list_cache: error during file processing: Get "https://block.energized.pro/basic/formats/hosts": dial tcp: lookup block.energized.pro: no such host
[2021-08-22 20:50:34]  INFO list_cache: starting download link=http://sysctl.org/cameleon/hosts
[2021-08-22 20:50:34]  WARN list_cache: error during file processing: Get "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts": dial tcp: lookup raw.githubusercontent.com: no such host
[2021-08-22 20:50:34]  WARN list_cache: error during file processing: Get "http://sysctl.org/cameleon/hosts": dial tcp: lookup sysctl.org: no such host
[2021-08-22 20:50:34]  INFO list_cache: group import finished group=ads total_count=0
[2021-08-22 20:50:34]  INFO list_cache: starting download link=https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt
[2021-08-22 20:50:34]  WARN list_cache: error during file processing: Get "https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt": dial tcp: lookup raw.githubusercontent.com: no such host
0xERR0R commented 3 years ago

interesting, I have only linux machines to test. Is 8.8.4.4 reachable with nslookup (nslookup raw.githubusercontent.com 8.8.4.4)

0xERR0R commented 3 years ago

I'll try today on a Windows 10 VM, maybe this is only Windows problem

adamsewell commented 3 years ago

That's what I'm testing on as well.

0xERR0R commented 3 years ago

blocky I tried blocky 0.15 on windows 10 with your config, start was successful.

Maybe windows blocks some connections on your machine?

adamsewell commented 3 years ago

Well that is super odd. This is a fresh install of Windows 10 with nothing else installed, no AV, no well... anything installed. And you had set your DNS to manual config with 127.0.0.1 as the DNS server?

If I add a DNS server like 1.1.1.1 as the secondary it works as expected. I really seems like it's trying to default to the configured DNS rather than the bootstrap.

0xERR0R commented 3 years ago

No, I just started blocky and tried to perform a request against it with nslookup (nslookup google.com 127.0.0.1) and it worked. I'll try again with DNS configuraiton

0xERR0R commented 3 years ago

I tried again, it worked. After disabling of Ipv6 I could reproduce the behavior. Same error "no such host".

Tried on linux with reconfiguration of DNS server -> it works.

adamsewell commented 3 years ago

Well that is super weird now, I just tried it again here at my office and it's working just fine with IPv6 enabled. I don't recall disabling IPv6 but it's possible I did.

I disabled IPv6 and sure enough, no route to host.

0xERR0R commented 3 years ago

It looks like golang uses under windows always the system resolver. There is an open proposal in golang which addresses this problem: https://github.com/golang/go/issues/33097

As far I understand. it is not possible to use custom DNS resolver in go binaries in windows

0xERR0R commented 3 years ago

Updated documentation, added a note that the bootstrapDns works only under Linux/*Nix OSes. Since this is a Go limitation, I'll close this issue and hope this will be fixed in near future by Go devs.