docker-squid icon indicating copy to clipboard operation
docker-squid copied to clipboard

How to use this container for rewriting existing domain's IP

Open sameersbn opened this issue 7 years ago • 0 comments

I'm trying to use this container for rewriting an existing domain's IP inside a private network.

My setup is that I have a private network with some machines setup and a router which has an internet accessible public IP. One of these machines is serving some content to the internet under a domain (say example.com) pointing to the public IP, by having a port opened from router to it. The thing is that other machines in the private network also need access to that server. Router however blocks packets originating from inside to access the public IP. So I thought I would use this container as a local DNS server to overwrite that public IP with the local one.

I have setup this container with this docker-compose file:

version: '2'

services:
  bind:
    image: sameersbn/bind:latest
    restart: always
    dns: 8.8.8.8
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"
    environment:
        - ROOT_PASSWORD=somepass
    ports:
      - 10000:10000
      - 53:53/udp
    volumes:
      - ./data:/data

and added following ACL and configs to it:

acl localclients {
	192.168.0.0/16;
	172.17.0.0/16;
	localhost;
	localnets;
};

options {
	directory "/var/cache/bind";
	dnssec-validation auto;

	auth-nxdomain no;
	listen-on-v6 { any; };
	listen-on {
		any;
		};

	recursion yes;

	allow-query { any; };
	allow-recursion {
		localclients;
		};
	allow-query-cache { localclients; };
}

currently looking up domain name on docker's host machine (with IP 192.168.1.6) works as expected:

$ nslookup example.com
Server:		192.168.1.6
Address:	192.168.1.64#53

Name:	example.com
Address: 192.168.1.4

but I can't use that for another container:

$ docker run --rm busybox nslookup example.com
Server:    192.168.1.6
Address 1: 192.168.1.6 servername

Name:      example.com
Address 1: 188.15.221.88

where 188.15.221.88 is the public IP. do I need additional config set on the container?

sameersbn avatar Mar 15 '18 16:03 sameersbn