Ce qui nous créé une images avec la commane tcpdump
# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE
tcpdump latest 9cc11b561802 7 seconds ago 123MB
Utilisation de l’image Tcpdump
L’idée est de pouvoir analyser la communication entre plusieurs containers, par exemple le traffic entre les gateways wireguard. Il est possible de lancer un container qui s’accroche au réseau d’un autre container avec l’option --network=container:<container_name>
# docker ps
1CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
254343975be23 masipcat/wireguard-go:latest "/entrypoint.sh"15 minutes ago Up 15 minutes GW_CL1
3b9d22ebbc6c2 masipcat/wireguard-go:latest "/entrypoint.sh"15 minutes ago Up 15 minutes GW_CL2
407f1e4236644 lscr.io/linuxserver/openssh-server:latest "/init"15 minutes ago Up 15 minutes server_1
589958c26c546 lscr.io/linuxserver/openssh-server:latest "/init"15 minutes ago Up 15 minutes server_3
65ddec96e70aa masipcat/wireguard-go:latest "/entrypoint.sh"15 minutes ago Up 15 minutes GW_PRES
70c91a8bf2fea lscr.io/linuxserver/openssh-server:latest "/init"15 minutes ago Up 15 minutes server_2
On lance le container TCPDUMP sur le réseau cible
docker run --tty --rm --net=container:GW_PRES tcpdump
On obtient ceci:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
18:37:31.969196 IP GW_PRES.51820 > GW_CL1.ext_net.51820: UDP, length 3218:37:32.634443 IP GW_CL2.ext_net.51820 > GW_PRES.51820: UDP, length 3218:37:36.969316 IP GW_PRES.51820 > GW_CL1.ext_net.51820: UDP, length 3218:37:36.969439 IP GW_CL1.ext_net.51820 > GW_PRES.51820: UDP, length 3218:37:37.634630 IP GW_CL2.ext_net.51820 > GW_PRES.51820: UDP, length 3218:37:41.969612 IP GW_PRES.51820 > GW_CL1.ext_net.51820: UDP, length 3218:37:41.969626 IP GW_CL1.ext_net.51820 > GW_PRES.51820: UDP, length 3218:37:41.992623 ARP, Request who-has GW_CL1.ext_net tell GW_PRES, length 2818:37:41.992922 ARP, Request who-has GW_PRES tell GW_CL1.ext_net, length 2818:37:41.992926 ARP, Reply GW_PRES is-at 02:42:0a:0a:00:05 (oui Unknown), length 2818:37:41.992932 ARP, Reply GW_CL1.ext_net is-at 02:42:0a:14:00:05 (oui Unknown), length 2818:37:42.634807 IP GW_PRES.51820 > GW_CL2.ext_net.51820: UDP, length 3218:37:42.634824 IP GW_CL2.ext_net.51820 > GW_PRES.51820: UDP, length 32
On voit que la commande attachée à notre container espion sur l’interface eth0 de notre container GW_PRES
# docker exec -it GW_PRES ifconfig -a
On voit s’aperçoit que notre container possède plusieurs interfaces réseaux