From dd26e9e55168efecd7d768a554f624160f90c246 Mon Sep 17 00:00:00 2001
From: Daniel J Walsh <dwalsh@redhat.com>
Date: Mon, 7 Dec 2020 07:14:27 -0500
Subject: [PATCH] Improve documentation of use with Podman

Replace: https://github.com/containers/dnsname/pull/39
Originally submitted by @omarc1492

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
---
 README_PODMAN.md        | 42 ++++++++++++++++++++++++++++--------
 example/foobar.conflist | 48 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 9 deletions(-)
 create mode 100644 example/foobar.conflist

diff --git a/README_PODMAN.md b/README_PODMAN.md
index 8709f9e..43b35b7 100644
--- a/README_PODMAN.md
+++ b/README_PODMAN.md
@@ -17,25 +17,49 @@ Using your package manager, install the *dnsmasq* package.  For Fedora, this wou
 ## Build and install
 
 1. using git, clone the *github.com/containers/dnsname* repository.
-2. make install PREFIX=/usr -- this will install the dnsname plugin into /usr/libexec/cni where your CNI plugins
-should already exist.
+2. make install PREFIX=/usr -- this will install the dnsname plugin into /usr/libexec/cni where
+your CNI plugins should already exist.
 
 ## Configure a CNI network for Podman
 
 1. Create a new network using `podman network create`.  For example, `podman network create foobar` will suffice.
 
-The following example [configuration file](example/cni-podman1.conflist) shows a usable example for Podman.
+The following example [configuration file](example/foobar.conflist) shows a usable example for Podman.
+
+2. (optional)+The configuration will be automatically enabled for newly created networks via
+`podman network create`. If you want to add this feature to an exisiting network add the needed
+lines to `/etc/cni/net.d/foobar.conflist` using your favorite editor. For example:
+
+ ```
+{
+   "cniVersion": "0.4.0",
+   "name": "foobar",
+   "plugins": [
+      ...
+      {
+         "type": "dnsname",
+         "domainName": "dns.podman"
+         "capabilities": {
+            "aliases": true
+         }
+      }
+   ]
+}
+ ```
 
 ## Example: container name resolution
 
-1. sudo podman run -dt --name web --network foobar quay.io/libpod/alpine_nginx:latest
-    5139d65d22135e9ecab511559d863754550894a32285befd94dab231017048c2
+In this test image, the nginx server will
+respond with *podman rulez* on an http request.
+**Note**: we use the --network foobar here.
 
-    Note: we use the --network foobar here. Also, in this test image, the nginx server will respond with
-    *podman rulez* on an http request.
-2. sudo podman run -it --name client --network cni-podman1 quay.io/libpod/alpine_nginx:latest curl http://web/
-podman rulez
+```console
+sudo podman run -dt --name web --network foobar quay.io/libpod/alpine_nginx:latest
+5139d65d22135e9ecab511559d863754550894a32285befd94dab231017048c2
 
+sudo podman run -it --name client --network foobar quay.io/libpod/alpine_nginx:latest curl http://web/
+podman rulez
+```
 
 ## Enabling name resolution on the default Podman network
 After making sure the *dnsplugin* is functioning properly, you can add name resolution to your default Podman
diff --git a/example/foobar.conflist b/example/foobar.conflist
new file mode 100644
index 0000000..d13880e
--- /dev/null
+++ b/example/foobar.conflist
@@ -0,0 +1,48 @@
+{
+   "cniVersion": "0.4.0",
+   "name": "foobar",
+   "plugins": [
+      {
+         "type": "bridge",
+         "bridge": "cni-podman1",
+         "isGateway": true,
+         "ipMasq": true,
+         "hairpinMode": true,
+         "ipam": {
+            "type": "host-local",
+            "routes": [
+               {
+                  "dst": "0.0.0.0/0"
+               }
+            ],
+            "ranges": [
+               [
+                  {
+                     "subnet": "10.89.0.0/24"
+                  }
+               ]
+            ]
+         }
+      },
+      {
+         "type": "portmap",
+         "capabilities": {
+            "portMappings": true
+         }
+      },
+      {
+         "type": "firewall",
+         "backend": ""
+      },
+      {
+         "type": "tuning"
+      },
+      {
+         "type": "dnsname",
+         "domainName": "dns.podman",
+         "capabilities": {
+            "aliases": true
+         }
+      }
+   ]
+}
\ No newline at end of file
-- 
GitLab