Thanks for hanging in there today. I did eventually get it sorted and of all things -- it came down to WSL on Windows not having the xt_TPROXY
module. So -- lesson learned by me to not use WSL for tproxy stuff...
Here's the shortest list of steps that can accomplish the goal and demonstrate a container intercepting a ficticiouis DNS entry and sending it to another container. Hopefully it's clear. I'll record a super short video for this soon.
Terminal 1
curl -so docker-compose.yaml https://get.openziti.io/dock/docker-compose.yml
curl -so .env https://get.openziti.io/dock/.env
edit the ZITI_PWD to admin (or replace the admin password used below)
add this to the docker compose file.
-
to ziti-controller service, add this network:
extranet:
aliases:
- ziti-edge-controller
-
to ziti-edge-router service, add this network:
- extranet
-
to networks, declare an external network:
extranet:
external: true
Then, create the extranet network. This network is just meant to be sort of like 'the internet' or the 'green' network (you could call it zitigreen of course):
docker network create extranet
bring up the compose file:
docker compose up
Terminal 2
establish a name for the intercepting router, login to the ziti controller and create the router (deleting it is not necessary but let's you re-run these steps if you want)
router_name="intercepting-router"
ziti edge login localhost:1280 -u admin -p admin -y
ziti edge delete edge-router "${router_name}"
ziti edge create edge-router "${router_name}" -o "${router_name}.jwt" -t
once that's done, you can run a new container (i didn't use compose to try to keep it simpler, dunno if it makes it easier or not to follow/understand). Note that I use --rm
here so when the container terminates, you'll lose the router. again it was to make it so you can run all the commands over and over if you like... Also note the addition of the -e
param for the control plane port. You could of simply edit the .env file if you want as well:
docker run --rm \
--env-file .env \
--name intercepting-router \
--user root \
--dns 127.0.0.1 \
--dns 1.1.1.1 \
--env ZITI_ROUTER_MODE=tproxy \
--env ZITI_CTRL_ADVERTISED_PORT=6262 \
--cap-add NET_ADMIN \
--network extranet \
--env ZITI_ENROLL_TOKEN="$(< intercepting-router.jwt)" \
openziti/ziti-router
Terminal 3
Configure the new intercepting router to be able to intercept traffic for the web-test-blue http server, configure a service and authorize the dial/bind containers
router_name="intercepting-router"
binder="ziti-private-blue"
dialer="${router_name}"
ziti edge login localhost:1280 -u admin -p admin -y
ziti edge delete service-policy "http-web-test-blue.dial"
ziti edge delete service-policy "http-web-test-blue.binder"
ziti edge delete service "http-web-test-blue.svc"
ziti edge delete config "http-web-test-blue.intercept.v1"
ziti edge delete config "http-web-test-blue.host.v1"
ziti edge create config "http-web-test-blue.intercept.v1" intercept.v1 \
'{"protocols":["tcp"],"addresses":["http-web-test-blue.ziti"], "portRanges":[{"low":8000, "high":8000}]}'
ziti edge create config "http-web-test-blue.host.v1" host.v1 \
'{"protocol":"tcp", "address":"web-test-blue","port":8000 }'
ziti edge create service "http-web-test-blue.svc" \
--configs "http-web-test-blue.intercept.v1","http-web-test-blue.host.v1"
ziti edge create service-policy "http-web-test-blue.dial" Dial \
--service-roles "@http-web-test-blue.svc" \
--identity-roles "@${dialer}"
ziti edge create service-policy "http-web-test-blue.binder" Bind \
--service-roles "@http-web-test-blue.svc" \
--identity-roles "@${binder}"
Let the containers receive the update (about 15 seconds ish?) and then -- use the intercepting router container in some other container to run a curl:
docker run \
--rm \
--name intercepting-client \
--network container:intercepting-router \
openziti/quickstart curl -s http://http-web-test-blue.ziti:8000
Assuming everything works, you'll see the ziti logo:
cd@deb12:~/docker-demo/complex$ docker run \
--rm \
--name intercepting-client \
--network container:intercepting-router \
openziti/quickstart curl -s http://http-web-test-blue.ziti:8000
<pre>
Hello World
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::,::$77777777777777,:,::::::::::::::::::::
::::::::::::::::::77777777777777777777777~,:::::::::::::::::
:::::::::::::::77777777777777II7777777777777,:::::::::::::::
::::::::::::$777777777777777I.:7777777777777777,::::::::::::
::::::::::77777777777777777I...I7777777777777777I:::::::::::
:::::::::77777777777777777I....?777777777777777777::::::::::
:::::::$77777777777777777I......77777777777777777777::::::::
::::::777777777777777777I.......I77777777777777777777,::::::
:::::777777777777777777I....?...?777777777777777777777::::::
:::,777777777777777777I....I7?...777777777777777777777$:::::
:::777777777777777777I....I77I...I777777777777777777777$::::
:::77777777777777777I....I7777...?7777777777777777777777::::
::77777777777777777I....I77777?..,77777777777777777777777:::
::7777777777777777I....I777777I...I77777777777777$7$$$$7$,::
:$777777777777777I....I77777777...?7777777777777$$77777777::
:777777777777777I ...I777II7777?...I.I7777777$777777777777::
:77777777777777I....I777I..7777I.......?I777$$$$$77$$$$7$$::
:7777777777777I....?I77I...I7777..........I777777$$$$$7$$$,:
:77777777777777?.. .??. ?7777? ..??. .?7$7$$$7$$$$$7::
,7777777777777777I..........I$77I...I777?....77777$7$$$$$$,,
:7777777777777777777?.......I7$$7..I777I....7$$$$$$$$$$$$$::
:777777777777777777777I.I=..?77777777$7....77$$$$$$$$7$$$$::
:777777777777777777777777I...I$7777777....77$$$$$$$$$$$$$$::
::77777777777777$7$7$$$$$I...?7$$7$77....7$$$$$$$$$$$$$$$:::
::777777777777777777$$$777+..~77$$7I....77$$$$$$$$$$$$$$$:::
:::77777777777777777777$$7I...7$$$I....7$7$$$$$$$$$$$$$$::::
:::Z77777777$7777777777$77I...?$77....I$$$$$$$$$$$$$$$$$::::
::::77777$$$$$7777$$$$$$$$7:..+77....I$$$$$$$$$$$$$$$$$:::::
:::::77777$777$$$$777$$$$77I...I....I$$$$$$$$$$$$$$$$$::::::
::::::$7777777$7777$$$7$$$$I...... I$$$$$$$$$$$$$$$$7:::::::
:::::::?$$$$$$$$$$$$$$$$$$$7=.....I$$$$$$$$$$$$$$$$=::::::::
:::::::::7$$$$$7$$$$$$$$$$$$?....77$$$$$$$$$$$$$$$::::::::::
::::::::::,7$$7$$$$$$$$$$$$$7...I$$$$$$$$$$$$$$$::::::::::::
::::::::::::~$$$$$$$$$$$$$$$7?.I$$$$$$$$$$$$$$::::::::::::::
:::::::::::::::$$$$$$$$$$$$$$77$$$$$$$$$$$$$::::::::::::::::
::::::::::::::::::7$$$$$$$$$$$$$$$$$$$$$$:::::::::::::::::::
:::::::::::::::::::::::$$$$$$$$$$$$$::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
</pre>