Giter Club home page Giter Club logo

netshoot's Introduction

netshoot: a Docker + Kubernetes network trouble-shooting swiss-army container

                    dP            dP                           dP
                    88            88                           88
88d888b. .d8888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P
88'  `88 88ooood8   88   Y8ooooo. 88'  `88 88'  `88 88'  `88   88
88    88 88.  ...   88         88 88    88 88.  .88 88.  .88   88
dP    dP `88888P'   dP   `88888P' dP    dP `88888P' `88888P'   dP

Purpose: Docker and Kubernetes network troubleshooting can become complex. With proper understanding of how Docker and Kubernetes networking works and the right set of tools, you can troubleshoot and resolve these networking issues. The netshoot container has a set of powerful networking troubleshooting tools that can be used to troubleshoot Docker networking issues. Along with these tools come a set of use-cases that show how this container can be used in real-world scenarios.

Network Namespaces: Before starting to use this tool, it's important to go over one key topic: Network Namespaces. Network namespaces provide isolation of the system resources associated with networking. Docker uses network and other type of namespaces (pid,mount,user..etc) to create an isolated environment for each container. Everything from interfaces, routes, and IPs is completely isolated within the network namespace of the container.

Kubernetes also uses network namespaces. Kubelets creates a network namespace per pod where all containers in that pod share that same network namespace (eths,IP, tcp sockets...etc). This is a key difference between Docker containers and Kubernetes pods.

Cool thing about namespaces is that you can switch between them. You can enter a different container's network namespace, perform some troubleshooting on its network's stack with tools that aren't even installed on that container. Additionally, netshoot can be used to troubleshoot the host itself by using the host's network namespace. This allows you to perform any troubleshooting without installing any new packages directly on the host or your application's package.

Netshoot with Docker

  • Container's Network Namespace: If you're having networking issues with your application's container, you can launch netshoot with that container's network namespace like this:

    $ docker run -it --net container:<container_name> nicolaka/netshoot

  • Host's Network Namespace: If you think the networking issue is on the host itself, you can launch netshoot with that host's network namespace:

    $ docker run -it --net host nicolaka/netshoot

  • Network's Network Namespace: If you want to troubleshoot a Docker network, you can enter the network's namespace using nsenter. This is explained in the nsenter section below.

Netshoot with Docker Compose

You can easily deploy netshoot using Docker Compose using something like this:

version: "3.6"
services:
  tcpdump:
    image: nicolaka/netshoot
    depends_on:
      - nginx
    command: tcpdump -i eth0 -w /data/nginx.pcap
    network_mode: service:nginx
    volumes:
      - $PWD/data:/data

  nginx:
    image: nginx:alpine
    ports:
      - 80:80

Netshoot with Kubernetes

  • if you want to debug using an ephemeral container in an existing pod:

    $ kubectl debug mypod -it --image=nicolaka/netshoot

  • if you want to spin up a throw away pod for debugging.

    $ kubectl run tmp-shell --rm -i --tty --image nicolaka/netshoot

  • if you want to spin up a container on the host's network namespace.

    $ kubectl run tmp-shell --rm -i --tty --overrides='{"spec": {"hostNetwork": true}}' --image nicolaka/netshoot

  • if you want to use netshoot as a sidecar container to troubleshoot your application container

   $ cat netshoot-sidecar.yaml
   apiVersion: apps/v1
   kind: Deployment
   metadata:
       name: nginx-netshoot
       labels:
           app: nginx-netshoot
   spec:
   replicas: 1
   selector:
       matchLabels:
           app: nginx-netshoot
   template:
       metadata:
       labels:
           app: nginx-netshoot
       spec:
           containers:
           - name: nginx
           image: nginx:1.14.2
           ports:
               - containerPort: 80
           - name: netshoot
           image: nicolaka/netshoot
           command: ["/bin/bash"]
           args: ["-c", "while true; do ping localhost; sleep 60;done"]

   $ kubectl apply -f netshoot-sidecar.yaml
     deployment.apps/nginx-netshoot created

   $ kubectl get pod
NAME                              READY   STATUS    RESTARTS   AGE
nginx-netshoot-7f9c6957f8-kr8q6   2/2     Running   0          4m27s

   $ kubectl exec -it nginx-netshoot-7f9c6957f8-kr8q6 -c netshoot -- /bin/zsh
                       dP            dP                           dP
                       88            88                           88
   88d888b. .d8888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P
   88'  `88 88ooood8   88   Y8ooooo. 88'  `88 88'  `88 88'  `88   88
   88    88 88.  ...   88         88 88    88 88.  .88 88.  .88   88
   dP    dP `88888P'   dP   `88888P' dP    dP `88888P' `88888P'   dP

   Welcome to Netshoot! (github.com/nicolaka/netshoot)


   nginx-netshoot-7f9c6957f8-kr8q6 $ 

The netshoot kubectl plugin

To easily troubleshoot networking issues in your k8s environment, you can leverage the Netshoot Kubectl Plugin (shout out to Nebojsa Ilic for creating it!). Using this kubectl plugin, you can easily create ephemeral netshoot containers to troubleshoot existing pods, k8s controller or worker nodes. To install the plugin, follow these steps.

Sample Usage:

# spin up a throwaway pod for troubleshooting
kubectl netshoot run tmp-shell

# debug using an ephemeral container in an existing pod
kubectl netshoot debug my-existing-pod

# create a debug session on a node
kubectl netshoot debug node/my-node

Network Problems

Many network issues could result in application performance degradation. Some of those issues could be related to the underlying networking infrastructure(underlay). Others could be related to misconfiguration at the host or Docker level. Let's take a look at common networking issues:

  • latency
  • routing
  • DNS resolution
  • firewall
  • incomplete ARPs

To troubleshoot these issues, netshoot includes a set of powerful tools as recommended by this diagram.

Included Packages: The following packages are included in netshoot. We'll go over some with some sample use-cases.

apache2-utils \
bash \
bind-tools \
bird \
bridge-utils \
busybox-extras \
conntrack-tools \
curl \
dhcping \
drill \
ethtool \
file\
fping \
grpcurl \
iftop \
iperf \
iperf3 \
iproute2 \
ipset \
iptables \
iptraf-ng \
iputils \
ipvsadm \
jq \
libc6-compat \
liboping \
ltrace \
mtr \
net-snmp-tools \
netcat-openbsd \
nftables \
ngrep \
nmap \
nmap-nping \
nmap-scripts \
openssl \
py3-pip \
py3-setuptools \
scapy \
socat \
speedtest-cli \
openssh \
strace \
tcpdump \
tcptraceroute \
tshark \
util-linux \
vim \
git \
zsh \
websocat \
swaks \
perl-crypt-ssleay \
perl-net-ssleay

Sample Use-cases

iperf

Purpose: test networking performance between two containers/hosts.

Create Overlay network:

$ docker network create -d overlay perf-test

Launch two containers:

๐Ÿณ  โ†’ docker service create --name perf-test-a --network perf-test nicolaka/netshoot iperf -s -p 9999
7dkcckjs0g7b4eddv8e5ez9nv


๐Ÿณ  โ†’ docker service create --name perf-test-b --network perf-test nicolaka/netshoot iperf -c perf-test-a -p 9999
2yb6fxls5ezfnav2z93lua8xl



 ๐Ÿณ  โ†’ docker service ls
ID            NAME         REPLICAS  IMAGE              COMMAND
2yb6fxls5ezf  perf-test-b  1/1       nicolaka/netshoot  iperf -c perf-test-a -p 9999
7dkcckjs0g7b  perf-test-a  1/1       nicolaka/netshoot  iperf -s -p 9999



๐Ÿณ  โ†’ docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS               NAMES
ce4ff40a5456        nicolaka/netshoot:latest   "iperf -s -p 9999"       31 seconds ago      Up 30 seconds                           perf-test-a.1.bil2mo8inj3r9nyrss1g15qav

๐Ÿณ  โ†’ docker logs ce4ff40a5456
------------------------------------------------------------
Server listening on TCP port 9999
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 10.0.3.3 port 9999 connected with 10.0.3.5 port 35102
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec  32.7 GBytes  28.1 Gbits/sec
[  5] local 10.0.3.3 port 9999 connected with 10.0.3.5 port 35112

tcpdump

tcpdump is a powerful and common packet analyzer that runs under the command line. It allows the user to display TCP/IP and other packets being transmitted or received over an attached network interface.

# Continuing on the iperf example. Let's launch netshoot with perf-test-a's container network namespace.

๐Ÿณ  โ†’ docker run -it --net container:perf-test-a.1.0qlf1kaka0cq38gojf7wcatoa  nicolaka/netshoot 

# Capturing packets on eth0 and tcp port 9999.

/ # tcpdump -i eth0 port 9999 -c 1 -Xvv
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
23:14:09.771825 IP (tos 0x0, ttl 64, id 60898, offset 0, flags [DF], proto TCP (6), length 64360)
    10.0.3.5.60032 > 0e2ccbf3d608.9999: Flags [.], cksum 0x1563 (incorrect -> 0x895d), seq 222376702:222441010, ack 3545090958, win 221, options [nop,nop,TS val 2488870 ecr 2488869], length 64308
	0x0000:  4500 fb68 ede2 4000 4006 37a5 0a00 0305  E..h..@[email protected].....
	0x0010:  0a00 0303 ea80 270f 0d41 32fe d34d cb8e  ......'..A2..M..
	0x0020:  8010 00dd 1563 0000 0101 080a 0025 fa26  .....c.......%.&
	0x0030:  0025 fa25 0000 0000 0000 0001 0000 270f  .%.%..........'.
	0x0040:  0000 0000 0000 0000 ffff d8f0 3435 3637  ............4567
	0x0050:  3839 3031 3233 3435 3637 3839 3031 3233  8901234567890123
	0x0060:  3435 3637 3839 3031 3233 3435 3637 3839  4567890123456789
	0x0070:  3031 3233 3435 3637 3839 3031 3233 3435  0123456789012345
	0x0080:  3637 3839 3031 3233 3435 3637 3839 3031  6789012345678901
	0x0090:  3233 3435 3637 3839 3031 3233 3435 3637  2345678901234567
	0x00a0:  3839 3031 3233 3435 3637 3839 3031 3233  8901234567890123
	0x00b0:  3435 3637 3839 3031 3233 3435 3637 3839  4567890123456789
	0x00c0:  3031 3233 3435 3637 3839 3031 3233 3435  0123456789012345
	0x00d0:  3637 3839 3031 3233 3435 3637 3839 3031  6789012345678901
	0x00e0:  3233 3435 3637 3839 3031 3233 3435 3637  2345678901234567
	0x00f0:  3839 3031 3233 3435 3637 3839 3031 3233  8901234567890123
	0x0100:  3435 3637 3839 3031 3233 3435 3637 3839  4567890123456789
	

More info on tcpdump can be found here.

netstat

Purpose: netstat is a useful tool for checking your network configuration and activity.

Continuing on from iperf example. Let's use netstat to confirm that it's listening on port 9999.

๐Ÿณ  โ†’ docker run -it --net container:perf-test-a.1.0qlf1kaka0cq38gojf7wcatoa  nicolaka/netshoot 

/ # netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.11:46727        0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:9999            0.0.0.0:*               LISTEN      -
udp        0      0 127.0.0.11:39552        0.0.0.0:*                           -

nmap

nmap ("Network Mapper") is an open source tool for network exploration and security auditing. It is very useful for scanning to see which ports are open between a given set of hosts. This is a common thing to check for when installing Swarm or UCP because a range of ports is required for cluster communication. The command analyzes the connection pathway between the host where nmap is running and the given target address.

๐Ÿณ  โ†’ docker run -it --privileged nicolaka/netshoot nmap -p 12376-12390 -dd 172.31.24.25

...
Discovered closed port 12388/tcp on 172.31.24.25
Discovered closed port 12379/tcp on 172.31.24.25
Discovered closed port 12389/tcp on 172.31.24.25
Discovered closed port 12376/tcp on 172.31.24.25
...

There are several states that ports will be discovered as:

  • open: the pathway to the port is open and there is an application listening on this port.
  • closed: the pathway to the port is open but there is no application listening on this port.
  • filtered: the pathway to the port is closed, blocked by a firewall, routing rules, or host-based rules.

iftop

Purpose: iftop does for network usage what top does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth usage by pairs of hosts.

Continuing the iperf example.

 โ†’ docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS               NAMES
ce4ff40a5456        nicolaka/netshoot:latest   "iperf -s -p 9999"       5 minutes ago       Up 5 minutes                            perf-test-a.1.bil2mo8inj3r9nyrss1g15qav

๐Ÿณ  โ†’ docker run -it --net container:perf-test-a.1.bil2mo8inj3r9nyrss1g15qav nicolaka/netshoot iftop -i eth0

iftop.png

drill

Purpose: drill is a tool to designed to get all sorts of information out of the DNS.

Continuing the iperf example, we'll use drill to understand how services' DNS is resolved in Docker.

๐Ÿณ  โ†’ docker run -it --net container:perf-test-a.1.bil2mo8inj3r9nyrss1g15qav nicolaka/netshoot drill -V 5 perf-test-b
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 0
;; flags: rd ; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;; perf-test-b.	IN	A

;; ANSWER SECTION:

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 0 msec
;; WHEN: Thu Aug 18 02:08:47 2016
;; MSG SIZE  rcvd: 0
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 52723
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;; perf-test-b.	IN	A

;; ANSWER SECTION:
perf-test-b.	600	IN	A	10.0.3.4 <<<<<<<<<<<<<<<<<<<<<<<<<< Service VIP

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 1 msec
;; SERVER: 127.0.0.11 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Local resolver 
;; WHEN: Thu Aug 18 02:08:47 2016
;; MSG SIZE  rcvd: 56

netcat

Purpose: a simple Unix utility that reads and writes data across network connections, using the TCP or UDP protocol. It's useful for testing and troubleshooting TCP/UDP connections. netcat can be used to detect if there's a firewall rule blocking certain ports.

๐Ÿณ  โ†’  docker network create -d overlay my-ovl
55rohpeerwqx8og4n0byr0ehu

๐Ÿณ  โ†’ docker service create --name service-a --network my-ovl -p 8080:8080 nicolaka/netshoot nc -l 8080
bnj517hh4ylpf7ewawsp9unrc

๐Ÿณ  โ†’ docker service create --name service-b --network my-ovl nicolaka/netshoot nc -vz service-a 8080
3xv1ukbd3kr03j4uybmmlp27j

๐Ÿณ  โ†’ docker logs service-b.1.0c5wy4104aosovtl1z9oixiso
Connection to service-a 8080 port [tcp/http-alt] succeeded!

netgen

Purpose: netgen is a simple script that will generate a packet of data between containers periodically using netcat. The generated traffic can be used to demonstrate different features of the networking stack.

netgen <host> <ip> will create a netcat server and client listening and sending to the same port.

Using netgen with docker run:

๐Ÿณ  โ†’  docker network create -d bridge br
01b167971453700cf0a40d7e1a0dc2b0021e024bbb119541cc8c1858343c9cfc

๐Ÿณ  โ†’  docker run -d --rm --net br --name c1 nicolaka/netshoot netgen c2 5000
8c51eb2100c35d14244dcecb80839c780999159985415a684258c7154ec6bd42

๐Ÿณ  โ†’  docker run -it --rm --net br --name c2 nicolaka/netshoot netgen c1 5000
Listener started on port 5000
Sending traffic to c1 on port 5000 every 10 seconds
Sent 1 messages to c1:5000
Sent 2 messages to c1:5000

๐Ÿณ  โ†’  sudo tcpdump -vvvn -i eth0 port 5000
...

Using netgen with docker services:

๐Ÿณ  โ†’  docker network create -d overlay ov
01b167971453700cf0a40d7e1a0dc2b0021e024bbb119541cc8c1858343c9cfc

๐Ÿณ  โ†’  docker service create --network ov --replicas 3 --name srvc netshoot netgen srvc 5000
y93t8mb9wgzsc27f7l2rdu5io

๐Ÿณ  โ†’  docker service logs srvc
srvc.1.vwklts5ybq5w@moby    | Listener started on port 5000
srvc.1.vwklts5ybq5w@moby    | Sending traffic to srvc on port 5000 every 10 seconds
srvc.1.vwklts5ybq5w@moby    | Sent 1 messages to srvc:5000
srvc.3.dv4er00inlxo@moby    | Listener started on port 5000
srvc.2.vu47gf0sdmje@moby    | Listener started on port 5000
...


๐Ÿณ  โ†’  sudo tcpdump -vvvn -i eth0 port 5000
...

iproute2

purpose: a collection of utilities for controlling TCP / IP networking and traffic control in Linux.

# Sample routing and arp table of the docker host.

๐Ÿณ  โ†’ docker run -it --net host nicolaka/netshoot

/ # ip route show
default via 192.168.65.1 dev eth0  metric 204
172.17.0.0/16 dev docker0  proto kernel  scope link  src 172.17.0.1
172.19.0.0/16 dev br-fd694678f5c3  proto kernel  scope link  src 172.19.0.1 linkdown
172.20.0.0/16 dev docker_gwbridge  proto kernel  scope link  src 172.20.0.1
172.21.0.0/16 dev br-0d73cc4ac114  proto kernel  scope link  src 172.21.0.1 linkdown
172.22.0.0/16 dev br-1eb1f1e84df8  proto kernel  scope link  src 172.22.0.1 linkdown
172.23.0.0/16 dev br-aafed4ec941f  proto kernel  scope link  src 172.23.0.1 linkdown
192.168.65.0/29 dev eth0  proto kernel  scope link  src 192.168.65.2

/ # ip neigh show
192.168.65.1 dev eth0 lladdr f6:16:36:bc:f9:c6 STALE
172.17.0.7 dev docker0 lladdr 02:42:ac:11:00:07 STALE
172.17.0.6 dev docker0 lladdr 02:42:ac:11:00:06 STALE
172.17.0.5 dev docker0 lladdr 02:42:ac:11:00:05 STALE

More info on iproute2 here

nsenter

Purpose: nsenter is a powerful tool allowing you to enter into any namespaces. nsenter is available inside netshoot but requires netshoot to be run as a privileged container. Additionally, you may want to mount the /var/run/docker/netns directory to be able to enter any network namespace including bridge and overlay networks.

With docker run --name container-B --net container:container-A , docker uses container-A's network namespace ( including interfaces and routes) when creating container-B. This approach is helpful for troubleshooting network issues at the container level. To troubleshoot network issues at the bridge or overlay network level, you need to enter the namespace of the network itself. nsenter allows you to do that.

For example, if we wanted to check the L2 forwarding table for a overlay network. We need to enter the overlay network namespace and use same tools in netshoot to check these entries. The following examples go over some use cases for using nsenter to understand what's happening within a docker network ( overlay in this case).

# Creating an overlay network
๐Ÿณ  โ†’ docker network create -d overlay nsenter-test
9tp0f348donsdj75pktssd97b

# Launching a simple busybox service with 3 replicas
๐Ÿณ  โ†’ docker service create --name nsenter-l2-table-test --replicas 3 --network nsenter-test busybox ping localhost
3692i3q3u8nephdco2c10ro4c

# Inspecting the service
๐Ÿณ  โ†’ docker network inspect nsenter-test
[
    {
        "Name": "nsenter-test",
        "Id": "9tp0f348donsdj75pktssd97b",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.0.1.0/24",
                    "Gateway": "10.0.1.1"
                }
            ]
        },
        "Internal": false,
        "Containers": {
            "0ebe0fab555d2e2ef2fcda634bef2071ad3f5842b06bd134b40f259ab9be4f13": {
                "Name": "nsenter-l2-table-test.2.83uezc16jcaz2rp6cjwyf4605",
                "EndpointID": "3064946bb0224a4b3647cefcba18dcbea71b90a2ba1c09212a7bc599ec1ed3eb",
                "MacAddress": "02:42:0a:00:01:04",
                "IPv4Address": "10.0.1.4/24",
                "IPv6Address": ""
            },
            "55065360ac1c71638fdef50a073a661dec53b693409c5e09f8f854abc7dbb373": {
                "Name": "nsenter-l2-table-test.1.4ryh3wmmv21nsrfwmilanypqq",
                "EndpointID": "f81ae5f979d6c54f60636ca9bb2107d95ebf9a08f64786c549e87a66190f1b1f",
                "MacAddress": "02:42:0a:00:01:03",
                "IPv4Address": "10.0.1.3/24",
                "IPv6Address": ""
            },
            "57eca277749bb01a488f0e6c4e91dc6720b7c8f08531536377b29a972971f54b": {
                "Name": "nsenter-l2-table-test.3.9cuoq5m2ue1wi4lsw64k88tvz",
                "EndpointID": "ff1a251ffd6c674cd5fd117386d1a197ab68b4ed708187035d91ff5bd5fe0251",
                "MacAddress": "02:42:0a:00:01:05",
                "IPv4Address": "10.0.1.5/24",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "260"
        },
        "Labels": {}
    }
]

# Launching netshoot in privileged mode
 ๐Ÿณ  โ†’ docker run -it --rm -v /var/run/docker/netns:/var/run/docker/netns --privileged=true nicolaka/netshoot
 
# Listing all docker-created network namespaces
 
/ # cd /var/run/docker/netns/
/var/run/docker/netns # ls
0b1b36d33313  1-9tp0f348do  14d1428c3962  645eb414b538  816b96054426  916dbaa7ea76  db9fd2d68a9b  e79049ce9994  f857b5c01ced
1-9r17dodsxt  1159c401b8d8  1a508036acc8  7ca29d89293c  83b743f2f087  aeed676a57a5  default       f22ffa5115a0

# The overlay network that we created had an id of 9tp0f348donsdj75pktssd97b. All overlay networks are named <number>-<id>. We can see it in the list as `1-9tp0f348do`. To enter it:

/ # nsenter --net=/var/run/docker/netns/1-9tp0f348do sh

# Now all the commands we issue are within that namespace. 

/ # ifconfig
br0       Link encap:Ethernet  HWaddr 02:15:B8:E7:DE:B3
          inet addr:10.0.1.1  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::20ce:a5ff:fe63:437d%32621/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:36 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2224 (2.1 KiB)  TX bytes:1348 (1.3 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%32621/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:336 (336.0 B)  TX bytes:336 (336.0 B)

veth2     Link encap:Ethernet  HWaddr 02:15:B8:E7:DE:B3
          inet6 addr: fe80::15:b8ff:fee7:deb3%32621/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:9 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:690 (690.0 B)  TX bytes:2460 (2.4 KiB)

veth3     Link encap:Ethernet  HWaddr 7E:55:C3:5C:C2:78
          inet6 addr: fe80::7c55:c3ff:fe5c:c278%32621/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:13 errors:0 dropped:0 overruns:0 frame:0
          TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:970 (970.0 B)  TX bytes:1940 (1.8 KiB)

veth4     Link encap:Ethernet  HWaddr 72:95:AB:A1:6A:87
          inet6 addr: fe80::7095:abff:fea1:6a87%32621/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1068 (1.0 KiB)  TX bytes:2038 (1.9 KiB)

vxlan1    Link encap:Ethernet  HWaddr EA:EC:1D:B1:7D:D7
          inet6 addr: fe80::e8ec:1dff:feb1:7dd7%32621/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:33 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# Let's check out the L2 forwarding table. These MAC addresses belong to the tasks/containers in this service. 

/ # bridge  fdb show br br0
33:33:00:00:00:01 dev br0 self permanent
01:00:5e:00:00:01 dev br0 self permanent
33:33:ff:63:43:7d dev br0 self permanent
ea:ec:1d:b1:7d:d7 dev vxlan1 master br0 permanent
02:15:b8:e7:de:b3 dev veth2 master br0 permanent
33:33:00:00:00:01 dev veth2 self permanent
01:00:5e:00:00:01 dev veth2 self permanent
33:33:ff:e7:de:b3 dev veth2 self permanent
7e:55:c3:5c:c2:78 dev veth3 master br0 permanent
33:33:00:00:00:01 dev veth3 self permanent
01:00:5e:00:00:01 dev veth3 self permanent
33:33:ff:5c:c2:78 dev veth3 self permanent
72:95:ab:a1:6a:87 dev veth4 master br0 permanent
33:33:00:00:00:01 dev veth4 self permanent
01:00:5e:00:00:01 dev veth4 self permanent
33:33:ff:a1:6a:87 dev veth4 self permanent


# ARP and routing tables. Note that an overlay network only routes traffic for that network. It only has a single route that matches the subnet of that network.

/ # ip neigh show
/ # ip route
10.0.1.0/24 dev br0  proto kernel  scope link  src 10.0.1.1

# Looks like the arp table is flushed. Let's ping some of the containers on this network.

/ # ping 10.0.1.4
PING 10.0.1.4 (10.0.1.4) 56(84) bytes of data.
64 bytes from 10.0.1.4: icmp_seq=1 ttl=64 time=0.207 ms
64 bytes from 10.0.1.4: icmp_seq=2 ttl=64 time=0.087 ms
^C
--- 10.0.1.4 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.087/0.147/0.207/0.060 ms

/ # ip neigh show
10.0.1.4 dev br0 lladdr 02:42:0a:00:01:04 REACHABLE

# and using bridge-utils to show interfaces of the overlay network local bridge.

/ # brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.0215b8e7deb3	no		vxlan1
							veth2
							veth3
							veth4

CTOP

ctop is a free open source, simple and cross-platform top-like command-line tool for monitoring container metrics in real-time. It allows you to get an overview of metrics concerning CPU, memory, network, I/O for multiple containers and also supports inspection of a specific container.

To get data into ctop, you'll need to bind docker.sock into the netshoot container.

/ # docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nicolaka/netshoot ctop

ctop.png

It will display running and existed containers with useful metrics to help troubleshoot resource issues; hit "q" to exit.

Termshark

Termshark is a terminal user-interface for tshark. It allows user to read pcap files or sniff live interfaces with Wireshark's display filters.

# Launching netshoot with NET_ADMIN and CAP_NET_RAW capabilities. Capturing packets on eth0 with icmp 
/ # docker run --rm --cap-add=NET_ADMIN --cap-add=NET_RAW -it nicolaka/netshoot termshark -i eth0 icmp
# Launching netshoot with NET_ADMIN and CAP_NET_RAW capabilities Reading packets from ipv4frags.pcap

/ # docker run --rm --cap-add=NET_ADMIN --cap-add=NET_RAW -v /tmp/ipv4frags.pcap:/tmp/ipv4frags.pcap -it nicolaka/netshoot termshark -r /tmp/ipv4frags.pcap

More info on termshark here

Swaks

Swaks (Swiss Army Knife for SMTP) is a featureful, flexible, scriptable, transaction-oriented SMTP test tool. It is free to use and licensed under the GNU GPLv2.

You can use it to test and troubleshoot email servers with a crystal-clear syntax:

swaks --to [email protected] \
  --from [email protected] --h-From: '"Fred Example" <[email protected]>' \
  --auth CRAM-MD5 --auth-user [email protected] \
  --header-X-Test "test email" \
  --tls \
  --data "Example body"

More info, examples and lots of documentation on Swaks here

Grpcurl

grpcurl is a command-line tool that lets you interact with gRPC servers. It's basically curl for gRPC servers.

Invoking an RPC on a trusted server (e.g. TLS without self-signed key or custom CA) that requires no client certs and supports server reflection is the simplest thing to do with grpcurl. This minimal invocation sends an empty request body:

grpcurl grpc.server.com:443 my.custom.server.Service/Method

# no TLS
grpcurl -plaintext grpc.server.com:80 my.custom.server.Service/Method

More info, examples and lots of documentation on Grpcurl here

Fortio

Fortio is a fast, small (4Mb docker image, minimal dependencies), reusable, embeddable go library as well as a command line tool and server process, the server includes a simple web UI and REST API to trigger run and see graphical representation of the results (both a single latency graph and a multiple results comparative min, max, avg, qps and percentiles graphs).

$ fortio load http://www.google.com
Fortio X.Y.Z running at 8 queries per second, 8->8 procs, for 5s: http://www.google.com
19:10:33 I httprunner.go:84> Starting http test for http://www.google.com with 4 threads at 8.0 qps
Starting at 8 qps with 4 thread(s) [gomax 8] for 5s : 10 calls each (total 40)
19:10:39 I periodic.go:314> T002 ended after 5.056753279s : 10 calls. qps=1.9775534712220633
19:10:39 I periodic.go:314> T001 ended after 5.058085991s : 10 calls. qps=1.9770324224999916
19:10:39 I periodic.go:314> T000 ended after 5.058796046s : 10 calls. qps=1.9767549252963101
19:10:39 I periodic.go:314> T003 ended after 5.059557593s : 10 calls. qps=1.9764573910247019
Ended after 5.059691387s : 40 calls. qps=7.9056
Sleep times : count 36 avg 0.49175757 +/- 0.007217 min 0.463508712 max 0.502087879 sum 17.7032725
Aggregated Function Time : count 40 avg 0.060587641 +/- 0.006564 min 0.052549016 max 0.089893269 sum 2.42350566
# range, mid point, percentile, count
>= 0.052549 < 0.06 , 0.0562745 , 47.50, 19
>= 0.06 < 0.07 , 0.065 , 92.50, 18
>= 0.07 < 0.08 , 0.075 , 97.50, 2
>= 0.08 <= 0.0898933 , 0.0849466 , 100.00, 1
# target 50% 0.0605556
# target 75% 0.0661111
# target 99% 0.085936
# target 99.9% 0.0894975
Code 200 : 40
Response Header Sizes : count 40 avg 690.475 +/- 15.77 min 592 max 693 sum 27619
Response Body/Total Sizes : count 40 avg 12565.2 +/- 301.9 min 12319 max 13665 sum 502608
All done 40 calls (plus 4 warmup) 60.588 ms avg, 7.9 qps

More info, examples and lots of documentation on Fortio here

Contribution

Feel free to provide to contribute networking troubleshooting tools and use-cases by opening PRs. If you would like to add any package, please follow these steps:

  • In the PR, please include some rationale as to why this tool is useful to be included in netshoot.

    Note: If the functionality of the tool is already addressed by an existing tool, I might not accept the PR

  • Change the Dockerfile to include the new package/tool
  • If you're building the tool from source, make sure you leverage the multi-stage build process and update the build/fetch_binaries.sh script
  • Update the README's list of included packages AND include a section on how to use the tool
  • If the tool you're adding supports multi-platform, please make sure you highlight that.

netshoot's People

Contributors

axeal avatar blacksd avatar cougar avatar dblackhall-tyro avatar dependabot[bot] avatar guettli avatar hanyouqing avatar hasnat avatar john-lin avatar kennethgillen avatar larsbingbong avatar luolanzone avatar mauroseb avatar max-len avatar mcarden avatar nickolaev avatar nicolaka avatar pascalandy avatar programmer04 avatar quadespresso avatar sabbott-cg avatar schnatterer avatar sean-abbott avatar shakerg avatar tak2siva avatar timelf123 avatar twz123 avatar walbertus avatar webner avatar yanickxia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netshoot's Issues

/usr/local/bin/ctop contains a webpage

 netshoot ๎‚ฐ ~ ๎‚ฐ ctop 
/usr/local/bin/ctop: line 8: syntax error: unexpected newline

 netshoot ๎‚ฐ ~ ๎‚ฐ head =ctop






<!DOCTYPE html>
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" >
  <head>
    <meta charset="utf-8">

Looks like the download url is wrong in fetch_binaries.sh

Add semantic versioning on tags

Currently tags are pushed to dockerhub with some digest/hash instead of decent semantic versions.
Please fix this so people could automatic versioning tools like renovate with this container.

Build new Docker Image

Hello,
thank you for your work with netshoot, it is a great help to me.

Today I wanted to iperf a SDN, but sadly 5f2b4a6 (iperf3) is not yet included in the Docker image.

Would you mind rebuilding and reuploading the image to Docker Hub?

Thanks in advance!

Can't open pcap file

I ran this command to generate a tcpdump cap file

docker run -it --rm --net container: nicolaka/netshoot tcpdump -s 0 -i wlp2s0 -w - > tcpdump.pcap

But Wireshark can't open that file, nor any other online analyzer I tried

Add kuberntes deployment with service and ingress templates

This is a small improvement request to add resources to deploy into Kubernetes examples

Adding a deployment, service, and ingress template to quickly test various ingress services.

This should probably have a working netcat or some other script start a listing service.

In my use case, I want to be able to test what arrives at a pod. Through the various ingress services, AWS load balancer, and Nginx ingress controller. What headers actually arrive at the destination pod.

This should be used as a type of example for people who want to quickly deploy something to test this setup.
But need additional resources to get things working. It should be quick to add and quick to remove

deployment

Should run the netshoot image and possible start a listing service on a know / configurable port

service

Service should point to this above deployment service listing port.

ingress

Quick examples for people who want to deploy the various ingress services.

  • ingress Nginx
  • ambassador
  • Traefik
  • Kong
  • HAProxy

I will submit a pull request for this in the near future.

Add termshark for inspecting packets?

termshark is a terminal user-interface for tshark. https://github.com/gcla/termshark

The UI is much like Wireshark easy to inspect large pcap files or sniff live interfaces however tshark has to be added as run-time dependency. This will increase docker image size from 195M to 311M, I was wondering if you could add termshark into netshoot image? or any thoughts

I could help doing this PR

Why is the input in the terminal buggy?

The input in the terminal does not work properly. It shows incorrectly, but if I expand the terminal a little, the error will visually disappear, but the input continues to give this effect. When deleting, the terminal also behaves strangely.
Introduced the "dig mysql"
ะกะฝะธะผะพะบ14
expanded the terminal
ะกะฝะธะผะพะบ66
removed 2 characters from the end
ะกะฝะธะผะพะบ444
removed all characters
ะกะฝะธะผะพ63ะบ

Container does not have the cap_net_raw+p capability or setuid? capabilities.

I have deployed the container on to GKE cluster as a sidecar, here is the yaml file.

apiVersion: apps/v1
kind: Deployment
metadata:
    name: nginx-netshoot
    labels:
        app: nginx-netshoot
spec:
  replicas: 1
  selector:
    matchLabels:
        app: nginx-netshoot
  template:
      metadata:
       labels:
          app: nginx-netshoot
      spec:
            containers:
            - name: nginx
              image: nginxinc/nginx-unprivileged
              ports:
                  - containerPort: 80
              securityContext:
                runAsNonRoot: true
                runAsUser: 100
                seccompProfile:
                  type: RuntimeDefault
                allowPrivilegeEscalation: false
                capabilities:
                  drop:
                  - NET_RAW
            - name: netshoot
              image: nicolaka/netshoot
              command: ["/bin/bash"]
              args: ["-c", "while true; do ping localhost; sleep 60;done"]
              securityContext:
                runAsNonRoot: true
                runAsUser: 100
                seccompProfile:
                  type: RuntimeDefault
                allowPrivilegeEscalation: false
                capabilities:
                  drop:
                  - NET_RAW
                  - NET_ADMIN

when I check the logs of the container,
I get the following,

ping: socktype: SOCK_RAW
ping: socket: Operation not permitted
ping: => missing cap_net_raw+p capability or setuid?
ping: socktype: SOCK_RAW
ping: socket: Operation not permitted
ping: => missing cap_net_raw+p capability or setuid?

Any ideas on how to overcome this, it looks like it needs packages of libcap/libcap_dev and also tcpdump command gives operation not permitted exception.

dns resolve issue with alpinelinux

bash-5.0# ping edge01.hkkc.xxx.com

ping: edge01.hkkc.xxx.com: Name does not resolve
bash-5.0# 
bash-5.0# nslookup edge01.hkkc.xxx.com
Server:         192.168.0.13
Address:        192.168.0.13#53

*** Can't find edge01.hkkc.xxx.com.xxx.com: No answer

bash-5.0# cat /etc/alpine-release 
3.9.4
bash-5.0# cat /etc/resolv.conf 
nameserver 192.168.0.13
search default.svc.k8s-test-cluster.local svc.k8s-test-cluster.local k8s-test-cluster.local corp.xxx.com xxx.com
options ndots:5

relate issue gliderlabs/docker-alpine#476
gliderlabs/docker-alpine#476

Add alpine variant

Sometimes debugging issues in alpine based containers (which uses MUSL) is pretty helpful.

httpie is broken

$ docker run --rm -it nicolaka/netshoot http example.com

Traceback (most recent call last):
  File "/usr/bin/http", line 33, in <module>
    sys.exit(load_entry_point('httpie==2.4.0', 'console_scripts', 'http')())
  File "/usr/lib/python3.8/site-packages/httpie/__main__.py", line 10, in main
    from .core import main
  File "/usr/lib/python3.8/site-packages/httpie/core.py", line 13, in <module>
    from httpie.client import collect_messages
  File "/usr/lib/python3.8/site-packages/httpie/client.py", line 15, in <module>
    from httpie.plugins.registry import plugin_manager
  File "/usr/lib/python3.8/site-packages/httpie/plugins/registry.py", line 1, in <module>
    from httpie.plugins.manager import PluginManager
  File "/usr/lib/python3.8/site-packages/httpie/plugins/manager.py", line 5, in <module>
    from pkg_resources import iter_entry_points
ModuleNotFoundError: No module named 'pkg_resources'

Please add ltrace to netshoot

ltrace is very similar to strace already in netshoot - except it can trace library calls as well as system calls - it's pretty essential because some system calls go through linux-vdso.so - these system calls are hidden from strace and do not show up in its output - but ltrace can track system calls in vdso

I'll put in a PR

feature request: add jq

Would you mind adding jq to the toolset? I use it a bunch for troubleshooting apis, etc.

thanks! (and great thanks for netshoot in general)

httpie is broken in latest netshoot

This is not #69, but similar. With current netshoot:latest, httpie does not work anymore:

mesh-debug-pod# http                                                                          
Traceback (most recent call last):
  File "/usr/bin/http", line 33, in <module>
    sys.exit(load_entry_point('httpie==3.2.1', 'console_scripts', 'http')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/httpie/__main__.py", line 8, in main
    from httpie.core import main
  File "/usr/lib/python3.11/site-packages/httpie/core.py", line 8, in <module>
    import requests
  File "/usr/lib/python3.11/site-packages/requests/__init__.py", line 147, in <module>
    from . import packages, utils
  File "/usr/lib/python3.11/site-packages/requests/utils.py", line 24, in <module>
    from . import certs
  File "/usr/lib/python3.11/site-packages/requests/certs.py", line 14, in <module>
    from certifi import where
ModuleNotFoundError: No module named 'certifi'
mesh-debug-pod# 

termshark does not yet support arm

"termshark does not yet support arm". I can however run termShark in mac m1 (via brew install).

% docker run -it --net container:opensearch-dashboards nicolaka/netshoot
Unable to find image 'nicolaka/netshoot:latest' locally
latest: Pulling from nicolaka/netshoot
Digest: sha256:1116ede25c69cd4e3effa2dfbdc35e6638c8faceabd4fbbd334dfbb108c07095
Status: Downloaded newer image for nicolaka/netshoot:latest
                    dP            dP                           dP
                    88            88                           88
88d888b. .d8888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P
88'  `88 88ooood8   88   Y8ooooo. 88'  `88 88'  `88 88'  `88   88
88    88 88.  ...   88         88 88    88 88.  .88 88.  .88   88
dP    dP `88888P'   dP   `88888P' dP    dP `88888P' `88888P'   dP

Welcome to Netshoot! (github.com/nicolaka/netshoot)



 9a6e3e7ea06b ๎‚ฐ ~ ๎‚ฐ termshark
termshark does not yet support arm

Netshoot Enterprise

It would be nice to have an enterprise version of this that supports RBAC, SAML, and has a GUI

telnet?

nice diagram, where would telnet fit?

Dockerfile: alphabetize list of packages

it's good form to sort packages installed alphabetically to make it easier to read the list, especially when the list is as long as the one here. please make it so with the next change (addition or removal) on the list.

Crticial vulnerabilities on netshoot image

I scanned netshoot image with Gyrpe and it found some critical vulns. Are there any plan to mitigate these? It would be nice to have a scheduled action that scans the image for vulns.

NAME                                  INSTALLED                                                  FIXED-IN   TYPE       VULNERABILITY        SEVERITY
apache2-utils                         2.4.53-r0                                                  2.4.54-r0  apk        CVE-2022-28615       Critical
apache2-utils                         2.4.53-r0                                                  2.4.54-r0  apk        CVE-2022-30556       High
apache2-utils                         2.4.53-r0                                                  2.4.54-r0  apk        CVE-2022-31813       Critical
apache2-utils                         2.4.53-r0                                                  2.4.54-r0  apk        CVE-2022-26377       High
apache2-utils                         2.4.53-r0                                                  2.4.54-r0  apk        CVE-2022-28330       Medium
apache2-utils                         2.4.53-r0                                                  2.4.54-r0  apk        CVE-2022-30522       High
apache2-utils                         2.4.53-r0                                                  2.4.54-r0  apk        CVE-2022-28614       Medium
apache2-utils                         2.4.53-r0                                                  2.4.54-r0  apk        CVE-2022-29404       High
flock                                 2.38-r1                                                               apk        CVE-2010-3262        Medium
github.com/containerd/containerd      v1.4.1                                                     1.4.12     go-module  GHSA-5j5w-g665-5m35  Low
github.com/containerd/containerd      v1.4.1                                                     1.4.11     go-module  GHSA-c2h3-6mxw-7mvq  Medium
github.com/containerd/containerd      v1.4.1                                                     1.4.8      go-module  GHSA-c72p-9xmj-rx3w  Medium
github.com/containerd/containerd      v1.4.1                                                     1.4.13     go-module  GHSA-crp2-qrr5-8pq7  High
github.com/containerd/containerd      v1.4.1                                                     1.5.13     go-module  GHSA-5ffw-gxpp-mxpf  Medium
github.com/containerd/containerd      v1.4.1                                                     1.4.3      go-module  GHSA-36xw-fx78-c5r4  Medium
github.com/docker/docker              v20.10.0-beta1.0.20201113105859-b6bfff2a628f+incompatible             go-module  CVE-2021-21285       Medium
github.com/docker/docker              v20.10.0-beta1.0.20201113105859-b6bfff2a628f+incompatible             go-module  CVE-2021-21284       Medium
github.com/gogo/protobuf              v1.3.1                                                     1.3.2      go-module  GHSA-c3h9-896r-86jm  High
github.com/influxdata/influxdb        v0.0.0-20190102202943-dd481f35df2c                                    go-module  CVE-2018-17572       Medium
github.com/influxdata/influxdb        v0.0.0-20190102202943-dd481f35df2c                                    go-module  CVE-2019-20933       Critical
github.com/opencontainers/image-spec  v1.0.1                                                     1.0.2      go-module  GHSA-77vh-xpmg-72qh  Low
github.com/opencontainers/runc        v1.0.3                                                     1.1.2      go-module  GHSA-f3fp-gc8g-vw66  Medium
github.com/projectcalico/calico       (devel)                                                               go-module  CVE-2020-13597       Low
go.etcd.io/etcd                       v0.5.0-alpha.5.0.20201125193152-8a03d2e9614b               3.4.0      go-module  GHSA-wf43-55jj-vwq8  Medium
google.golang.org/protobuf            v1.26.0                                                               go-module  CVE-2021-22570       High
google.golang.org/protobuf            v1.26.0                                                               go-module  CVE-2015-5237        High
httpie                                3.2.1                                                                 python     CVE-2019-10751       High
pcre2                                 10.39-r0                                                   10.40-r0   apk        CVE-2022-1587        Critical
pcre2                                 10.39-r0                                                   10.40-r0   apk        CVE-2022-1586        Critical
scapy                                 git-archive.dev8b63d73a172                                 2.4.1      python     GHSA-mpf2-q34c-fc6j  High
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1735        High
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1785        High
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1851        High
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1769        High
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1771        Medium
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1927        Critical
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1796        High
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1898        High
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1886        High
vim                                   8.2.4969-r0                                                           apk        CVE-2022-1942        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1769        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1942        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1851        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1785        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1796        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1927        Critical
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1886        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1735        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1898        High
xxd                                   8.2.4969-r0                                                           apk        CVE-2022-1771        Medium

Unable to use the Kubernetes deployment file

Hi, I'm running a kubernetes cluster on my local machine using virtual machines (virtualbox). The cluster is working fine and I have created some deployments on the nodes. I've also applied the calico network add-on.

Now I'm trying to deploy netshoot on my cluster. I'm using the following deployment file:
kubectl apply -f https://github.com/nicolaka/netshoot/blob/master/configs/netshoot-calico.yaml

However, I get the error on replica set that service account 'cni-plugin' not found, so I changed the service account to 'calico-node' in the deployment file and tried again. This time the replica was created successfully, however I'm getting an error on the pod that was created by the deployment. The following is the log for the netshoot pod

Events:
  Type     Reason       Age               From               Message
  ----     ------       ----              ----               -------
  Normal   Scheduled    40s               default-scheduler  Successfully assigned kube-system/netshoot-calico-deploy-778d8f88b4-cvgj6 to k8s-head
  Warning  FailedMount  8s (x7 over 40s)  kubelet, k8s-head  MountVolume.SetUp failed for volume "etcd-certs" : secret "calico-etcd-secrets" not found

How can I solve this problem? If I'm using the wrong service account, then which service account should I be using?

Any help will be greatly appreciated. Thanks!

no matching manifest for linux/arm/v7 in the manifest list entries

Hi Nikolaka,

I'm trying to install netshoot on my RPI with this command:
_sudo docker run -it --net host nicolaka/netshoot_

after a few seconds this is what I get in return:
_docker: no matching manifest for linux/arm/v7 in the manifest list entries._

Not sure what I'm doing wrong.

nslookup throws "nslookup: can't resolve '(null)': Name does not resolve"

Running from a freshly spawned container:

/ # nslookup www.google.com
nslookup: can't resolve '(null)': Name does not resolve

Name:      www.google.com
Address 1: 172.217.9.4 dfw28s02-in-f4.1e100.net
Address 2: 2607:f8b0:4000:811::2004 dfw28s01-in-x04.1e100.net
/ #

I did some digging online, and found a couple references to this:

  1. [RESOLVED] Service name resolution broken on alpine and docker 1.11.1-cs1
  2. virtualbox-host-dns-resolver with alpine linux

For the second reference listed above, scroll to the bottom. It appears that the issue might be with how Alpine Linux (at least when run as a container) may be mishandling AAAA records.

It's not yet apparent how best to deal with the can't resolve '(null)': Name does not resolve issue, short of putting a wrapper script around it to filter out the noise.

License

I was wondering if we are allowed to use/modify code from this repository? because there's no license attached. Thanks!

error in multiple command

on a k3s cluster( containerd runtime), I use
kubectl debug mypod -n myns -it --image=nicolaka/netshoot --share-processes --copy-to=mypod-debug
then I tried to run different commands but some of them has errors:
1- termshark error

bash-5.1# termshark
Termshark is initializing - please wait...
(The termshark UI will start when packets are detected on DisplayPort AUX channel monitor capture...)
Cannot capture on device DisplayPort AUX channel monitor capture: exit status 1 (exit code 1)
See https://termshark.io/no-root for more info.
bash-5.1#

2- ctop

ctop - error โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โ”‚
โ”‚ [04:55:39 UTC] Get "http://unix.sock/info": dial unix /var/run/docker.sock: connect: no such file or directory โ”‚
โ”‚ โ”‚
โ”‚ [04:55:39 UTC] attempting to reconnect...

Couldn't run /usr/bin/dumpcap in child process: Operation not permitted

On Ubuntu 20.04.3 LTS (Focal Fossa) / k8s client v1.21.5 server 1.20.8 / docker://20.10.11
with invocation docker run -it nicolaka/netshoot
and
Ubuntu 20.10 (Groovy Gorilla) / Docker version 20.10.7, build f0df350
with invocation kubectl run tmp-shell --rm -i --tty --overrides='{"spec": {"hostNetwork": true}}' --image nicolaka/netshoot -- /bin/bash

 6d6e1772e365 ๎‚ฐ ~ ๎‚ฐ tshark -i eth0
Capturing on 'eth0'
tshark: Couldn't run /usr/bin/dumpcap in child process: Operation not permitted

0 packets captured
  • addgroup root wireshark and chmod a+x /usr/bin/dumpcap doesn't help
  • solved with chown root:root /usr/bin/dumpcap
  • tried both inside container and build time change

IMO wireshark group permissions are not relevant for temporary container based troubleshooting i.e. the fix is suitable for release. Let me know if you want a PR.

Netgen service not available anymore

Hello, just a quick issue :

In documentation you're referring to a script "netgen" that allows to generate traffic, this script doesn't exist anymore (I couldn't find it in any tags).

Either remove reference from documentation or re-provide the script. In my case the script would have been useful because I'm looking to generate high volume traffic to troubleshoot some socket connection close with a load-balancer.

netcat does not work on Centos 7.2

[vagrant@node01 ~]$  cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)
[vagrant@node01 ~]$  
[vagrant@node01 ~]$ docker run -it --rm --net host nicolaka/netshoot netstat -tln |grep :22 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      
tcp        0      0 :::22                   :::*                    LISTEN      
[vagrant@node01 ~]$ 
[vagrant@node01 ~]$ docker run -it --rm --net host nicolaka/netshoot nc localhost 22; echo $?
Error relocating /usr/lib/libglib-2.0.so.0: pthread_setname_np: symbol not found
127
[vagrant@node01 ~]$ 
[vagrant@node01 ~]$ docker images |grep netshoot
nicolaka/netshoot         latest              eeddb90fd6b9        3 weeks ago         42.4 MB
[vagrant@node01 ~]$ 

ARM64 images

Please consider releasing an ARM64 docker image

openssl package

I often use the openssl s_client -connect <url>:<port> command to debug SSL connections.

Would it be possible to include the openssl package by default?

permission denied on OpenShift 4.x

OpenShift fails to create to container with following error message:

Error: container create failed: time="2021-04-12T15:03:47Z" level=error msg="container_linux.go:366: starting container process caused: chdir to cwd ("/root") set in config.json failed: permission denied"

feature request: include https://httpie.org/

hi there

thanks for maintaining this useful product!

i'd love to see https://httpie.org/ being included in netshoot.

compared to curl/wget it is much easier/intuitive to invoke http requests (esp. when dealing with json)

please let me know what you do think about including it.

thanks in advance!

new initial prompt issues

Related to #59 (but its closed)

... a few days ago (maybe a week), the container image changed and "delete" stopped working (backspace). That seems to be solved, (perhaps above)... but I still notice two things.

When starting via kubectl...

kubectl run netshoots-${USER}-debug --rm -it --image nicolaka/netshoot
  • It seems to clear screen (not desirable) at startup ... at a minimum it blows away the netshoot logo, it also potentially destroys output I wanted to copy/paste.
  • The prompt is missing its emoji docker whale (and something else?)
 netshoots-tmcneely-debug ๎‚ฐ ~ ๎‚ฐ

Screen Shot 2021-03-30 at 4 40 38 PM

rebuilt the docker image from an old (56-fix) branch, and it looks "correct"

older one:
Screen Shot 2021-03-30 at 5 10 23 PM

I like the hostname, rather than the root@ part, but I want my whale back :)

Netshoot kubectl plugin

Hi, I am a big fan of netshoot and so I've developed a kubectl plugin which can spin up netshoot quickly without having to memorize the correct syntax for kubectl run or kubectl debug:

https://github.com/nilic/kubectl-netshoot

Main goal was to cover all the example use cases from Netshoot with Kubernetes. I have also added a few additional example use cases to the readme (debugging nodes, running command instead of attaching to an interactive shell).

Through flags, plugin allows for selecting which netshoot container image to use, as well as whether to run the container in the host network's namespace.

If this sounds useful, please consider adding a link to my project to netshoot readme. I am also open to any suggestions or ideas how to further improve the plugin. Thanks ๐Ÿ™‚

nslookup needs an update

[centos@ucp-manager-0 ~]$ docker container run -it nicolaka/netshoot bash
bash-4.4# nslookup www.google.com
Error relocating /usr/lib/libisc.so.1200: explicit_bzero: symbol not found

bash-4.4# apk update && apk upgrade
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
v3.8.1-115-ge3ed6b4e31 [http://dl-cdn.alpinelinux.org/alpine/v3.8/main]
v3.8.1-112-g45bdd0edfb [http://dl-cdn.alpinelinux.org/alpine/v3.8/community]
v3.8.0-3619-g179325d5d6 [http://nl.alpinelinux.org/alpine/edge/main]
v3.8.0-3617-ge537e93b64 [http://nl.alpinelinux.org/alpine/edge/testing]
OK: 18601 distinct packages available
Upgrading critical system libraries and apk-tools:
(1/5) Purging ssl_client (1.28.4-r1)
(2/5) Upgrading apk-tools (2.10.1-r0 -> 2.10.3-r0)
(3/5) Purging libressl2.7-libtls (2.7.4-r0)
(4/5) Purging libressl2.7-libssl (2.7.4-r0)
(5/5) Purging libressl2.7-libcrypto (2.7.4-r0)
Executing busybox-1.28.4-r1.trigger
Executing ca-certificates-20180924-r1.trigger
Continuing the upgrade transaction with new apk-tools:
(1/15) Upgrading musl (1.1.19-r10 -> 1.1.20-r2)
(2/15) Upgrading busybox (1.28.4-r1 -> 1.29.3-r3)
Executing busybox-1.29.3-r3.post-upgrade
(3/15) Upgrading alpine-baselayout (3.1.0-r0 -> 3.1.0-r2)
Executing alpine-baselayout-3.1.0-r2.pre-upgrade
Executing alpine-baselayout-3.1.0-r2.post-upgrade
(4/15) Installing libtls-standalone (2.7.4-r5)
(5/15) Installing ssl_client (1.29.3-r3)
(6/15) Installing libressl2.7-libcrypto (2.7.4-r2)
(7/15) Upgrading bind-libs (9.12.2_p1-r1 -> 9.12.3-r0)
(8/15) Upgrading bind-tools (9.12.2_p1-r1 -> 9.12.3-r0)
(9/15) Upgrading musl-utils (1.1.19-r10 -> 1.1.20-r2)
(10/15) Upgrading libc6-compat (1.1.19-r10 -> 1.1.20-r2)
(11/15) Purging krb5-libs (1.15.3-r1)
(12/15) Purging krb5-conf (1.0-r1)
(13/15) Purging libcom_err (1.44.4-r0)
(14/15) Purging keyutils-libs (1.5.10-r0)
(15/15) Purging libverto (0.3.0-r1)
Executing busybox-1.29.3-r3.trigger
Executing ca-certificates-20180924-r1.trigger
OK: 154 MiB in 103 packages

bash-4.4# nslookup www.google.com
Server:		10.10.0.2
Address:	10.10.0.2#53

Non-authoritative answer:
Name:	www.google.com
Address: 172.217.22.100
Name:	www.google.com
Address: 2a00:1450:4001:80b::2004

tcpdump not available when running from k8s (Openshift) container

oc run network-debug-tmp-pod --rm -i -t --image nicolaka/netshoot -- tcpdump -i eth0 -s 0 -Xvv tcp port 80

Returns:
tcpdump: eth0: You don't have permission to capture on that device
(socket: Operation not permitted)

But sudo is not available in the netshoot image. Any suggestions?

Include docker-compose example in the documentation

Hey,

it took me a while to figure out how to achieve this so I figured others might benefit from my work. Here's an example of a docker-compose.yml capturing all network traffic of an nginx container:

version: "3.6"
services:
  tcpdump:
    image: nicolaka/netshoot
    depends_on:
      - nginx
    command: tcpdump -i eth0 -w /data/nginx.pcap
    network_mode: service:nginx
    volumes:
      - $PWD/data:/data

  nginx:
    image: nginx:alpine
    ports:
      - 80:80

Would you like to include this in the documentation?

root required for "latest"

It works in v0.7 but now it fails with the latest version:

bash-5.1$ ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
ping: permission denied (are you root?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.