-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_network_info.sh
More file actions
29 lines (25 loc) · 816 Bytes
/
get_network_info.sh
File metadata and controls
29 lines (25 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
#START SCRIPT
ip="$(hostname -I | awk '{print $1}')"
mac="$(cat /sys/class/net/enp0s3/address)"
gate="$(ip r | awk '/via/ {print}' | cut -d ' ' -f 3)"
speed="$(ethtool enp0s3 | awk '/Speed:/ {print}' | cut -d ' ' -f 2)"
dup="$(ethtool enp0s3 | awk '/Duplex:/ {print}' | cut -d ' ' -f 2)"
echo "Dynamic IPv4 Address: '$ip'"
echo "MAC Address: '$mac'"
echo "Gateway Router: '$gate'"
sudo cat /etc/resolv.conf | while IFS= read -r line
do
header="$(echo "$line" | cut -d ' ' -f 1)"
if [[ "$header" == "search" ]]; then
domain="$(echo "$line" | cut -d ' ' -f 2)"
echo "DNS Domain: '$domain'"
fi
if [[ "$header" == "nameserver" ]]; then
server="$(echo "$line" | cut -d ' ' -f 2)"
echo "DNS Server: '$server'"
fi
done
echo "NIC Speed: '$speed'"
echo "Duplex: '$dup'"
#END SCRIPT