### Perform Load Testing with Fortio Source: https://github.com/nicolaka/netshoot/blob/master/README.md Fortio is a load-testing tool. This example shows how to initiate a load test against a given URL. ```bash $ fortio load http://www.google.com ``` -------------------------------- ### Netshoot Kubectl Plugin Usage Examples Source: https://github.com/nicolaka/netshoot/blob/master/README.md Demonstrates how to use the Netshoot kubectl plugin to run ephemeral debug pods, debug existing pods, or debug nodes. ```bash # 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 ``` -------------------------------- ### Start a netcat listener Source: https://context7.com/nicolaka/netshoot/llms.txt Starts a netcat listener on a specified port within a Docker container. This is useful for testing network connectivity. ```bash docker network create -d bridge my-br docker run -d --rm --net my-br --name service-a nicolaka/netshoot nc -l 8080 ``` -------------------------------- ### Live packet capture with Termshark Source: https://context7.com/nicolaka/netshoot/llms.txt Starts Termshark for live packet capture on a specified interface with a display filter. Requires NET_ADMIN and NET_RAW capabilities. ```bash docker run --rm --cap-add=NET_ADMIN --cap-add=NET_RAW -it \ nicolaka/netshoot termshark -i eth0 icmp ``` -------------------------------- ### Query DNS Information with drill Source: https://github.com/nicolaka/netshoot/blob/master/README.md Utilize drill to retrieve detailed DNS information. This example queries for version 5 information about 'perf-test-b'. ```bash $ docker run -it --net container:perf-test-a nicolaka/netshoot drill -V 5 perf-test-b ``` -------------------------------- ### Start iperf server in a Docker container Source: https://context7.com/nicolaka/netshoot/llms.txt Starts an iperf3 server in a detached Docker container for network throughput testing. Ensure the container is connected to the desired network. ```bash docker network create -d bridge perf-test docker run -d --rm --net perf-test --name perf-test-a nicolaka/netshoot iperf3 -s -p 9999 ``` -------------------------------- ### Enter Network Namespaces with nsenter Source: https://github.com/nicolaka/netshoot/blob/master/README.md nsenter allows entering different Linux namespaces. This example shows how to mount Docker's network namespace directory and then use nsenter to enter a specific network namespace. ```bash $ docker run -it --rm -v /var/run/docker/netns:/var/run/docker/netns --privileged=true nicolaka/netshoot / # cd /var/run/docker/netns/ /var/run/docker/netns # ls / # nsenter --net=/var/run/docker/netns/ sh ``` -------------------------------- ### Test TCP/UDP Connections with netcat Source: https://github.com/nicolaka/netshoot/blob/master/README.md Netcat can be used for testing network connections. This example creates a bridge network, starts a netcat listener on port 8080, and then tests the connection from another container. ```bash $ docker network create -d bridge my-br $ docker run -d --rm --net my-br --name service-a nicolaka/netshoot nc -l 8080 $ docker run -it --rm --net my-br --name service-b nicolaka/netshoot nc -vz service-a 8080 ``` -------------------------------- ### Use Netshoot with Docker Host Network Namespace Source: https://context7.com/nicolaka/netshoot/llms.txt Troubleshoot the host network stack directly by running netshoot with the host's network namespace. This avoids the need to install tools on the host machine. ```bash $ docker run -it --net host nicolaka/netshoot / # ip route show / # netstat -tulpn / # tcpdump -i eth0 -n ``` -------------------------------- ### Run Netshoot in Host's Network Namespace (Docker) Source: https://github.com/nicolaka/netshoot/blob/master/README.md Execute netshoot with the host's network namespace to diagnose issues affecting the entire host machine. This avoids installing tools directly on the host. ```bash $ docker run -it --net host nicolaka/netshoot ``` -------------------------------- ### Interact with gRPC Servers using grpcurl Source: https://github.com/nicolaka/netshoot/blob/master/README.md grpcurl is a command-line client for gRPC servers. It allows you to invoke methods and inspect services. Examples show both TLS and plaintext connections. ```bash grpcurl grpc.server.com:443 my.custom.server.Service/Method # no TLS grpcurl -plaintext grpc.server.com:80 my.custom.server.Service/Method ``` -------------------------------- ### Send SMTP Test Emails with Swaks Source: https://github.com/nicolaka/netshoot/blob/master/README.md Swaks is a versatile tool for testing SMTP connections and sending emails. This example demonstrates sending a test email with custom headers, authentication, and TLS. ```bash swaks --to user@example.com \ --from fred@example.com --h-From: '"Fred Example" ' \ --auth CRAM-MD5 --auth-user me@example.com \ --header-X-Test "test email" \ --tls \ --data "Example body" ``` -------------------------------- ### Manual Multi-Arch Docker Build and Push Source: https://context7.com/nicolaka/netshoot/llms.txt Manually build and push multi-architecture Docker images for Netshoot using docker buildx. ```bash docker buildx build \ --platform linux/amd64,linux/arm64 \ --output "type=image,push=true" \ --file ./Dockerfile \ --tag nicolaka/netshoot:v1.0 \ --tag nicolaka/netshoot:latest . ``` -------------------------------- ### Fortio Load Testing Source: https://context7.com/nicolaka/netshoot/llms.txt Perform basic and advanced HTTP load tests. Configure QPS, duration, connections, and save reports. ```bash # Basic load test (default: 8 connections, 8 QPS) $ fortio load http://www.example.com ``` ```bash # 100 QPS for 30 seconds, 50 connections, save JSON report $ fortio load -qps 100 -t 30s -c 50 -json /tmp/report.json http://my-service:8080/api ``` ```bash # Start Fortio's built-in web UI and REST API $ fortio server # Web UI at http://localhost:8080/fortio/ ``` -------------------------------- ### Monitor real-time bandwidth with iftop Source: https://context7.com/nicolaka/netshoot/llms.txt Runs iftop within a container's network namespace to display real-time network bandwidth usage, sorted by host pair. ```bash docker run -it --net container:perf-test-a nicolaka/netshoot iftop -i eth0 ``` -------------------------------- ### Run iftop for Network Usage Monitoring Source: https://github.com/nicolaka/netshoot/blob/master/README.md Use iftop to monitor real-time network bandwidth usage by host pairs on a specified interface. Requires a running container with the 'perf-test-a' network. ```bash $ docker run -it --net container:perf-test-a nicolaka/netshoot iftop -i eth0 ``` -------------------------------- ### List gRPC services with grpcurl Source: https://context7.com/nicolaka/netshoot/llms.txt Lists all available services exposed by a gRPC server. Requires the server address and port. ```bash grpcurl grpc.server.com:443 list ``` -------------------------------- ### Run ctop for container metrics Source: https://context7.com/nicolaka/netshoot/llms.txt Launches the ctop container monitoring tool. Mount the Docker socket to view metrics for all running containers. ```bash docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nicolaka/netshoot ctop ``` -------------------------------- ### Makefile for Building Netshoot Image Source: https://context7.com/nicolaka/netshoot/llms.txt Build Netshoot Docker images for different architectures using provided Makefile targets. ```makefile # Makefile targets make build-x86 # linux/amd64 make build-arm64 # linux/arm64 make build-all # multi-arch (no push) make all # multi-arch build + push ``` -------------------------------- ### Run Temporary Debug Pod (Kubernetes) Source: https://github.com/nicolaka/netshoot/blob/master/README.md Spin up a temporary, self-cleaning Kubernetes pod running netshoot for debugging purposes. This is useful for quick network checks without leaving persistent resources. ```bash $ kubectl run tmp-shell --rm -i --tty --image nicolaka/netshoot ``` -------------------------------- ### Analyze Network Traffic with Termshark (Live) Source: https://github.com/nicolaka/netshoot/blob/master/README.md Use Termshark to capture and display live network traffic on an interface, applying Wireshark display filters. Requires NET_ADMIN and NET_RAW capabilities. ```bash $ docker run --rm --cap-add=NET_ADMIN --cap-add=NET_RAW -it nicolaka/netshoot termshark -i eth0 icmp ``` -------------------------------- ### Inspect IP Routing and Neighbor Tables Source: https://github.com/nicolaka/netshoot/blob/master/README.md Use iproute2 utilities to view the system's IP routing table and neighbor cache. This requires running netshoot in host network mode. ```bash $ docker run -it --net host nicolaka/netshoot / # ip route show / # ip neigh show ``` -------------------------------- ### kubectl-netshoot Plugin for Troubleshooting Pods Source: https://context7.com/nicolaka/netshoot/llms.txt Utilize the kubectl-netshoot plugin to quickly launch a troubleshooting pod. This simplifies the process of running netshoot within a Kubernetes cluster for debugging purposes. ```bash # Install: https://github.com/nilic/kubectl-netshoot#installation # Throw-away troubleshooting pod kubectl netshoot run tmp-shell ``` -------------------------------- ### List network interfaces with ip link Source: https://context7.com/nicolaka/netshoot/llms.txt Displays all network interfaces and their status within the current network namespace. ```bash / # ip link show ``` -------------------------------- ### Run iperf3 client to measure throughput Source: https://context7.com/nicolaka/netshoot/llms.txt Executes an iperf3 client to measure network throughput against a running server. This command should be run from a separate container on the same network. ```bash docker run -it --rm --net perf-test --name perf-test-b nicolaka/netshoot iperf3 -c perf-test-a -p 9999 ``` -------------------------------- ### Enter Docker network namespaces with nsenter Source: https://context7.com/nicolaka/netshoot/llms.txt Allows entering a specific Docker container's network namespace using its network namespace path. Requires privileged mode and Docker socket mounting. ```bash docker run -it --rm \ -v /var/run/docker/netns:/var/run/docker/netns \ --privileged=true nicolaka/netshoot / # nsenter --net=/var/run/docker/netns/1234abcd sh ``` -------------------------------- ### Netstat and SS for Socket Information Source: https://context7.com/nicolaka/netshoot/llms.txt View listening sockets, established connections, and connection states using netstat or the more efficient ss command. ```bash # All listening TCP/UDP sockets with process names / # netstat -tulpn ``` ```bash # Equivalent with ss (faster, more detail) / # ss -tulpn ``` ```bash # Show established connections / # ss -tnp state established ``` ```bash # Count connections by state / # ss -tan | awk '{print $1}' | sort | uniq -c | sort -rn ``` -------------------------------- ### Monitor Container Metrics with CTOP Source: https://github.com/nicolaka/netshoot/blob/master/README.md Run CTOP to monitor container metrics like CPU, memory, and network in real-time. Requires mounting the Docker socket. ```bash $ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nicolaka/netshoot ctop ``` -------------------------------- ### Apply and Access Netshoot Sidecar Pod Source: https://github.com/nicolaka/netshoot/blob/master/README.md Commands to apply the Netshoot sidecar deployment and exec into the Netshoot container for interactive debugging. ```bash $ 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 $ ``` -------------------------------- ### Debug Running Pod with Ephemeral Container (Kubernetes) Source: https://github.com/nicolaka/netshoot/blob/master/README.md Use kubectl debug to launch netshoot as an ephemeral container within an existing Kubernetes pod. This allows for on-demand network troubleshooting without modifying the pod's original definition. ```bash $ kubectl debug mypod -it --image=nicolaka/netshoot ``` -------------------------------- ### Run Netshoot in Host Network Namespace (Kubernetes) Source: https://github.com/nicolaka/netshoot/blob/master/README.md Launch a temporary Kubernetes pod using netshoot that operates within the host's network namespace. This is suitable for debugging host-level network configurations from within the cluster. ```bash $ kubectl run tmp-shell --rm -i --tty --overrides='{"spec": {"hostNetwork": true}}' --image nicolaka/netshoot ``` -------------------------------- ### Analyze pcap file with Termshark Source: https://context7.com/nicolaka/netshoot/llms.txt Opens an existing pcap file in Termshark for analysis. Mount the pcap file into the container and specify the file path with -r. ```bash 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 ``` -------------------------------- ### Docker Compose: Capture Traffic from a Service with Netshoot Source: https://context7.com/nicolaka/netshoot/llms.txt Deploy netshoot as a companion service in Docker Compose to capture network packets from another service's network interface. The captured traffic can be analyzed offline. ```yaml # docker-compose.yml version: "3.6" services: tcpdump: image: nicolaka/netshoot depends_on: - nginx command: tcpdump -i eth0 -w /data/nginx.pcap network_mode: service:nginx # shares nginx's network namespace volumes: - $PWD/data:/data nginx: image: nginx:alpine ports: - 80:80 ``` ```bash $ docker compose up # A nginx.pcap file is written to ./data/ for offline analysis $ docker run --rm -v $PWD/data:/data nicolaka/netshoot tshark -r /data/nginx.pcap ``` -------------------------------- ### Kubernetes: Ephemeral Debug Container with Netshoot Source: https://context7.com/nicolaka/netshoot/llms.txt Inject netshoot as an ephemeral container into a running Kubernetes pod without requiring a restart. This allows for immediate network troubleshooting within the pod's context. ```bash # Inject netshoot as an ephemeral container into an existing pod (no restart needed) $ kubectl debug mypod -it --image=nicolaka/netshoot # Throw-away pod — deleted automatically on exit $ kubectl run tmp-shell --rm -i --tty --image=nicolaka/netshoot # Throw-away pod on the host network namespace $ kubectl run tmp-shell --rm -i --tty \ --overrides='{"spec": {"hostNetwork": true}}' \ --image=nicolaka/netshoot ``` -------------------------------- ### Deploy Netshoot as a Kubernetes Sidecar Source: https://github.com/nicolaka/netshoot/blob/master/README.md Deploy a Kubernetes Deployment with Nginx and a Netshoot sidecar container. The Netshoot container runs a loop to keep it alive and accessible for debugging. ```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"] ``` -------------------------------- ### Analyze Network Traffic with Termshark (File) Source: https://github.com/nicolaka/netshoot/blob/master/README.md Use Termshark to read and display network traffic from a pcap file. Mount the pcap file into the container. ```bash $ 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 ``` -------------------------------- ### Inspect bridge network namespace Source: https://context7.com/nicolaka/netshoot/llms.txt After entering a bridge network namespace using nsenter, this command shows IP addresses and bridge forwarding database entries. ```bash / # ip addr show / # bridge fdb show ``` -------------------------------- ### Test SMTP with Swaks (TLS/CRAM-MD5) Source: https://context7.com/nicolaka/netshoot/llms.txt Sends an email using Swaks with TLS encryption and CRAM-MD5 authentication. Useful for testing SMTP server configurations. ```bash swaks --to user@example.com \ --from fred@example.com \ --h-From: '"Fred Example" ' \ --auth CRAM-MD5 --auth-user me@example.com \ --header-X-Test "test email" \ --tls \ --data "Example body" ``` -------------------------------- ### Netshoot iperf for Network Performance Testing Source: https://github.com/nicolaka/netshoot/blob/master/README.md Use iperf within Netshoot containers to test network performance between two Docker containers. Requires a bridge network for communication. ```bash $ docker network create -d bridge perf-test $ docker run -d --rm --net perf-test --name perf-test-a nicolaka/netshoot iperf -s -p 9999 $ docker run -it --rm --net perf-test --name perf-test-b nicolaka/netshoot iperf -c perf-test-a -p 9999 ``` -------------------------------- ### Inspect routing table with ip route Source: https://context7.com/nicolaka/netshoot/llms.txt Displays the IP routing table within a host's network namespace. Useful for understanding network traffic flow. ```bash docker run -it --net host nicolaka/netshoot / # ip route show ``` -------------------------------- ### Show socket statistics with ss Source: https://context7.com/nicolaka/netshoot/llms.txt Lists active network sockets, including listening ports and established connections. Replaces the older 'netstat' command. ```bash / # ss -tulpn ``` -------------------------------- ### Perform DNS diagnostics with drill Source: https://context7.com/nicolaka/netshoot/llms.txt Uses the drill tool to query DNS records, specifying a target host and optionally a DNS server version. Useful for troubleshooting DNS resolution. ```bash docker run -it --net container:perf-test-a nicolaka/netshoot drill -V 5 perf-test-b ``` -------------------------------- ### Service version detection on specific ports Source: https://context7.com/nicolaka/netshoot/llms.txt Scans specified ports on localhost within a container's network namespace to detect running services and their versions. ```bash docker run -it --net container:my-app nicolaka/netshoot nmap -sV -p 80,443,8080 localhost ``` -------------------------------- ### Inspect ARP/neighbor cache with ip neigh Source: https://context7.com/nicolaka/netshoot/llms.txt Shows the ARP cache (neighbor table) for the current network namespace. Helps diagnose Layer 2 connectivity issues. ```bash / # ip neigh show ``` -------------------------------- ### Discover live hosts on a subnet Source: https://context7.com/nicolaka/netshoot/llms.txt Uses nmap to perform a host discovery scan (ping scan) on a given subnet. This helps identify active hosts. ```bash docker run -it --net host nicolaka/netshoot nmap -sn 192.168.1.0/24 ``` -------------------------------- ### Perform a UDP scan with netcat Source: https://context7.com/nicolaka/netshoot/llms.txt Tests UDP connectivity to a specified port on a target service. Useful for checking UDP-based services or firewall rules. ```bash docker run -it --rm --net my-br nicolaka/netshoot nc -vzu service-a 5353 ``` -------------------------------- ### Display interface RX/TX counters with ip -s link Source: https://context7.com/nicolaka/netshoot/llms.txt Shows detailed statistics for a network interface, including received (RX) and transmitted (TX) packet counts. ```bash / # ip -s link show eth0 ``` -------------------------------- ### Quick SMTP connectivity test with Swaks Source: https://context7.com/nicolaka/netshoot/llms.txt Performs a basic SMTP connection test to a specified server and port without authentication or TLS. Helps verify basic reachability. ```bash swaks --to user@example.com --server mail.example.com:25 ``` -------------------------------- ### Attach Netshoot to a Docker Container's Network Namespace Source: https://context7.com/nicolaka/netshoot/llms.txt Run netshoot sharing the network namespace of an existing container to inspect its network stack. This is useful for diagnosing issues from the perspective of a specific application container. ```bash # Attach to a running container's network namespace $ docker run -it --net container: nicolaka/netshoot # Example: inspect interfaces and routes of "my-app" $ docker run -it --net container:my-app nicolaka/netshoot / # ip addr show / # ip route show / # ss -tulpn ``` -------------------------------- ### Kubernetes: Calico CNI Debug Deployment with Netshoot Source: https://context7.com/nicolaka/netshoot/llms.txt Deploy netshoot on a Kubernetes master node with host networking enabled for debugging Calico CNI. This configuration allows direct access to Calico configurations and network status. ```yaml # configs/netshoot-calico.yaml — runs on master node with host networking and Calico credentials apiVersion: apps/v1 kind: Deployment metadata: namespace: kube-system name: netshoot-calico-deploy spec: template: spec: serviceAccountName: cni-plugin hostNetwork: true containers: - image: nicolaka/netshoot name: netshoot command: ["ping", "localhost"] env: - name: ETCD_ENDPOINTS value: "https://localhost:12378" - name: ETCD_CA_CERT_FILE valueFrom: configMapKeyRef: key: etcd_ca name: calico-config ``` ```bash $ kubectl apply -f configs/netshoot-calico.yaml $ kubectl exec -it -n kube-system -- calicoctl node status ``` -------------------------------- ### Invoke a specific gRPC RPC method Source: https://context7.com/nicolaka/netshoot/llms.txt Invokes a specific RPC method on a gRPC server. Requires the server address, port, service name, and method name. ```bash grpcurl grpc.server.com:443 my.custom.server.Service/Method ``` -------------------------------- ### Test TCP connectivity with netcat Source: https://context7.com/nicolaka/netshoot/llms.txt Tests TCP connectivity to a listening service from another container on the same network. Reports success or failure. ```bash docker run -it --rm --net my-br --name service-b nicolaka/netshoot nc -vz service-a 8080 ``` -------------------------------- ### Run Netshoot in Container's Network Namespace (Docker) Source: https://github.com/nicolaka/netshoot/blob/master/README.md Launch netshoot within the network namespace of another container to troubleshoot its specific network configuration. This is useful when application-level network issues are suspected. ```bash $ docker run -it --net container: nicolaka/netshoot ``` -------------------------------- ### Netshoot tcpdump for Packet Analysis Source: https://github.com/nicolaka/netshoot/blob/master/README.md Run tcpdump inside a Netshoot container attached to a specific Docker network to capture and analyze network packets on a given port. ```bash $ docker run -it --net container:perf-test-a nicolaka/netshoot / # tcpdump -i eth0 port 9999 -c 1 -Xvv ``` -------------------------------- ### MTR Network Diagnostics Source: https://context7.com/nicolaka/netshoot/llms.txt Combine traceroute and ping for detailed network path analysis. Use with host or container networks. ```bash $ docker run -it --net host nicolaka/netshoot mtr --report 8.8.8.8 # Sends 10 probe packets per hop and prints latency statistics ``` ```bash $ docker run -it --net container:my-app nicolaka/netshoot mtr --report --tcp -P 443 api.example.com ``` -------------------------------- ### Deploy Netshoot with Docker Compose for TCPdump Source: https://github.com/nicolaka/netshoot/blob/master/README.md This Docker Compose configuration deploys netshoot to capture TCPdump data from a specified network interface (eth0) within the network namespace of an nginx service. Captured data is saved to a local volume. ```yaml 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 ``` -------------------------------- ### Fping Bulk ICMP Reachability Source: https://context7.com/nicolaka/netshoot/llms.txt Perform bulk ICMP reachability checks on subnets or lists of hosts, reporting which hosts are up. ```bash # Ping an entire subnet and report which hosts are up $ docker run -it --net host nicolaka/netshoot fping -a -g 192.168.1.0/24 2>/dev/null ``` ```bash # Ping a list of hosts with timestamps $ docker run -it --net host nicolaka/netshoot \ fping -D -l -p 500 host1.local host2.local host3.local ``` -------------------------------- ### Netshoot nmap for Port Scanning Source: https://github.com/nicolaka/netshoot/blob/master/README.md Use nmap from within a Netshoot container to scan a target IP address for open ports. Requires privileged access for certain scans. ```bash $ docker run -it --privileged nicolaka/netshoot nmap -p 12376-12390 -dd 172.31.24.25 ``` -------------------------------- ### Kubernetes: Netshoot Sidecar Container in a Deployment Source: https://context7.com/nicolaka/netshoot/llms.txt Deploy netshoot as a sidecar container within a Kubernetes Deployment. This allows netshoot to share the network namespace of the primary application container, enabling in-context network analysis. ```yaml # configs/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"] ``` ```bash $ kubectl apply -f configs/netshoot-sidecar.yaml $ kubectl exec -it nginx-netshoot-7f9c6957f8-kr8q6 -c netshoot -- /bin/zsh nginx-netshoot-7f9c6957f8-kr8q6 $ # now inside netshoot, sharing nginx's network namespace ``` -------------------------------- ### Invoke gRPC method without TLS Source: https://context7.com/nicolaka/netshoot/llms.txt Invokes an RPC method on a gRPC server using plaintext (no TLS). Useful for testing local or unencrypted gRPC services. ```bash grpcurl -plaintext grpc.server.com:80 my.custom.server.Service/Method ``` -------------------------------- ### Netshoot netstat for Network Configuration Source: https://github.com/nicolaka/netshoot/blob/master/README.md Execute netstat within a Netshoot container attached to a specific Docker network to inspect network configuration and activity. ```bash $ docker run -it --net container:perf-test-a nicolaka/netshoot / # netstat -tulpn ``` -------------------------------- ### Save captured traffic to a pcap file Source: https://context7.com/nicolaka/netshoot/llms.txt Captures all traffic on a specified interface and saves it to a pcap file. This file can later be analyzed with tools like Wireshark. ```bash docker run -it --net container:perf-test-a nicolaka/netshoot / # tcpdump -i eth0 -w /tmp/capture.pcap ``` -------------------------------- ### Check DNSSEC records Source: https://context7.com/nicolaka/netshoot/llms.txt Uses drill to query DNSSEC records for a domain. This is helpful for verifying DNS security extensions. ```bash docker run -it nicolaka/netshoot drill -D example.com ``` -------------------------------- ### Tshark Packet Capture and Analysis Source: https://context7.com/nicolaka/netshoot/llms.txt Capture and analyze network traffic using command-line Wireshark. List interfaces, filter traffic, and decode PCAP files. ```bash # List available interfaces $ docker run --rm --cap-add=NET_ADMIN --cap-add=NET_RAW nicolaka/netshoot tshark -D ``` ```bash # Capture HTTP traffic and print fields $ docker run --rm --cap-add=NET_ADMIN --cap-add=NET_RAW --net container:my-app \ nicolaka/netshoot tshark -i eth0 -Y "http" -T fields -e http.request.uri ``` ```bash # Decode a pcap $ docker run --rm -v /tmp/capture.pcap:/tmp/capture.pcap nicolaka/netshoot \ tshark -r /tmp/capture.pcap -Y "tcp.flags.syn==1" ``` -------------------------------- ### Scan a port range on a specific host Source: https://context7.com/nicolaka/netshoot/llms.txt Performs a port scan on a given IP address within a specified range. Requires privileged mode for certain scan types. ```bash docker run -it --privileged nicolaka/netshoot nmap -p 12376-12390 -dd 172.31.24.25 ``` -------------------------------- ### Query a specific DNS server Source: https://context7.com/nicolaka/netshoot/llms.txt Queries DNS records for a domain using a specified public DNS server. This helps isolate issues with specific DNS resolvers. ```bash docker run -it nicolaka/netshoot drill @8.8.8.8 example.com A ``` -------------------------------- ### Capture packets on a specific port Source: https://context7.com/nicolaka/netshoot/llms.txt Captures a limited number of packets on a specified interface and port with verbose hex output. This is useful for inspecting traffic details. ```bash docker run -it --net container:perf-test-a nicolaka/netshoot / # tcpdump -i eth0 port 9999 -c 10 -Xvv ``` -------------------------------- ### OpenSSL TLS Certificate Inspection Source: https://context7.com/nicolaka/netshoot/llms.txt Inspect remote TLS certificates, test cipher support, and check certificate expiry directly from the command line. ```bash # Inspect a remote TLS certificate / # openssl s_client -connect example.com:443 /dev/null | openssl x509 -noout -text ``` ```bash # Test cipher support / # openssl s_client -cipher ECDHE-RSA-AES256-GCM-SHA384 -connect example.com:443 ``` ```bash # Check certificate expiry / # echo | openssl s_client -connect example.com:443 2>/dev/null \ | openssl x509 -noout -dates ``` -------------------------------- ### Pass JSON request body to gRPC method Source: https://context7.com/nicolaka/netshoot/llms.txt Invokes an RPC method with a JSON payload. The -d flag specifies the request body. ```bash grpcurl -plaintext -d '{"name": "world"}' localhost:50051 helloworld.Greeter/SayHello ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.