Created
          October 25, 2025 07:45 
        
      - 
      
 - 
        
Save NF1198/7704e69cb37ec5517f2cf99157d021c1 to your computer and use it in GitHub Desktop.  
  
    
      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 characters
    
  
  
    
  | #!/bin/bash | |
| # Colors | |
| BOLD="\033[1m" | |
| BLUE="\033[1;34m" | |
| CYAN="\033[1;36m" | |
| YELLOW="\033[1;33m" | |
| MAGENTA="\033[1;35m" | |
| WHITE="\033[1;37m" | |
| DARKRED="\033[0;31m" | |
| NC="\033[0m" | |
| # ───────────────────────────────────────────── | |
| echo -e "${BOLD}${BLUE}SYSTEM INFO${NC}" | |
| echo -e "${CYAN}Hostname: ${YELLOW}$(hostname)${NC}" | |
| echo -e "${CYAN}FQDN: ${YELLOW}$(hostname -f)${NC}" | |
| default_gw=$(ip route | awk '/^default/ {print $3; exit}') | |
| [[ -n "$default_gw" ]] && echo -e "${CYAN}Default GW: ${YELLOW}$default_gw${NC}" | |
| # ───────────────────────────────────────────── | |
| echo -e "\n${BOLD}${BLUE}NAME SERVICES${NC}" | |
| found=0 | |
| for svc in \ | |
| systemd-resolved dnsmasq nscd named \ | |
| unbound pdns-recursor dnscrypt-proxy coredns avahi-daemon; do | |
| if systemctl is-active --quiet "$svc"; then | |
| echo -e "${CYAN}Service: ${YELLOW}$svc${NC}" | |
| found=1 | |
| fi | |
| done | |
| [[ $found -eq 0 ]] && echo -e "${CYAN}Service: ${YELLOW}<none active>${NC}" | |
| # ───────────────────────────────────────────── | |
| echo -e "\n${BOLD}${BLUE}DNS SERVERS${NC}" | |
| if command -v resolvectl >/dev/null 2>&1; then | |
| resolvectl dns | tail -n +2 | awk '{print " \033[1;36mDNS:\033[0m \033[1;33m" $2 "\033[0m"}' | |
| else | |
| grep '^nameserver' /etc/resolv.conf | awk '{print " \033[1;36mDNS:\033[0m \033[1;33m" $2 "\033[0m"}' | |
| fi | |
| # ───────────────────────────────────────────── | |
| echo -e "\n${BOLD}${BLUE}INTERFACES${NC}" | |
| # Build associative array of MAC addresses | |
| declare -A macs | |
| while IFS= read -r line; do | |
| ifname=$(echo "$line" | awk -F: '{print $2}' | xargs) | |
| mac=$(echo "$line" | grep -oP 'link/\w+ \K([0-9a-f]{2}:){5}[0-9a-f]{2}') | |
| [[ -n "$ifname" && -n "$mac" ]] && macs["$ifname"]="$mac" | |
| done < <(ip -o link) | |
| # Show interface info | |
| ip -brief address | while read -r line; do | |
| iface=$(echo "$line" | awk '{print $1}') | |
| state=$(echo "$line" | awk '{print $2}') | |
| addrs=$(echo "$line" | cut -d' ' -f3-) | |
| ipv4=$(echo "$addrs" | grep -oP '\d+\.\d+\.\d+\.\d+/\d+' | head -n1) | |
| ipv6=$(echo "$addrs" | grep -oP '([a-fA-F0-9:]+:+)+[a-fA-F0-9]*/\d+' | head -n1) | |
| mac="${macs[$iface]}" | |
| if [[ -n "$mac" ]]; then | |
| echo -e "${CYAN}Interface: ${YELLOW}$iface ${WHITE}[$mac]${NC}" | |
| else | |
| echo -e "${CYAN}Interface: ${YELLOW}$iface${NC}" | |
| fi | |
| if [[ "$state" == "DOWN" ]]; then | |
| echo -e "${CYAN} Status: ${DARKRED}DOWN${NC}" | |
| continue | |
| fi | |
| [[ -n "$ipv4" ]] && echo -e "${CYAN} IPv4: ${YELLOW}$ipv4${NC}" | |
| [[ -n "$ipv6" ]] && echo -e "${CYAN} IPv6: ${MAGENTA}$ipv6${NC}" | |
| done | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment