Created
January 9, 2025 17:12
-
-
Save nickkostov/b605df329647c470fae995b68b0b1e7c to your computer and use it in GitHub Desktop.
Revisions
-
nickkostov created this gist
Jan 9, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ #!/bin/bash # Function to check distribution type check_distro() { if [ -f /etc/os-release ]; then . /etc/os-release DISTRO=$ID else echo "Unable to determine the distribution type." exit 1 fi } # Main script check_distro # Print network configuration echo "\n####################### Network Configuration #######################" ifconfig 2>/dev/null || ip addr echo "\n######################### /etc/hosts File ##########################" cat /etc/hosts echo "\n####################### /etc/resolv.conf File ######################" cat /etc/resolv.conf # Handle systemd-resolved files echo "\n####################### Systemd Resolved Config #####################" if [ "$DISTRO" == "debian" ] || [ "$DISTRO" == "ubuntu" ]; then if [ -f /etc/systemd/resolved.conf ]; then echo "\n/etc/systemd/resolved.conf:" cat /etc/systemd/resolved.conf else echo "File not found: /etc/systemd/resolved.conf" fi if [ -f /run/systemd/resolve/resolv.conf ]; then echo "\n/run/systemd/resolve/resolv.conf:" cat /run/systemd/resolve/resolv.conf else echo "File not found: /run/systemd/resolve/resolv.conf" fi elif [ "$DISTRO" == "rhel" ] || [ "$DISTRO" == "centos" ] || [ "$DISTRO" == "fedora" ]; then if [ -f /etc/systemd/resolved.conf ]; then echo "\n/etc/systemd/resolved.conf:" cat /etc/systemd/resolved.conf else echo "File not found: /etc/systemd/resolved.conf" fi else echo "Unsupported distribution: $DISTRO" exit 1 fi echo "\n#####################################################################"