| 1 | #! /bin/bash |
| 2 | set -xu |
| 3 | |
| 4 | # Gather distro & kernel info. |
| 5 | lsb_release -a || cat /etc/issue /etc/os-release |
| 6 | uname -a |
| 7 | |
| 8 | echo "Printing per-distro configuration" |
| 9 | cat /etc/wsl.conf |
| 10 | |
| 11 | echo "Printing adapter & routing configuration" |
| 12 | ip a |
| 13 | ip route show table all |
| 14 | ip neighbor |
| 15 | ip link |
| 16 | ip rule show |
| 17 | |
| 18 | # We only print whether the HTTP proxy variables are set or not, as their content might contain secrets such as usernames, passwords. |
| 19 | if [ -z ${http_proxy+x} ]; then echo "http_proxy is unset"; else echo "http_proxy is set"; fi |
| 20 | if [ -z ${HTTP_PROXY+x} ]; then echo "HTTP_PROXY is unset"; else echo "HTTP_PROXY is set"; fi |
| 21 | if [ -z ${https_proxy+x} ]; then echo "https_proxy is unset"; else echo "https_proxy is set"; fi |
| 22 | if [ -z ${HTTPS_PROXY+x} ]; then echo "HTTPS_PROXY is unset"; else echo "HTTPS_PROXY is set"; fi |
| 23 | if [ -z ${no_proxy+x} ]; then echo "no_proxy is unset"; else echo "no_proxy is set"; fi |
| 24 | if [ -z ${NO_PROXY+x} ]; then echo "NO_PROXY is unset"; else echo "NO_PROXY is set"; fi |
| 25 | if [ -z ${WSL_PAC_URL+x} ]; then echo "WSL_PAC_URL is unset"; else echo "WSL_PAC_URL is set"; fi |
| 26 | |
| 27 | echo "Printing DNS configuration" |
| 28 | cat /etc/resolv.conf |
| 29 | cat /etc/nsswitch.conf |
| 30 | |
| 31 | echo "Printing iptables and nftables rules" |
| 32 | # iptables can be configured using both "iptables" and the legacy version "iptables-legacy". It's possible they can be used together |
| 33 | # (although not recommended). Collect both to make sure no rules are missed. |
| 34 | # We list the contents of the most common tables (filter, nat, mangle, raw, security) |
| 35 | iptables -vL -t filter |
| 36 | iptables -vL -t nat |
| 37 | iptables -vL -t mangle |
| 38 | iptables -vL -t raw |
| 39 | iptables -vL -t security |
| 40 | |
| 41 | ip6tables -vL -t filter |
| 42 | ip6tables -vL -t nat |
| 43 | ip6tables -vL -t mangle |
| 44 | ip6tables -vL -t raw |
| 45 | ip6tables -vL -t security |
| 46 | |
| 47 | iptables-legacy -vL -t filter |
| 48 | iptables-legacy -vL -t nat |
| 49 | iptables-legacy -vL -t mangle |
| 50 | iptables-legacy -vL -t raw |
| 51 | iptables-legacy -vL -t security |
| 52 | |
| 53 | ip6tables-legacy -vL -t filter |
| 54 | ip6tables-legacy -vL -t nat |
| 55 | ip6tables-legacy -vL -t mangle |
| 56 | ip6tables-legacy -vL -t raw |
| 57 | ip6tables-legacy -vL -t security |
| 58 | |
| 59 | nft list ruleset |
| 60 | |
| 61 | # This will print configurations such as net.ipv4.conf.all.route_localnet or net.ipv4.ip_local_port_range |
| 62 | echo "Printing networking configurations" |
| 63 | sysctl -a | grep net |