Last active
May 24, 2024 03:15
-
-
Save RealYukiSan/4341def451d6a7e940638282301ef8aa to your computer and use it in GitHub Desktop.
List available network interface
This file contains 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
#!/usr/bin/sh | |
for iface in $(ls /sys/class/net/); do | |
echo "Interface: $iface"; | |
mode=$(iw $iface info 2>/dev/null) | |
if [[ $? -eq 0 ]]; then | |
mode=$(echo "$mode" | grep type | awk '{print $2}') | |
echo "Mode: $mode" | |
fi | |
ethtool -i $iface 2>/dev/null | grep -E 'driver|version'; | |
pci=$(ethtool -i $iface 2>/dev/null | grep bus-info | awk '{print $2}' | cut -d: -f2,3); | |
if [[ -n "$pci" ]]; then | |
lspci -v -s $pci | grep -E 'Ethernet|Network' | |
else | |
echo "PCI info not found"; | |
fi | |
echo "-----"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
deactivate first?:
rename the interface:
switch interface mode:
re-activate?