mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-26 21:18:36 -06:00
new: Added getip.sh
This commit is contained in:
parent
16eb2379cd
commit
3a2f1761e5
2 changed files with 20 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
![Number of scripts](https://img.shields.io/badge/number_of_scripts-38-blue)
|
![Number of scripts](https://img.shields.io/badge/number_of_scripts-39-blue)
|
||||||
# Random Scripts
|
# Random Scripts
|
||||||
This repository is for random scripts I wrote mostly for personal use.
|
This repository is for random scripts I wrote mostly for personal use.
|
||||||
|
|
||||||
|
|
19
getip.sh
Normal file
19
getip.sh
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This is a simple script to get the ip addresses of a machine.
|
||||||
|
|
||||||
|
echo 'ipv4:'
|
||||||
|
for i in eno1 wlan0; do
|
||||||
|
addr="$(ip -4 addr show dev $i | grep -oP '(?<=inet\s)\d+(\.\d+){3}')"
|
||||||
|
[ -z "$addr" ] || echo -e "\t$i: \t\t$addr"
|
||||||
|
done
|
||||||
|
echo -e "\texternal: \t$(curl -s ipv4.icanhazip.com)"
|
||||||
|
|
||||||
|
[ "$(cat /sys/module/ipv6/parameters/disable)" == "1" ] && exit
|
||||||
|
|
||||||
|
echo 'ipv6:'
|
||||||
|
for i in eno1 wlan0; do
|
||||||
|
addr="$(ip -6 addr show dev $i | grep -oP '(?<=inet6\s)\w+(\:{1,2}\w+){4}(?=.+link)')"
|
||||||
|
[ -z "$addr" ] || echo -e "\t$i: \t\t$addr"
|
||||||
|
done
|
||||||
|
echo -e "\texternal: \t$(curl -s ipv6.icanhazip.com)"
|
Loading…
Reference in a new issue