### Check Installed Docker Version Details Source: https://github.com/mageddo/dns-proxy-server/blob/master/examples/using-different-compose-files/README.md Provides the command and expected output for checking the installed Docker client and server versions. This includes detailed information such as API versions, Go versions, Git commits, build dates, and operating system/architecture. ```bash docker version Client: Docker Engine - Community Version: 18.09.0 API version: 1.39 Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:46:51 2018 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.0 API version: 1.39 (minimum version 1.12) Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:52:55 2018 OS/Arch: linux/amd64 Experimental: false ``` -------------------------------- ### Start DNS Proxy Server Frontend Application Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/_index.en.md Steps to start the optional frontend application using npm. Once started, access it via http://localhost:3000/, which will proxy requests to the backend running on http://localhost:5380. ```bash $ cd app && npm start ``` -------------------------------- ### Install Hugo Learn Theme via Git Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/themes/hugo-theme-learn/README.md Instructions to install the Hugo Learn theme by navigating to the Hugo site's themes directory and cloning the theme repository from GitHub. ```shell cd themes git clone https://github.com/matcornic/hugo-theme-learn.git ``` -------------------------------- ### Check Installed Docker Version Details Source: https://github.com/mageddo/dns-proxy-server/blob/master/examples/custom-hostnames-compose-file/README.md This snippet shows how to retrieve detailed version information for both the Docker client and server (Engine). It provides insights into the Docker version, API version, Go version, Git commit, build date, and operating system/architecture, which is useful for debugging and environment verification. ```bash docker version Client: Docker Engine - Community Version: 18.09.0 API version: 1.39 Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:46:51 2018 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.0 API version: 1.39 (minimum version 1.12) Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:52:55 2018 OS/Arch: linux/amd64 Experimental: false ``` -------------------------------- ### Initialize Docker Compose Environment for Service Discovery Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/5-tutorials/docker-reverse-proxy.en.md This sequence of commands sets up the project environment by cloning the DNS Proxy Server repository, navigating to the relevant example directory, building the necessary Docker images without cache, and starting the containers. This action deploys an Nginx reverse proxy and two web applications, forming the foundation for the service discovery and API gateway solution. ```bash $ git clone https://github.com/mageddo/dns-proxy-server.git $ cd examples/api-gateway_service-discovery_reverse-proxy $ docker-compose build --no-cache $ docker-compose up ``` -------------------------------- ### Example: Registering a Container with Custom Domain Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/3-configuration/_index.en.md Demonstrates how running a Docker container will automatically register its name with the configured domain, for example, `nginx.docker`. ```bash docker run --rm --name nginx nginx ``` -------------------------------- ### Install DNS Proxy Server as Linux System Service Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/installing-as-service/_index.en.md Installs the DNS Proxy Server as a native system service on Linux, ensuring it starts automatically with the operating system. This command requires superuser privileges and assumes the dns-proxy-server executable is in the current directory. ```shell sudo ./dns-proxy-server -service=docker ``` -------------------------------- ### Get DNS Proxy Server Command-Line Help Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/3-configuration/_index.en.md Shows how to retrieve command-line instructions and help for the DNS Proxy Server, both when running directly and via Docker. ```bash ./dns-proxy-server --help ``` ```bash docker run defreitas/dns-proxy-server --help ``` -------------------------------- ### Start DPS (DNS Proxy Server) on Linux/macOS Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/_index.en.md Instructions to start the DNS Proxy Server (DPS) directly from its binary. Requires administrator/sudo privileges to allow DPS to set itself as the default DNS server. ```bash sudo ./dns-proxy-server ``` -------------------------------- ### Start DNS Proxy Server Instance for Testing Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/stress-tests.en.md This command sequence builds the DNS Proxy Server (DPS), copies the native executable to the stress test environment, and then starts a Docker Compose stack for the DPS instance, preparing it for stress testing. ```bash ./gradlew clean build compTest shadowJar nativeImageJar nativeCompile -i cp build/native/nativeCompile/dns-proxy-server ./src/stress-test/docker/dps-stress-test-instance/files/ docker-compose -f src/stress-test/docker/dps-stress-test-instance/docker-compose.yml up --build ``` -------------------------------- ### Start DNS Proxy Server with Docker Compose Source: https://github.com/mageddo/dns-proxy-server/blob/master/examples/wildcards/README.md This command initiates the DNS proxy server and its associated services using Docker Compose, bringing up the entire environment as defined in the docker-compose.yml file. ```bash $ docker-compose up ``` -------------------------------- ### Configure Server Protocol Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/3-configuration/_index.en.md Specifies the protocol to start the DNS server. ```APIDOC Parameter: Server Protocol Description: Protocol to start the DNS server. Default: UDP_TCP ``` -------------------------------- ### Example JSON Configuration for DNS Proxy Server (Version 2) Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/3-configuration/_index.en.md Provides a complete example of the version 2 JSON configuration file for the DNS Proxy Server, including remote DNS servers, environment-specific hostnames, and various server settings. ```json { "version": 2, "remoteDnsServers": [ "8.8.8.8", "4.4.4.4:54" ], "envs": [ { "name": "", // empty string is the default enviroment "hostnames": [ // all local hostnames entries { "id": 1, // (optional) used to control it will be automatically generated if not passed "type": "A", "hostname": "github.com", "ip": "192.168.0.1", "ttl": 255 // how many seconds cache this entry } ] } ], "activeEnv": "", "webServerPort": 5380, "dnsServerPort": 53, "logLevel": "INFO", "logFile": "console", "registerContainerNames": false, "domain": "docker", "dpsNetwork": false, "dpsNetworkAutoConnect": false, "defaultDns": true, "hostMachineHostname" : "host.docker", "serverProtocol": "UDP_TCP", "dockerHost": null, "resolvConfOverrideNameServers": true, "noRemoteServers": false, "noEntriesResponseCode": 3, "dockerSolverHostMachineFallbackActive": true, "solverRemote" : { "circuitBreaker" : { "failureThreshold" : 3, "failureThresholdCapacity" : 10, "successThreshold" : 5, "testDelay" : "PT20S" } } } ``` -------------------------------- ### Start DNS Proxy Server Instance for Testing Source: https://github.com/mageddo/dns-proxy-server/blob/master/src/stress-test/docker/grafana/README.md This script compiles the DNS Proxy Server (DPS), copies the native executable, and starts a Docker Compose stack for the DPS instance, preparing it for stress testing. It ensures the DPS is built and running in a test environment. ```bash ./gradlew clean build compTest shadowJar nativeImageJar nativeCompile -i cp build/native/nativeCompile/dns-proxy-server ./src/stress-test/docker/dps-stress-test-instance/files/ docker-compose -f src/stress-test/docker/dps-stress-test-instance/docker-compose.yml up --build ``` -------------------------------- ### Run DNS Proxy Server Backend with Docker Compose Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/_index.en.md Builds the project JAR and then starts the backend service using `docker-compose-dev.yml`. This method leverages Docker Compose for containerized development. ```bash $ ./gradlew clean build shadowJar $ docker-compose -f docker-compose-dev.yml up backend ``` -------------------------------- ### Install DNS Proxy Server as Docker Container Service Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/installing-as-service/_index.en.md Deploys the DNS Proxy Server as a Docker container, configured to restart automatically unless stopped. It maps host volumes for configuration, Docker socket access, and /etc/resolv.conf to ensure proper DNS resolution and service management. ```bash docker run --hostname dns.mageddo --name dns-proxy-server -p 5380:5380 \ --restart=unless-stopped -d \ -v /opt/dns-proxy-server/conf:/app/conf \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /etc/resolv.conf:/etc/resolv.conf \ defreitas/dns-proxy-server ``` -------------------------------- ### Checkout Specific Version of Hugo Learn Theme Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/themes/hugo-theme-learn/README.md Demonstrates how to switch to an older version of the Hugo Learn theme using Git tags, useful for compatibility requirements. This example checks out version 1.1.0. ```shell cd themes/hugo-theme-learn git checkout tags/1.1.0 ``` -------------------------------- ### Create Docker Network and Deploy Services with Docker Compose Source: https://github.com/mageddo/dns-proxy-server/blob/master/examples/using-different-compose-files/README.md Demonstrates how to create a shared, attachable Docker network and then deploy services defined in separate `docker-compose` files. This setup allows containers to communicate without a DNS proxy server, but prevents host-to-container name resolution. ```bash $ docker network create --attachable dps || true &&\ docker-compose -f docker-compose-nginx-server.yml up -d --force-recreate &&\ docker-compose -f docker-compose-client.yml up --force-recreate ``` -------------------------------- ### Start Grafana Stack for Performance Metrics Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/stress-tests.en.md This command initiates a Docker Compose stack that includes Grafana and related services, designed to collect and visualize performance metrics during the stress tests. ```bash docker-compose -f src/stress-test/docker/grafana/docker-compose.yml up --build ``` -------------------------------- ### Start Grafana Stack for Performance Metrics Source: https://github.com/mageddo/dns-proxy-server/blob/master/src/stress-test/docker/grafana/README.md This command initiates a Docker Compose stack for Grafana, which is used to collect and visualize performance metrics during the stress tests. It sets up the monitoring infrastructure. ```bash docker-compose -f src/stress-test/docker/grafana/docker-compose.yml up --build ``` -------------------------------- ### Monitor DNS Proxy Server Linux Service Logs Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/installing-as-service/_index.en.md Displays real-time log output from the DNS Proxy Server service, useful for monitoring startup progress, debugging issues, and verifying service operations. The command continuously outputs new log entries. ```shell tail -f /var/log/dns-proxy-server.log ``` -------------------------------- ### Stub Solver DNS Resolution Examples Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/stub-solver/_index.en.md Illustrates how Stub Solver resolves different IP address formats (dot, dash, hexadecimal, IPv6) into hostnames, both with and without an optional name prefix. ```Conceptual Without a name: * 10.0.0.1.stub => 10.0.0.1 * 192-168-1-250.stub => 192.168.1.250 * 0a000803.stub => 10.0.8.3 With a name: * app.10.8.0.1.stub => 10.8.0.1 * app-116-203-255-68.stub => 116.203.255.68 * app-c0a801fc.stub => 192.168.1.252 * customer1.app.10.0.0.1.stub => 10.0.0.1 * customer2-app-127-0-0-1.stub => 127.0.0.1 * customer3-app-7f000101.stub => 127.0.1.1 * app.2a01-4f8-c17-b8f--2.stub => 2a01:4f8:c17:b8f::2 ``` -------------------------------- ### Example: Successful Disconnect Containers API Response (JavaScript) Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/api/v1/networks.en.md This snippet provides a concrete example of the JSON response returned by the `DELETE /network/disconnect-containers` API endpoint upon a successful operation. It shows a list of success messages for two disconnected containers. ```javascript HTTP/1.1 200 [ "success for 551adbb704bf95ae73f3f8e497560609d2016d1566196298f1787f087af4b5cd", "success for 5f5ce51404b15069795006e7319f270db4f6d822a067e61808eeb0b2922087db" ] ``` -------------------------------- ### Creating Docker Container with HOSTNAMES Environment Variable Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/docker-solving/_index.en.md This command demonstrates how to start a Docker container and assign multiple hostnames to it using the `HOSTNAMES` environment variable. These hostnames will be registered by DPS for DNS resolution. ```bash $ docker run -e HOSTNAMES="nginx1.dev,nginx1.docker" nginx ``` -------------------------------- ### Verify Hostname Resolution for Containers with Curl Source: https://github.com/mageddo/dns-proxy-server/blob/master/examples/custom-hostnames-compose-file/README.md This snippet demonstrates how to verify that multiple hostnames are correctly registered to the same container or that containers can be resolved from the host. It uses a `curl` command to access a service via its hostname and displays the HTTP response and server logs, indicating successful DNS resolution and service access. ```bash $ Every 2s: curl -s -I nginx.server 2019-01-25 05:46:07 curl-client_1_73be594e986d | curl-client_1_73be594e986d | HTTP/1.1 200 OK curl-client_1_73be594e986d | Server: nginx/1.15.8 curl-client_1_73be594e986d | Date: Fri, 25 Jan 2019 05:46:07 GMT curl-client_1_73be594e986d | Content-Type: text/html curl-client_1_73be594e986d | Content-Length: 612 curl-client_1_73be594e986d | Last-Modified: Tue, 25 Dec 2018 09:56:47 GMT curl-client_1_73be594e986d | Connection: keep-alive curl-client_1_73be594e986d | ETag: "5c21fedf-264" curl-client_1_73be594e986d | Accept-Ranges: bytes curl-client_1_73be594e986d | nginx_1_1edd2e86b950 | 172.0.0.3 - - [25/Jan/2019:05:46:07 +0000] "HEAD / HTTP/1.1" 200 0 "-" "curl/7.61.1" "-" ``` -------------------------------- ### Run React App in Development Mode Source: https://github.com/mageddo/dns-proxy-server/blob/master/app/README.md This command starts the React application in development mode, making it accessible via a local server at `http://localhost:3000`. It automatically reloads the page on code edits and displays lint errors directly in the console. ```Shell npm start ``` -------------------------------- ### Restart Docker Compose Services Source: https://github.com/mageddo/dns-proxy-server/blob/master/examples/pre-registered-hosts/README.md This command stops and recreates Docker Compose services, ensuring a fresh start. It's useful for applying configuration changes or resolving issues by rebuilding containers. ```bash docker-compose down && docker-compose up --force-recreate ``` -------------------------------- ### Run DPS with custom port and container registration Source: https://github.com/mageddo/dns-proxy-server/blob/master/README.md This command demonstrates how to start the DNS Proxy Server (DPS) on Linux or Mac. It configures DPS to listen on port 5555 and automatically register Docker container names for DNS resolution. ```bash sudo ./dns-proxy-server --server-port 5555 --register-container-names ``` -------------------------------- ### Basic Hugo Content File Front Matter Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/archetypes/default.md This snippet illustrates the basic structure of a Hugo content file's front matter. It defines metadata such as a dynamically generated title (from the filename), the content's creation date, and a 'draft' status flag, which controls content visibility during site generation. ```Hugo Template --- title: "{{ replace .Name "-" " " | title }}" date: {{ .Date }} draft: true --- ``` -------------------------------- ### Run DNS Proxy Server as a Docker Service Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/linux/_index.en.md Deploy DNS Proxy Server as a Docker container, configured to automatically restart and bind to specific ports. This setup allows DPS to resolve container IPs by mounting the Docker socket and handles DNS traffic on custom ports. ```bash docker run --hostname dns.mageddo --restart=unless-stopped -d \ -p 5354:53/tcp \ -p 5354:53/udp \ -p 5380:5380 \ -v /var/run/docker.sock:/var/run/docker.sock \ defreitas/dns-proxy-server ``` -------------------------------- ### Creating Docker Container with Hostname and Domainname Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/docker-solving/_index.en.md This command starts a Docker container, explicitly setting its hostname and domain name. DPS will register the combination of these for DNS resolution, allowing the container to be accessed via `nginx1.app`. ```bash $ docker run --rm --hostname nginx1 --domainname app nginx ``` -------------------------------- ### Run a Sample Nginx Docker Container Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/accessing-container-by-name/_index.en.md This command starts a new Nginx container named `my-nginx` in detached mode. The `--rm` flag ensures the container is removed when it exits, making it suitable for testing. ```bash $ docker run --rm --name my-nginx nginx ``` -------------------------------- ### Run DNS Proxy Server as Docker Service on macOS Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/mac/_index.en.md Instructions to run DNS Proxy Server (DPS) as a Docker service on macOS, exposing ports 5380 (TCP/UDP) and 53 (TCP/UDP) and mounting the Docker socket for communication. This setup ensures the service restarts automatically unless stopped. ```bash $ docker run -d -p 5380:5380 -p 53:53/udp -p 53:53/tcp --restart=unless-stopped \ -v /var/run/docker.sock:/var/run/docker.sock \ defreitas/dns-proxy-server ``` -------------------------------- ### Verify DNS Resolution with nslookup on Windows Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/windows/_index.en.md These examples demonstrate how to confirm that the DNS Proxy Server (DPS) is correctly resolving both custom local domains (e.g., 'dps-sample.dev') and external public domains (e.g., 'acme.com'). The output shows the local address (127.0.0.1) as the DNS server, indicating DPS is active. ```bash > nslookup dps-sample.dev Server: UnKnown Address: 127.0.0.1 Non-authoritative answer: Name: dps-sample.dev Addresses: 192.168.0.254 192.168.0.254 > nslookup acme.com Server: UnKnown Address: 127.0.0.1 Non-authoritative answer: Name: acme.com Address: 23.93.76.124 ``` -------------------------------- ### Verify Web App 1 Access from Host Machine Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/5-tutorials/docker-reverse-proxy.en.md This command tests the successful routing and accessibility of 'web-app.webapp' from the host machine. It sends an HTTP GET request to the hostname, confirming that the DNS Proxy Server and Nginx reverse proxy are correctly resolving and forwarding requests to the first web application container. ```bash $ curl -i -X GET http://web-app.webapp ``` -------------------------------- ### Build and Run as Jar File Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/compiling.en.md These commands build the DNS proxy server into a runnable Jar file using Gradle and then execute it. The `shadowJar` task creates a fat JAR containing all dependencies, and `-i` provides informational logging during the build process. ```bash $ ./gradlew clean build compTest shadowJar -i $ java -jar dns-proxy-server-*-all.jar ``` -------------------------------- ### Configure Local DNS Entries using JSON Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/local-entries/_index.en.md This JSON configuration example demonstrates how to define local A, AAAA, or CNAME DNS entries. These entries are used by DPS to resolve hostnames locally before querying remote servers. Each entry can specify an optional ID, type, hostname, IP address, and TTL (Time To Live) for caching. ```json { "activeEnv": "", "envs" : [{ "name": "", // empty string is the default enviroment "hostnames": [{ // all local hostnames entries "id": 1, // (optional) used to control it will be automatically generated if not passed "type": "A", // Other options: CNAME, AAAA "hostname": "github.com", "ip": "192.168.0.1", "ttl": 255 // how many seconds cache this entry }] }] } ``` -------------------------------- ### Verify Web App 2 Access from Host Machine Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/5-tutorials/docker-reverse-proxy.en.md This command verifies the successful routing and accessibility of 'web-app-2.webapp' from the host machine. Similar to the first web app test, it sends an HTTP GET request to the hostname, confirming that the DNS Proxy Server and Nginx reverse proxy are correctly resolving and forwarding requests to the second web application container. ```bash $ curl -i -X GET http://web-app-2.webapp ``` -------------------------------- ### JSON Configuration for Static Threshold Circuit Breaker Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/remote-solver-circuitbreaker/_index.en.md This JSON configuration demonstrates how to set up the Static Threshold circuit breaker strategy. This strategy operates by opening and closing circuits based on a fixed count of failures or successes, starting with all remote server circuits closed. Key parameters include `failureThreshold`, `failureThresholdCapacity`, `successThreshold`, and `testDelay`. ```json { "version": 2, "remoteDnsServers": [], "envs": [], "activeEnv": "", "webServerPort": 5380, "dnsServerPort": 53, "logLevel": "INFO", "logFile": "console", "registerContainerNames": false, "domain": "docker", "dpsNetwork": false, "dpsNetworkAutoConnect": false, "defaultDns": true, "hostMachineHostname": "host.docker", "serverProtocol": "UDP_TCP", "dockerHost": null, "resolvConfOverrideNameServers": true, "noRemoteServers": false, "noEntriesResponseCode": 3, "dockerSolverHostMachineFallbackActive": true, "solverRemote": { "circuitBreaker": { "failureThreshold": 3, "failureThresholdCapacity": 10, "successThreshold": 5, "testDelay": "PT20S" } } } ``` -------------------------------- ### Preview Documentation Live with Hugo (Vanilla) Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/generating-docs.en.md This command allows you to preview the documentation locally using the Hugo development server. It serves the content from the 'docs' directory, providing a real-time view of changes. ```bash $ hugo server --source docs ``` -------------------------------- ### Generate and Run Native Binary Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/compiling.en.md These commands compile the DNS proxy server into a native executable using Gradle's `nativeCompile` task and then run the generated binary. The `-x check` flag skips the check task during the build process, optimizing for native compilation. ```bash $ ./gradlew -x check clean build nativeIntTest nativeImageJar nativeCompile $ ./build/native/nativeCompile/dns-proxy-server ``` -------------------------------- ### Build Frontend Files Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/compiling.en.md This command builds the optional frontend files for the DNS proxy server. It uses the `builder.bash` script to execute the `build-frontend` task, which prepares static assets. ```bash ./builder.bash build-frontend ``` -------------------------------- ### Preview Documentation Live with Docker Compose Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/generating-docs.en.md This command uses Docker Compose to spin up a container that serves the documentation live. It utilizes the 'docker-compose-dev.yml' file and targets the 'docs' service, providing an isolated environment for preview. ```bash $ docker-compose -f docker-compose-dev.yml up docs ``` -------------------------------- ### Verify DNS Resolution for Pre-configured Entries Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/_index.en.md Demonstrates how to verify that DPS is correctly resolving pre-configured entries from 'conf/config.json' by pinging a sample domain. ```bash $ ping dps-sample.dev PING dps-sample.dev (192.168.0.254) 56(84) bytes of data. ``` -------------------------------- ### List Available Network Services on macOS Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/mac/_index.en.md Command to list all available network services on macOS, which is a prerequisite for manually configuring DNS settings. It helps identify the correct network interface (e.g., Wi-Fi) to modify. ```bash $ networksetup -listallnetworkservices An asterisk (*) denotes that a network service is disabled. USB 10/100/1000 LAN Wi-Fi Thunderbolt Bridge ``` -------------------------------- ### Creating Docker Container with Specific Name Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/docker-solving/_index.en.md This command starts a Docker container with a user-defined name. When `MG_REGISTER_CONTAINER_NAMES=1` is enabled in DPS, this name can be used for DNS resolution. ```bash $ docker run --rm --name nginx1 nginx ``` -------------------------------- ### Restart systemd-resolved Service on Linux Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/linux/_index.en.md Restart the `systemd-resolved` service to apply any changes made to its configuration file. This ensures the system begins using the newly specified DNS server. ```bash $ service systemd-resolved restart ``` -------------------------------- ### Uninstall DNS Proxy Server Linux System Service Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/installing-as-service/_index.en.md Removes the DNS Proxy Server system service from Linux. This operation is irreversible and will prompt for confirmation before proceeding. ```shell sudo service dns-proxy-server uninstall ``` -------------------------------- ### Build React App for Production Source: https://github.com/mageddo/dns-proxy-server/blob/master/app/README.md This command builds the React application for production, optimizing it for performance and bundling all necessary assets into the `build` folder. The output is minified, and filenames include hashes, making the app ready for deployment. ```Shell npm run build ``` -------------------------------- ### Run DNS Proxy Server Backend Locally Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/_index.en.md Instructions to run the DNS Proxy Server backend application directly from the JAR file after building it with Gradle. DNS queries should be directed to the IP and ports indicated in the console log. ```bash $ ./gradlew clean shadowJar && java -jar ./build/libs/dns-proxy-server-*-all.jar ``` -------------------------------- ### Stop DNS Proxy Server Linux System Service Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/installing-as-service/_index.en.md Halts the running DNS Proxy Server system service on Linux. This command requires superuser privileges to manage system services. ```shell sudo service dns-proxy-server stop ``` -------------------------------- ### Generate Static Documentation HTML Files Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/generating-docs.en.md This command executes the 'builder.bash' script to generate the static HTML files for the documentation. The output will be placed in the designated documentation output directory, ready for deployment. ```bash $ ./builder.bash docs ``` -------------------------------- ### Generate Native Image Metadata Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/compiling.en.md These Gradle commands generate necessary metadata for building a native image of the DNS proxy server. The `-Pagent` flag is used during the `clean` and `compTest` phases to collect runtime information, followed by copying the generated metadata. ```bash ./gradlew clean -Pagent compTest ./gradlew metadataCopy ``` -------------------------------- ### List Network Interfaces and IPs on Linux Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/linux/_index.en.md Use the `ip addr` command to display all network interfaces and their assigned IP addresses. This is crucial for identifying the correct local IP to configure `systemd-resolved` when DPS is running on a non-standard port. ```bash $ ip addr ``` -------------------------------- ### Example: Disconnect Containers using cURL (Bash) Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/api/v1/networks.en.md This cURL command demonstrates how to make a `DELETE` request to the `/network/disconnect-containers` API endpoint. It includes the `networkId` query parameter to specify the target network for container disconnection. ```bash $ curl -X DELETE dns.mageddo:5380/network/disconnect-containers/?networkId=85e7564c6b71 ``` -------------------------------- ### Define Overlay Network in Docker Compose Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/dps-network-resolution/_index.en.md This `docker-compose.yml` defines an `nginx-1` service on an overlay network, simulating a scenario where containers are isolated from the host and other networks. This setup demonstrates the problem of inter-container communication in an overlay-only environment. ```yaml version: '3.2' services: nginx-1: image: nginx container_name: nginx-1 hostname: nginx-1.app networks: - nginx-network networks: nginx-network: driver: overlay attachable: true ``` -------------------------------- ### JavaScript for Syntax Highlighting and Mermaid Diagram Initialization Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/themes/hugo-theme-learn/layouts/partials/footer.html These JavaScript snippets initialize client-side libraries upon page load. `hljs.initHighlightingOnLoad()` activates Highlight.js to automatically detect and style code blocks, enhancing readability. `mermaid.initialize({ startOnLoad: true })` configures Mermaid.js to render diagram definitions found in the HTML, enabling visual representations of flowcharts, sequence diagrams, and more. ```JavaScript hljs.initHighlightingOnLoad(); mermaid.initialize({ startOnLoad: true }); ``` -------------------------------- ### Add Bridge Network to Docker Compose for Connectivity Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/dps-network-resolution/_index.en.md This `docker-compose.yml` modifies the previous setup by adding a bridge network (`nginx-network-bridge`) to the `nginx-1` service. This resolves the isolation issue, allowing the container to be accessible from the host or other bridge-connected containers. ```yaml version: '3.2' services: nginx-1: image: nginx container_name: nginx-1 hostname: nginx-1.app networks: - nginx-network - nginx-network-bridge networks: nginx-network: driver: overlay attachable: true nginx-network-bridge: driver: bridge ``` -------------------------------- ### Test Docker Overlay Network Isolation Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/dps-network-resolution/_index.en.md These commands start the Docker Compose services and attempt to access `nginx-1.app`. The `curl` command is expected to fail with a connection timeout, illustrating the network isolation issue when only an overlay network is used. ```bash $ docker-compose up $ curl --connect-timeout 2 nginx-1.app curl: (7) Failed to connect to nginx-1.app port 80: Connection timed out ``` -------------------------------- ### Run DNS Proxy Server as Docker Service on Windows Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/windows/_index.en.md This command initiates the DNS Proxy Server (DPS) as a Docker container, ensuring it automatically restarts with the system. It maps standard DNS ports (53 UDP/TCP) and the GUI port (5380) from the host to the container, and mounts the Docker socket for internal container resolution capabilities. ```bash $ docker run -d --restart=unless-stopped -p 53:53/udp -p 53:53/tcp -p 5380:5380 -v /var/run/docker.sock:/var/run/docker.sock defreitas/dns-proxy-server ``` -------------------------------- ### Execute Native Image Integration Tests Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/_index.en.md Runs integration tests specifically designed to verify the functionality of the native image binary. These tests cannot use mocking frameworks like Mockito and rely on flags instead of stubs/mocks to ensure compatibility with native image compilation. Tests ending with `IntTest.java` are run within the native image binary. ```bash $ ./gradlew clean nativeIntTest ``` -------------------------------- ### Execute Stress Test Suite Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/stress-tests.en.md This Gradle command builds the project and then runs the defined stress test suite, simulating load on the DNS Proxy Server instance to evaluate its performance under stress. ```bash ./gradlew build stressTest ``` -------------------------------- ### Resolve host machine IP using `host.docker` with DPS Source: https://github.com/mageddo/dns-proxy-server/blob/master/README.md This example shows how DPS can resolve the IP address of the host machine itself using the special host.docker hostname. nslookup queries DPS on port 5555, which then provides the host's IP address. ```bash $ nslookup -po=5555 host.docker 127.0.0.1 172.22.230.67 ``` -------------------------------- ### Hugo Template for Dynamic Navigation and Partials Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/themes/hugo-theme-learn/layouts/partials/footer.html This Hugo template code defines a recursive function 'menu-nextprev' to traverse site menus and determine 'next' and 'previous' pages. It handles page visibility, sets scratch variables for navigation links, and includes custom HTML partials. The logic ensures correct navigation links are generated based on the current page's position within the site structure. ```Go Template {{ if .Params.chapter }} {{ end }} {{ partial "custom-comments.html" . }} {{ $currentNode := . }} {{ template "menu-nextprev" dict "menu" .Site.Home "currentnode" $currentNode }} {{ define "menu-nextprev" }} {{$currentNode := .currentnode }} {{ if ne .menu.Params.hidden true}} {{if hasPrefix $currentNode.URL .menu.URL }} {{ $currentNode.Scratch.Set "NextPageOK" "OK" }} {{ $currentNode.Scratch.Set "prevPage" ($currentNode.Scratch.Get "prevPageTmp") }} {{else}} {{if eq ($currentNode.Scratch.Get "NextPageOK") "OK"}} {{ $currentNode.Scratch.Set "NextPageOK" nil }} {{ $currentNode.Scratch.Set "nextPage" .menu }} {{end}} {{end}} {{ $currentNode.Scratch.Set "prevPageTmp" .menu }} {{ $currentNode.Scratch.Set "pages" .menu.Pages }} {{ if .menu.IsHome}} {{ $currentNode.Scratch.Set "pages" .menu.Sections }} {{ else if .menu.Sections}} {{ $currentNode.Scratch.Set "pages" (.menu.Pages | union .menu.Sections) }} {{end}} {{ $pages := ($currentNode.Scratch.Get "pages") }} {{ range $pages.ByWeight }} {{ template "menu-nextprev" dict "menu" . "currentnode" $currentNode }} {{end}} {{ end }} {{ end }} {{$showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev))}} {{if $showPrevNext}} {{with ($.Scratch.Get "prevPage")}} []({{.URL}} "{{.Title}}"){{end}} {{with ($.Scratch.Get "nextPage")}} []({{.URL}} "{{.Title}}"){{end}} {{end}} ``` -------------------------------- ### Customize host machine hostname via JSON configuration Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/2-features/solving-host-machine-ip/_index.en.md Provides an example of how to define the host machine's hostname using a JSON configuration file. The `hostMachineHostname` property within the JSON object specifies the desired alias, offering a structured configuration approach. ```json { "hostMachineHostname": "host.docker" } ``` -------------------------------- ### Run DNS Proxy Server Standalone on Linux Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/linux/_index.en.md Execute the DNS Proxy Server directly on a Linux system after downloading and extracting the release. This command runs DPS as the primary DNS server until terminated. ```bash $ sudo ./dns-proxy-server ``` -------------------------------- ### DNS Proxy Server Command Line Arguments Source: https://github.com/mageddo/dns-proxy-server/blob/master/src/test/resources/flags-test/002.txt Details all available command-line arguments for configuring the DNS Proxy Server, including their short and long forms, expected values, default settings, and a brief explanation of their purpose. ```APIDOC Command:
Description: Command-line interface for the DNS Proxy Server. Arguments: -conf-path, --conf-path=: Type: string Description: The config file path. Default: conf/config.json -default-dns, --default-dns: Type: boolean flag Description: This DNS server will be the default server for this machine. Default: true -docker-host, --docker-host=: Type: string Description: The docker host address. Default: the default docker host value based on the OS -docker-solver-host-machine-fallback, --docker-solver-host-machine-fallback: Type: boolean flag Description: Whether should answer host machine IP when a matching container is found but it hasn't an IP to be answered. See Github Issue #442 Default: false -domain, --domain=: Type: string Description: Domain utilized to solver containers and services hostnames. Default: docker -dps-network, --dps-network: Type: boolean flag Description: Create a bridge network for DPS increasing compatibility. Default: false -dps-network-auto-connect, --dps-network-auto-connect: Type: boolean flag Description: Connect all running and new containers to the DPS network, this way you will probably not have resolution issues by acl (implies dps-network=true). Default: false -help, --help: Type: boolean flag Description: This message. Default: false -host-machine-hostname, --host-machine-hostname=: Type: string Description: The hostname to get host machine IP. Default: host.docker -log-file, --log-file=: Type: string Description: Log to file instead of console. (true=log to default log file, /tmp/log.log=log to custom log location) Default: console -log-level, --log-level=: Type: string (ERROR, WARNING, INFO, DEBUG) Description: Log Level. Default: INFO -no-entries-response-code, --no-entries-response-code=: Type: integer Description: Response code to use when no entries are returned by the configured solvers (3 means NXDOMAIN). Default: 3 -no-remote-servers, --no-remote-servers: Type: boolean flag Description: If remote servers like 8.8.8.8 must be disabled and only local solvers like docker containers or local db must be used. Default: false -register-container-names, --register-container-names: Type: boolean flag Description: If must register container name / service name as host in DNS server. Default: false -resolvconf-override-name-servers, --resolvconf-override-name-servers: Type: boolean flag Description: If must comment all existing nameservers at resolv.conf file or just put DPS at the first place. Default: true -server-port, --server-port=: Type: integer Description: The DNS server to start into. Default: 53 -service, --service=: Type: string (docker, normal, uninstall) Description: Setup as service, starting with machine at boot. Default: -service-publish-web-port, --service-publish-web-port: Type: boolean flag Description: Publish web port when running as service in docker mode. Default: true -stub-solver-domain-name, --stub-solver-domain-name=: Type: string Description: The domain name used for stub solver resolved hostnames. Default: Not specified -version, --version: Type: boolean flag Description: Shows the current version. Default: false -web-server-port, --web-server-port=: Type: integer Description: The web server port. Default: 5380 ``` -------------------------------- ### Check Docker Version Information Source: https://github.com/mageddo/dns-proxy-server/blob/master/examples/pre-registered-hosts/README.md Displays detailed version information for both the Docker client and server (engine). This includes version numbers, API versions, Go versions, and build details, useful for debugging and compatibility checks. ```text docker version Client: Docker Engine - Community Version: 18.09.0 API version: 1.39 Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:46:51 2018 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.0 API version: 1.39 (minimum version 1.12) Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:52:55 2018 OS/Arch: linux/amd64 Experimental: false ``` -------------------------------- ### Resolve public domain names via DPS proxy Source: https://github.com/mageddo/dns-proxy-server/blob/master/README.md This example shows DPS acting as a DNS proxy, forwarding requests for public domain names like google.com to remote DNS servers. nslookup queries DPS on port 5555, which then resolves the domain via the internet. ```bash $ nslookup -po=5555 google.com 127.0.0.1 142.250.79.174 ``` -------------------------------- ### Resolve Docker container by name using DPS Source: https://github.com/mageddo/dns-proxy-server/blob/master/README.md This example shows how to resolve a Docker container's IP address using its container name (nginx-app.docker) through DPS. It first runs an Nginx container and then uses nslookup to query DPS on port 5555 for the container's IP. ```bash $ docker run --rm --name nginx-app nginx $ nslookup -po=5555 nginx-app.docker 127.0.0.1 172.17.0.3 ``` -------------------------------- ### Execute JAR Version Integration Tests Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/_index.en.md Runs integration tests against the standard JAR version of the application. These tests are similar to component tests but are used to verify functionality without the native image compilation constraints. ```bash $ ./gradlew clean intTest ``` -------------------------------- ### Resolve Stub Hostnames (nip.io, sslip.io) with DPS Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/_index.en.md This example showcases DPS's capability to resolve stub hostnames, commonly used by services like 'nip.io' or 'sslip.io', which embed IP addresses directly within the hostname. It queries DPS for a hostname like 'machine-1.192.168.0.1.stub' to retrieve the embedded IP. ```bash $ nslookup -po=5555 machine-1.192.168.0.1.stub 127.0.0.1 ``` -------------------------------- ### Launch React App Test Runner Source: https://github.com/mageddo/dns-proxy-server/blob/master/app/README.md This command launches the test runner for the React application in interactive watch mode. It allows developers to run tests and see results in real-time as changes are made to the codebase. ```Shell npm test ``` -------------------------------- ### Resolve Docker Container by Hostname using DPS Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/_index.en.md This example illustrates how to resolve a Docker container's IP address using a custom hostname (e.g., 'nginx.dev') assigned during container creation. It involves running an Nginx container with a specified hostname and subsequently querying DPS via 'nslookup' for its resolution. ```bash $ docker run --rm --hostname nginx.dev nginx $ nslookup -po=5555 nginx.dev 127.0.0.1 ``` -------------------------------- ### Run DNS Proxy Server Backend Interactively in Docker Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/4-developing/_index.en.md Builds the project JAR, then runs an interactive bash session within the backend container defined in `docker-compose-dev.yml`. From within the container, the application JAR is executed manually. ```bash $ ./gradlew clean build shadowJar -i -x check $ docker-compose -f docker-compose-dev.yml run --rm -it backend bash $ java -jar dns-proxy-server-*-all.jar ``` -------------------------------- ### Run DNS Proxy Server Standalone on macOS Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/mac/_index.en.md Instructions to run DNS Proxy Server (DPS) as a standalone Java application on macOS. It requires downloading the JAR release and executing it with `sudo java -jar`. When run standalone, DPS can auto-configure itself as the OSX default DNS. ```bash $ sudo java -jar ./dns-proxy-server ``` -------------------------------- ### Verify Inter-Container DNS Resolution with Docker Compose Source: https://github.com/mageddo/dns-proxy-server/blob/master/examples/using-same-compose-file/README.md This snippet demonstrates how to start a Docker Compose application and verify that containers can resolve each other by name, specifically showing a `curl` client successfully reaching an `nginx` service. It notes that for containers within the same `docker-compose` file (v2/v3), an external DNS proxy like DPS is not necessary for name resolution. ```bash $ docker-compose -f docker-compose-v2.yml up --force-recreate Every 2s: curl -s -I nginx 2019-01-25 05:03:09 curl-client_1_b51dbdc408d6 | nginx_1_d21a8dc439bc | 172.25.0.2 - - [25/Jan/2019:05:03:09 +0000] "HEAD / HTTP/1.1" 200 0 "-" "curl/7.61.1" "-" curl-client_1_b51dbdc408d6 | HTTP/1.1 200 OK curl-client_1_b51dbdc408d6 | Server: nginx/1.15.8 curl-client_1_b51dbdc408d6 | Date: Fri, 25 Jan 2019 05:03:09 GMT curl-client_1_b51dbdc408d6 | Content-Type: text/html curl-client_1_b51dbdc408d6 | Content-Length: 612 curl-client_1_b51dbdc408d6 | Last-Modified: Tue, 25 Dec 2018 09:56:47 GMT curl-client_1_b51dbdc408d6 | Connection: keep-alive curl-client_1_b51dbdc408d6 | ETag: "5c21fedf-264" curl-client_1_b51dbdc408d6 | Accept-Ranges: bytes ``` -------------------------------- ### Accessing Site Parameters in Hugo Go Template Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/themes/hugo-theme-learn/layouts/shortcodes/siteparam.html This Go template snippet retrieves a site parameter by its name, passed as the first argument to the shortcode. It first gets the parameter name, then accesses the site's parameters, and finally indexes into them using the lowercase version of the parameter name. This is commonly used in Hugo shortcodes to dynamically fetch configuration values. ```Go Template {{- $paramName := (.Get 0) -}} {{- $siteParams := .Site.Params -}} {{- with $paramName -}} {{- with $siteParams -}} {{- index . (lower $paramName) -}} {{- end -}} {{- end -}} ``` -------------------------------- ### Configure Web Server Port Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/3-configuration/_index.en.md Sets the port for the Web GUI. ```APIDOC Parameter: Web Server Port Description: Web GUI port. Default: 5380 ``` -------------------------------- ### Configure Resolvconf Override Name Servers Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/3-configuration/_index.en.md Determines if existing nameservers in `resolv.conf` (Linux, MacOS) should be commented out, or if DPS should simply be placed first. ```APIDOC Parameter: Resolvconf Override Name Servers Description: If must comment all existing nameservers at resolv.conf (Linux, MacOS) or just put DPS at the first place. Default: true Configuration Options: Env: MG_RESOLVCONF_OVERRIDE_NAMESERVERS JSON: resolvConfOverrideNameServers Terminal: See --help ``` -------------------------------- ### Check Current DNS Servers for a Network Service on macOS Source: https://github.com/mageddo/dns-proxy-server/blob/master/docs/content/1-getting-started/running-it/mac/_index.en.md Command to check if any DNS servers are currently configured for a specific network service on macOS, such as 'Wi-Fi'. This step is recommended before making changes to allow for backing up existing configurations. ```bash $ networksetup -getdnsservers Wi-Fi There aren't any DNS Servers set on Wi-Fi. ```