[
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: docker\n    directory: /\n    schedule:\n      interval: daily\n\n  - package-ecosystem: github-actions\n    directory: /\n    schedule:\n      interval: daily\n"
  },
  {
    "path": ".github/workflows/release-buildx.yml",
    "content": "name: release-buildx\n\non:\n  push:\n    tags:\n      - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10\n\njobs:\n  buildx:\n    runs-on: ubuntu-latest\n    steps:\n      -\n        name: Checkout\n        uses: actions/checkout@v6\n        with:\n          ref: ${{ github.ref }}\n      -\n        name: Set up QEMU\n        uses: docker/setup-qemu-action@v3\n        with:\n          platforms: arm64,amd64\n      -\n        name: Set up Docker Buildx\n        id: buildx\n        uses: docker/setup-buildx-action@v3\n      -\n        name: Available platforms\n        run: echo ${{ steps.buildx.outputs.platforms }}\n      - name: Set Release Tag Env\n        run: echo \"RELEASE_VERSION=${GITHUB_REF#refs/*/}\" >> $GITHUB_ENV\n      - \n        name: docker hub login\n        env:\n          DOCKER_USER: ${{secrets.DOCKER_USER}}\n          DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}\n        run: |\n            docker login -u $DOCKER_USER -p $DOCKER_PASSWORD \n      - \n        name: docker ghcr login\n        env:\n          GHCR_USER: ${{secrets.GHCR_USER}}\n          GHCR_TOKEN: ${{secrets.GHCR_TOKEN}}\n        run: |\n            docker login ghcr.io -u $GHCR_USER -p $GHCR_TOKEN\n      -\n        name: Run Buildx\n        run: |\n          docker buildx build \\\n            --platform linux/amd64,linux/arm64 \\\n            --output \"type=image,push=true\" \\\n            --file ./Dockerfile \\\n            --tag $GITHUB_REPOSITORY:$GITHUB_SHA \\\n            --tag $GITHUB_REPOSITORY:$RELEASE_VERSION \\\n            --tag $GITHUB_REPOSITORY:latest \\\n            --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA \\\n            --tag ghcr.io/$GITHUB_REPOSITORY:$RELEASE_VERSION \\\n            --tag ghcr.io/$GITHUB_REPOSITORY:latest . \n\n\n            \n"
  },
  {
    "path": ".github/workflows/test-pr-buildx.yml",
    "content": "name: test-pr-buildx\n\non:\n  pull_request:\n    branches: master\n    \njobs:\n  buildx:\n    runs-on: ubuntu-latest\n    steps:\n      -\n        name: Checkout\n        uses: actions/checkout@v6\n      -\n        name: Set up QEMU\n        uses: docker/setup-qemu-action@v3\n        with:\n          platforms: arm64,amd64\n      -\n        name: Set up Docker Buildx\n        id: buildx\n        uses: docker/setup-buildx-action@v3\n      -\n        name: Available platforms\n        run: echo ${{ steps.buildx.outputs.platforms }}\n      -\n        name: Run Buildx\n        run: |\n          docker buildx build \\\n            --platform linux/amd64,linux/arm64 \\\n            --output \"type=image,push=false\" \\\n            --file ./Dockerfile .\n\n\n            \n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM debian:stable-slim as fetcher\nCOPY build/fetch_binaries.sh /tmp/fetch_binaries.sh\n\nRUN apt-get update && apt-get install -y \\\n  curl \\\n  wget\n\nRUN /tmp/fetch_binaries.sh\n\nFROM alpine:3.23.2\n\nRUN set -ex \\\n    && echo \"http://dl-cdn.alpinelinux.org/alpine/edge/main\" >> /etc/apk/repositories \\\n    && echo \"http://dl-cdn.alpinelinux.org/alpine/edge/testing\" >> /etc/apk/repositories \\\n    && echo \"http://dl-cdn.alpinelinux.org/alpine/edge/community\" >> /etc/apk/repositories \\\n    && apk update \\\n    && apk upgrade \\\n    && apk add --no-cache \\\n    apache2-utils \\\n    bash \\\n    bind-tools \\\n    bird \\\n    bridge-utils \\\n    busybox-extras \\\n    conntrack-tools \\\n    curl \\\n    dhcping \\\n    drill \\\n    ethtool \\\n    file\\\n    fping \\\n    iftop \\\n    iperf \\\n    iperf3 \\\n    iproute2 \\\n    ipset \\\n    iptables \\\n    iptraf-ng \\\n    iputils \\\n    ipvsadm \\\n    httpie \\\n    jq \\\n    libc6-compat \\\n    liboping \\\n    ltrace \\\n    mtr \\\n    net-snmp-tools \\\n    netcat-openbsd \\\n    nftables \\\n    ngrep \\\n    nmap \\\n    nmap-nping \\\n    nmap-scripts \\\n    openssl \\\n    py3-pip \\\n    py3-setuptools \\\n    scapy \\\n    socat \\\n    speedtest-cli \\\n    openssh \\\n    oh-my-zsh \\\n    strace \\\n    tcpdump \\\n    tcptraceroute \\\n    trippy \\\n    tshark \\\n    util-linux \\\n    vim \\\n    git \\\n    zsh \\\n    websocat \\\n    swaks \\\n    perl-crypt-ssleay \\\n    perl-net-ssleay\n\n# Installing ctop - top-like container monitor\nCOPY --from=fetcher /tmp/ctop /usr/local/bin/ctop\n\n# Installing calicoctl\nCOPY --from=fetcher /tmp/calicoctl /usr/local/bin/calicoctl\n\n# Installing termshark\nCOPY --from=fetcher /tmp/termshark /usr/local/bin/termshark\n\n# Installing grpcurl\nCOPY --from=fetcher /tmp/grpcurl /usr/local/bin/grpcurl\n\n# Installing fortio\nCOPY --from=fetcher /tmp/fortio /usr/local/bin/fortio\n\n# Setting User and Home\nUSER root\nWORKDIR /root\nENV HOSTNAME netshoot\n\n# ZSH Themes\nRUN curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh\nRUN git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions\nRUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k\nCOPY zshrc .zshrc\nCOPY motd motd\n\n# Fix permissions for OpenShift and tshark\nRUN chmod -R g=u /root\nRUN chown root:root /usr/bin/dumpcap\n\n# Running ZSH\nCMD [\"zsh\"]\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright 2017 Google Inc.\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "Makefile",
    "content": ".PHONY: build-x86 build-arm64 push all\n\n# Build Vars\nIMAGENAME=nicolaka/netshoot\nVERSION=0.1\n\n\n.DEFAULT_GOAL := all\n\nbuild-x86:\n\t    @docker build --platform linux/amd64 -t ${IMAGENAME}:${VERSION} .\nbuild-arm64:\n\t\t@docker build --platform linux/arm64 -t ${IMAGENAME}:${VERSION} .\nbuild-all:\n\t\t@docker buildx build --platform linux/amd64,linux/arm64 --output \"type=image,push=false\" --file ./Dockerfile .\npush:\n\t \t@docker push ${IMAGENAME}:${VERSION} \nall: build-all push\n\n\n\t\t\n"
  },
  {
    "path": "README.md",
    "content": "## netshoot: a Docker + Kubernetes network trouble-shooting swiss-army container\n\n```\n                    dP            dP                           dP\n                    88            88                           88\n88d888b. .d8888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P\n88'  `88 88ooood8   88   Y8ooooo. 88'  `88 88'  `88 88'  `88   88\n88    88 88.  ...   88         88 88    88 88.  .88 88.  .88   88\ndP    dP `88888P'   dP   `88888P' dP    dP `88888P' `88888P'   dP\n```\n\n**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.\n\n**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. \n\nKubernetes 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.\n\nCool 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. \n\n## Netshoot with Docker \n\n* **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:\n\n    `$ docker run -it --net container:<container_name> nicolaka/netshoot`\n\n* **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:\n\n    `$ docker run -it --net host nicolaka/netshoot`\n\n* **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.\n\n## Netshoot with Docker Compose\n\nYou can easily deploy `netshoot` using Docker Compose using something like this:\n\n```\nversion: \"3.6\"\nservices:\n  tcpdump:\n    image: nicolaka/netshoot\n    depends_on:\n      - nginx\n    command: tcpdump -i eth0 -w /data/nginx.pcap\n    network_mode: service:nginx\n    volumes:\n      - $PWD/data:/data\n\n  nginx:\n    image: nginx:alpine\n    ports:\n      - 80:80\n```\n\n## Netshoot with Kubernetes\n\n* if you want to debug using an [ephemeral container](https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container-example) in an existing pod:\n\n    `$ kubectl debug mypod -it --image=nicolaka/netshoot`\n\n* if you want to spin up a throw away pod for debugging.\n\n    `$ kubectl run tmp-shell --rm -i --tty --image nicolaka/netshoot`\n\n* if you want to spin up a container on the host's network namespace.\n\n    `$ kubectl run tmp-shell --rm -i --tty --overrides='{\"spec\": {\"hostNetwork\": true}}'  --image nicolaka/netshoot`\n\n* if you want to use netshoot as a sidecar container to troubleshoot your application container\n ```yaml\n# netshoot-sidecar.yaml\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: nginx-netshoot\n  labels:\n    app: nginx-netshoot\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: nginx-netshoot\n  template:\n    metadata:\n      labels:\n        app: nginx-netshoot\n    spec:\n      containers:\n        - name: nginx\n          image: nginx:1.14.2\n          ports:\n            - containerPort: 80\n        - name: netshoot\n          image: nicolaka/netshoot\n          command: [\"/bin/bash\"]\n          args: [\"-c\", \"while true; do ping localhost; sleep 60;done\"]\n ```\n\n ```bash\n$ kubectl apply -f netshoot-sidecar.yaml\ndeployment.apps/nginx-netshoot created\n\n$ kubectl get pod\nNAME                              READY   STATUS    RESTARTS   AGE\nnginx-netshoot-7f9c6957f8-kr8q6   2/2     Running   0          4m27s\n\n$ kubectl exec -it nginx-netshoot-7f9c6957f8-kr8q6 -c netshoot -- /bin/zsh\n                    dP            dP                           dP\n                    88            88                           88\n88d888b. .d8888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P\n88'  `88 88ooood8   88   Y8ooooo. 88'  `88 88'  `88 88'  `88   88\n88    88 88.  ...   88         88 88    88 88.  .88 88.  .88   88\ndP    dP `88888P'   dP   `88888P' dP    dP `88888P' `88888P'   dP\n\nWelcome to Netshoot! (github.com/nicolaka/netshoot)\n\nnginx-netshoot-7f9c6957f8-kr8q6 $ \n ```\n\n## The netshoot kubectl plugin\n\nTo easily troubleshoot networking issues in your k8s environment, you can leverage the [Netshoot Kubectl Plugin](https://github.com/nilic/kubectl-netshoot) (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](https://github.com/nilic/kubectl-netshoot#installation).\n\nSample Usage:\n\n```\n# spin up a throwaway pod for troubleshooting\nkubectl netshoot run tmp-shell\n\n# debug using an ephemeral container in an existing pod\nkubectl netshoot debug my-existing-pod\n\n# create a debug session on a node\nkubectl netshoot debug node/my-node\n```\n\n\n\n**Network Problems** \n\nMany 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:\n\n* latency\n* routing \n* DNS resolution\n* firewall \n* incomplete ARPs\n\nTo troubleshoot these issues, `netshoot` includes a set of powerful tools as recommended by this diagram. \n\n![](http://www.brendangregg.com/Perf/linux_observability_tools.png)\n\n\n**Included Packages:** The following packages and binaries are included in `netshoot`:\n\n    apache2-utils \\\n    bash \\\n    bind-tools \\\n    bird \\\n    bridge-utils \\\n    busybox-extras \\\n    conntrack-tools \\\n    curl \\\n    dhcping \\\n    drill \\\n    ethtool \\\n    file \\\n    fping \\\n    iftop \\\n    iperf \\\n    iperf3 \\\n    iproute2 \\\n    ipset \\\n    iptables \\\n    iptraf-ng \\\n    iputils \\\n    ipvsadm \\\n    httpie \\\n    jq \\\n    libc6-compat \\\n    liboping \\\n    ltrace \\\n    mtr \\\n    net-snmp-tools \\\n    netcat-openbsd \\\n    nftables \\\n    ngrep \\\n    nmap \\\n    nmap-nping \\\n    nmap-scripts \\\n    openssl \\\n    py3-pip \\\n    py3-setuptools \\\n    scapy \\\n    socat \\\n    speedtest-cli \\\n    openssh \\\n    oh-my-zsh \\\n    strace \\\n    tcpdump \\\n    tcptraceroute \\\n    trippy \\\n    tshark \\\n    util-linux \\\n    vim \\\n    git \\\n    zsh \\\n    websocat \\\n    swaks \\\n    perl-crypt-ssleay \\\n    perl-net-ssleay\n\nAdditionally, the following binaries are included:\n\n    ctop\n    calicoctl\n    termshark\n    grpcurl\n    fortio\n\n## **Sample Use-cases**\n\n### iperf\n\nPurpose: test networking performance between two containers/hosts.\n\nExample:\n\n```\n$ docker network create -d bridge perf-test\n$ docker run -d --rm --net perf-test --name perf-test-a nicolaka/netshoot iperf -s -p 9999\n$ docker run -it --rm --net perf-test --name perf-test-b nicolaka/netshoot iperf -c perf-test-a -p 9999\n```\n\n### tcpdump\n\n**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.\n\n```\n$ docker run -it --net container:perf-test-a nicolaka/netshoot\n/ # tcpdump -i eth0 port 9999 -c 1 -Xvv\n```\n\n### netstat\n\nPurpose: `netstat` is a useful tool for checking your network configuration and activity.\n\n```\n$ docker run -it --net container:perf-test-a nicolaka/netshoot\n/ # netstat -tulpn\n```\n\n### nmap\n\n`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.\n\n```\n$ docker run -it --privileged nicolaka/netshoot nmap -p 12376-12390 -dd 172.31.24.25\n```\n\n### iftop\n\nPurpose: 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.\n\n```\n$ docker run -it --net container:perf-test-a nicolaka/netshoot iftop -i eth0\n```\n\n### drill\n\nPurpose: drill is a tool to designed to get all sorts of information out of the DNS.\n\n```\n$ docker run -it --net container:perf-test-a nicolaka/netshoot drill -V 5 perf-test-b\n```\n\n### netcat\n\nPurpose: 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.\n\n```\n$ docker network create -d bridge my-br\n$ docker run -d --rm --net my-br --name service-a nicolaka/netshoot nc -l 8080\n$ docker run -it --rm --net my-br --name service-b nicolaka/netshoot nc -vz service-a 8080\n```\n\n### iproute2\n\nPurpose: a collection of utilities for controlling TCP / IP networking and traffic control in Linux.\n\n```\n$ docker run -it --net host nicolaka/netshoot\n/ # ip route show\n/ # ip neigh show\n```\n\n### nsenter\n\nPurpose: `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 networks.\n\n```\n$ docker run -it --rm -v /var/run/docker/netns:/var/run/docker/netns --privileged=true nicolaka/netshoot\n/ # cd /var/run/docker/netns/\n/var/run/docker/netns # ls\n/ # nsenter --net=/var/run/docker/netns/<namespace> sh\n```\n\n### CTOP\n\nctop 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.\n\n```\n$ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nicolaka/netshoot ctop\n```\n\n### Termshark\n\nTermshark is a terminal user-interface for tshark. It allows user to read pcap files or sniff live interfaces with Wireshark's display filters.\n\n```\n$ docker run --rm --cap-add=NET_ADMIN --cap-add=NET_RAW -it nicolaka/netshoot termshark -i eth0 icmp\n$ 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\n```\n\n### Swaks\n\nSwaks (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.\n\n```\nswaks --to user@example.com \\\n  --from fred@example.com --h-From: '\"Fred Example\" <fred@example.com>' \\\n  --auth CRAM-MD5 --auth-user me@example.com \\\n  --header-X-Test \"test email\" \\\n  --tls \\\n  --data \"Example body\"\n```\n\n### Grpcurl\n\ngrpcurl is a command-line tool that lets you interact with gRPC servers. It's basically curl for gRPC servers.\n\n```\ngrpcurl grpc.server.com:443 my.custom.server.Service/Method\n# no TLS\ngrpcurl -plaintext grpc.server.com:80 my.custom.server.Service/Method\n```\n\n### Fortio\n\nFortio is a fast, small, 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.\n\n```\n$ fortio load http://www.google.com\n```\n\n## Contribution\n\nFeel free to contribute networking troubleshooting tools and use-cases by opening PRs. If you would like to add any package, please follow these steps:\n\n* In the PR, please include some rationale as to why this tool is useful to be included in netshoot. \n     > Note: If the functionality of the tool is already addressed by an existing tool, I might not accept the PR\n* Change the Dockerfile to include the new package/tool\n* 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 \n* Update the README's list of included packages AND include a section on how to use the tool\n* If the tool you're adding supports multi-platform, please make sure you highlight that.\n\n\n"
  },
  {
    "path": "build/fetch_binaries.sh",
    "content": "#!/usr/bin/env bash\nset -euo pipefail\n\nget_latest_release() {\n  curl --silent \"https://api.github.com/repos/$1/releases/latest\" | # Get latest release from GitHub api\n    grep '\"tag_name\":' |                                            # Get tag line\n    sed -E 's/.*\"([^\"]+)\".*/\\1/'                                    # Pluck JSON value\n}\n\n\nARCH=$(uname -m)\ncase $ARCH in\n    x86_64)\n        ARCH=amd64\n        ;;\n    aarch64)\n        ARCH=arm64\n        ;;\nesac\n\nget_ctop() {\n  VERSION=$(get_latest_release bcicen/ctop | sed -e 's/^v//')\n  LINK=\"https://github.com/bcicen/ctop/releases/download/v${VERSION}/ctop-${VERSION}-linux-${ARCH}\"\n  wget \"$LINK\" -O /tmp/ctop && chmod +x /tmp/ctop\n}\n\nget_calicoctl() {\n  VERSION=$(get_latest_release projectcalico/calico)\n  LINK=\"https://github.com/projectcalico/calico/releases/download/${VERSION}/calicoctl-linux-${ARCH}\"\n  wget \"$LINK\" -O /tmp/calicoctl && chmod +x /tmp/calicoctl\n}\n\nget_termshark() {\n  case \"$ARCH\" in\n    *)\n      VERSION=$(get_latest_release gcla/termshark | sed -e 's/^v//')\n      if [ \"$ARCH\" == \"amd64\" ]; then\n        TERM_ARCH=x64\n      else\n        TERM_ARCH=\"$ARCH\"\n      fi\n      LINK=\"https://github.com/gcla/termshark/releases/download/v${VERSION}/termshark_${VERSION}_linux_${TERM_ARCH}.tar.gz\"\n      wget \"$LINK\" -O /tmp/termshark.tar.gz && \\\n      tar -zxvf /tmp/termshark.tar.gz && \\\n      mv \"termshark_${VERSION}_linux_${TERM_ARCH}/termshark\" /tmp/termshark && \\\n      chmod +x /tmp/termshark\n      ;;\n  esac\n}\n\nget_grpcurl() {\n  if [ \"$ARCH\" == \"amd64\" ]; then\n    TERM_ARCH=x86_64\n  else\n    TERM_ARCH=\"$ARCH\"\n  fi\n  VERSION=$(get_latest_release fullstorydev/grpcurl | sed -e 's/^v//')\n  LINK=\"https://github.com/fullstorydev/grpcurl/releases/download/v${VERSION}/grpcurl_${VERSION}_linux_${TERM_ARCH}.tar.gz\"\n  wget \"$LINK\" -O /tmp/grpcurl.tar.gz  && \\\n  tar --no-same-owner -zxvf /tmp/grpcurl.tar.gz && \\\n  mv \"grpcurl\" /tmp/grpcurl && \\\n  chmod +x /tmp/grpcurl\n  chown root:root /tmp/grpcurl\n}\n\nget_fortio() {\n  if [ \"$ARCH\" == \"amd64\" ]; then\n    TERM_ARCH=x86_64\n  else\n    TERM_ARCH=\"$ARCH\"\n  fi\n  VERSION=$(get_latest_release fortio/fortio | sed -e 's/^v//')\n  LINK=\"https://github.com/fortio/fortio/releases/download/v${VERSION}/fortio-linux_${ARCH}-${VERSION}.tgz\"\n  wget \"$LINK\" -O /tmp/fortio.tgz  && \\\n  tar -zxvf /tmp/fortio.tgz && \\\n  mv \"usr/bin/fortio\" /tmp/fortio && \\\n  chmod +x /tmp/fortio\n}\n\n\nget_ctop\nget_calicoctl\nget_termshark\nget_grpcurl\nget_fortio\n\n"
  },
  {
    "path": "configs/netshoot-calico.yaml",
    "content": "---\n# NOTE: use apps/v1beta1 before 1.9.x and apps/v1beta2 before v1.16.x\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  namespace: kube-system\n  name: netshoot-calico-deploy\n  labels:\n    app: netshoot-calico\nspec:\n  selector:\n    matchLabels:\n      app: netshoot\n  strategy:\n    type: Recreate\n  template:\n    metadata:\n      labels:\n        app: netshoot\n    spec:\n      serviceAccount: cni-plugin\n      serviceAccountName: cni-plugin\n      hostNetwork: true\n      containers:\n      - image: nicolaka/netshoot\n        name: netshoot\n        command: [\"ping\",\"localhost\"]\n        volumeMounts:\n        - mountPath: /calico-secrets\n          name: etcd-certs\n        - mountPath: /var/run/calico/bird.ctl\n          name: bird-ctl\n        env:\n        - name: ETCD_ENDPOINTS\n          value: \"https://localhost:12378\"\n        - name: ETCD_CA_CERT_FILE\n          valueFrom:\n            configMapKeyRef:\n              key: etcd_ca\n              name: calico-config\n        - name: ETCD_KEY_FILE\n          valueFrom:\n            configMapKeyRef:\n              key: etcd_key\n              name: calico-config\n        - name: ETCD_CERT_FILE\n          valueFrom:\n            configMapKeyRef:\n              key: etcd_cert\n              name: calico-config\n      volumes:\n        - name: etcd-certs\n          secret:\n           defaultMode: 420\n           secretName: calico-etcd-secrets\n        - name: bird-ctl\n          hostPath:\n            path: /var/run/calico/bird.ctl\n      nodeSelector:\n        node-role.kubernetes.io/master: \"\"\n\n"
  },
  {
    "path": "configs/netshoot-sidecar.yaml",
    "content": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n    name: nginx-netshoot\n    labels:\n        app: nginx-netshoot\nspec:\n replicas: 1\n selector:\n    matchLabels:\n        app: nginx-netshoot\n template:\n    metadata:\n     labels:\n        app: nginx-netshoot\n    spec:\n        containers:\n        - name: nginx\n          image: nginx:1.14.2\n          ports:\n            - containerPort: 80\n        - name: netshoot\n          image: nicolaka/netshoot\n          command: [\"/bin/bash\"]\n          args: [\"-c\", \"while true; do ping localhost; sleep 60;done\"]"
  },
  {
    "path": "motd",
    "content": "                    dP            dP                           dP   \n                    88            88                           88   \n88d888b. .d8888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P \n88'  `88 88ooood8   88   Y8ooooo. 88'  `88 88'  `88 88'  `88   88   \n88    88 88.  ...   88         88 88    88 88.  .88 88.  .88   88   \ndP    dP `88888P'   dP   `88888P' dP    dP `88888P' `88888P'   dP   \n                                                                    \nWelcome to Netshoot! (github.com/nicolaka/netshoot)\nVersion: 0.14\n\n                                         \n"
  },
  {
    "path": "zshrc",
    "content": "# If you come from bash you might have to change your $PATH.\n# export PATH=$HOME/bin:/usr/local/bin:$PATH\n\n# Path to your oh-my-zsh installation.\nexport ZSH=$HOME/.oh-my-zsh\n\n# Set name of the theme to load. Optionally, if you set this to \"random\"\n# it'll load a random theme each time that oh-my-zsh is loaded.\n# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes\n#export TERM=\"xterm-256color\"\nZSH_THEME=\"powerlevel10k/powerlevel10k\"\n\nZSH_DISABLE_COMPFIX=\"true\"\n\n# Set list of themes to load\n# Setting this variable when ZSH_THEME=random\n# cause zsh load theme from this variable instead of\n# looking in ~/.oh-my-zsh/themes/\n# An empty array have no effect\n# ZSH_THEME_RANDOM_CANDIDATES=( \"robbyrussell\" \"agnoster\" )\n\n# Uncomment the following line to use case-sensitive completion.\n# CASE_SENSITIVE=\"true\"\n\n# Uncomment the following line to use hyphen-insensitive completion. Case\n# sensitive completion must be off. _ and - will be interchangeable.\n# HYPHEN_INSENSITIVE=\"true\"\n\n# Uncomment the following line to disable bi-weekly auto-update checks.\n# DISABLE_AUTO_UPDATE=\"true\"\n\n# Uncomment the following line to change how often to auto-update (in days).\n# export UPDATE_ZSH_DAYS=13\n\n# Uncomment the following line to disable colors in ls.\n# DISABLE_LS_COLORS=\"true\"\n\n# Uncomment the following line to disable auto-setting terminal title.\n# DISABLE_AUTO_TITLE=\"true\"\n\n# Uncomment the following line to enable command auto-correction.\n# ENABLE_CORRECTION=\"true\"\n\n# Uncomment the following line to display red dots whilst waiting for completion.\n# COMPLETION_WAITING_DOTS=\"true\"\n\n# Uncomment the following line if you want to disable marking untracked files\n# under VCS as dirty. This makes repository status check for large repositories\n# much, much faster.\n# DISABLE_UNTRACKED_FILES_DIRTY=\"true\"\n\n# Uncomment the following line if you want to change the command execution time\n# stamp shown in the history command output.\n# The optional three formats: \"mm/dd/yyyy\"|\"dd.mm.yyyy\"|\"yyyy-mm-dd\"\n# HIST_STAMPS=\"mm/dd/yyyy\"\n\n# Would you like to use another custom folder than $ZSH/custom?\n# ZSH_CUSTOM=/path/to/new-custom-folder\n\n# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)\n# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/\n# Example format: plugins=(rails git textmate ruby lighthouse)\n# Add wisely, as too many plugins slow down shell startup.\nplugins=(\n  git\n  zsh-autosuggestions\n  yarn\n  web-search\n  jsontools\n  macports\n  node\n  sudo\n  docker\n)\n\nsource $ZSH/oh-my-zsh.sh\n# User configuration\ncat motd\n\n# export MANPATH=\"/usr/local/man:$MANPATH\"\n\n# You may need to manually set your language environment\n# export LANG=en_US.UTF-8\n\n# Preferred editor for local and remote sessions\n# if [[ -n $SSH_CONNECTION ]]; then\n#   export EDITOR='vim'\n# else\n#   export EDITOR='mvim'\n# fi\n\n# Compilation flags\n# export ARCHFLAGS=\"-arch x86_64\"\n\n# ssh\n# export SSH_KEY_PATH=\"~/.ssh/rsa_id\"\n\n# Set personal aliases, overriding those provided by oh-my-zsh libs,\n# plugins, and themes. Aliases can be placed here, though oh-my-zsh\n# users are encouraged to define aliases within the ZSH_CUSTOM folder.\n# For a full list of active aliases, run `alias`.\n#\n# Example aliases\n# alias zshconfig=\"mate ~/.zshrc\"\n# alias ohmyzsh=\"mate ~/.oh-my-zsh\"\n\n# test -e \"${HOME}/.iterm2_shell_integration.zsh\" && source \"${HOME}/.iterm2_shell_integration.zsh\"\n\n# Reload the plugin to highlight the commands each time Iterm2 starts\n#source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh\n\n\n### VISUAL CUSTOMISATION ###\n# Elements options of left prompt (remove the @username context)\nPOWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(host dir rbenv)\n# Elements options of right prompt\nPOWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()\n# Add a second prompt line for the command\nPOWERLEVEL9K_PROMPT_ON_NEWLINE=false\n\n# Add a space in the first prompt\nPOWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=''\n\n# Visual customisation of the second prompt line\n#local user_symbol=\"$\"\n#if [[ $(print -P \"%#\") =~ \"#\" ]]; then\n#    user_symbol = \"#\"\n#fi\n#POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX=\"%{%B%F{black}%K{yellow}%} $user_symbol%{%b%f%k%F{yellow}%} %{%f%}\"\n\n\n# Change the git status to red when something isn't committed and pushed\nPOWERLEVEL9K_VCS_MODIFIED_BACKGROUND='red'\n\n# Add a new line after the global prompt\nPOWERLEVEL9K_PROMPT_ADD_NEWLINE=true\n\n\n# Colorise the top Tabs of Iterm2 with the same color as background\n# Just change the 18/26/33 wich are the rgb values\necho -e \"\\033]6;1;bg;red;brightness;18\\a\"\necho -e \"\\033]6;1;bg;green;brightness;26\\a\"\necho -e \"\\033]6;1;bg;blue;brightness;33\\a\"\n"
  }
]