[gull] netfunc.bash
felix
felix at f-hauri.ch
Wed Jul 27 12:33:16 CEST 2022
Quelques corrections et mises à jour:
Le Tue, Apr 05, 2022 at 08:06:50AM +0200, felix via gull a écrit :
>
> https://f-hauri.ch/vrac/netfunc.bash.txt
>
> Ce fichier est un fichier bash, à ``sourcer'':
>
> . netfunc.bash
> Bash source file for IPV4 computing - netfunc v0.13
Nlle v0.15...
> - int2ip integer to IPv4
int2ip 3232235521 3232235790 -> affiche deux lignes: 192.168.0.1 192.168.1.14
int2ip -v chaine 3232235521 3232235790 ->
stoque 192.168.0.1 et 192.168.1.14 dans ${chaine[@]}
> - int2rev 3 most significant bytes, for reverse DNS X.X.X.in-addr.arpa
int2rev 3232235790 -> 1.168.192
> - checkIsIp throw an error if not valid IPv4
checkIsIp "$arg" || echo "Error '$arg' is not an ipv4"
> - ip2int IPv4 to integer 32 bits value.
ip2int 192.168.1.1 -> affiche 3232235777
ip2int -v variable 192.168.1.1 -> stoque 3232235777 dans $variable
> - mask2int from mask len to integer value of IPv4 mask
mask2int 24 -> affiche 4294967040
mask2int -v variable -> stoque 4294967040 dans $variable
int2ip $variable -> affichera 255.255.255.0
> - int2mlen compute mask len from integer value of IPv4 mask
ip2int -v variable 255.255.255.128 ; int2mlen $variable -> affiche 25
ip2int -v variable 255.255.255.128 ; int2mlen -v variable $variable -> stoque 25...
> - be2int Big Endian to INTeger, ( for reading proc/net/route )
be2int -v variable 0001A8C0;int2ip $variable -> affiche 192.168.1.0
be2int -v variable 0001A8C0;int2ip -v variable $variable -> stoque 192.168.1.0...
> - int2uu 1st run generate int2uu() to render bash's 64# from integer
int2uu 3232235521 -> affiche 30G001
echo $((64#30G001)) -> affiche 3232235521
int2uu -v variable 3232235521 ; int2ip $((64#30G001)) -> affiche 192.168.0.1
> - int2bin 1st run generate int2bin to render 32bits, mark mask with a dot.
int2bin 3232235521 24 -> affiche 11000000 10101000 00000000. 00000001
avec un `.' au 24ème bit.
> - rangeIp Generate array of integer representation of IPv4 from argument
rangeIp 192.168.1.100/28 -> affiche 3232235872 3232235873 ... 3232235887
rangeIp 192.168.1.95-192.168.1.110 -> affiche 3232235871 3232235872 ... 3232235886
> - multiping One ping on many target. Use integer representation of IPv4
rangeIp -v variable 192.168.1.0/24 ; multiping ${variable[@]} ->
192.168.1.1 1.09
192.168.1.33 0.654
192.168.1.34 0.029
> - ip2hnam Fork to `host` and store in _ipResInv, if not already stored.
ip2hnam 192.168.1.1 -> peut afficher un truc du genre: internetbox
ip2hnam -v variable 192.168.1.1 -> stoque internetbox dans variable.
> - hname2ip Fork to `host` and store in _ipResolv, if not already stored.
hname2ip internetbox -> affichera (alors) 192.168.1.1
hname2ip -v variable internetbox -> stoque 192.168.1.1 dans variable
> - isup Monitor ping many targets simultaneously (hit any key to quit)
isup 192.168.1.{1,33,34} -> Affiche les temps de réponse de plusieurs hosts
sur une ligne. Appuyer sur une touche pour stopper.
Elaps Cnt int..ox tv-box hp3..76
2.0423 3 2.15 0.286 4.04
> - mping quick ping scan IPv4 ranges and resolv host name of waked hosts
mping 192.168.1.0/24 -> liste des tous les hosts répondant sur 192.168.1.0/24
mping -> sans arguments effectue un ping sur tous les réseaux locaux.
mping -v variable -> stoque la liste des hosts répondants dans $variable
> - ipcalc compute and render network submited as [ip mask] or [ip/masklen]
ipcalc 192.168.1.33/24 192.168.1.1
┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━┓
┃ Network base│192.168.1.0 │ #0│11000000 10101000 00000001│ 00000000┃
┃ Mask │255.255.255.0 │/24 │11111111 11111111 11111111│ 00000000┃
┃ Broadcast │192.168.1.255 │ #255│11000000 10101000 00000001│ 11111111┃
┃ Host/net │254 │Class C │ │ ┃
┠─────────────┼───────────────┼───────────┼──────────────────────────┼─────────┨
┃ internetbox │192.168.1.1 │ #1│11000000 10101000 00000001│ 00000001┃
┃▸Host │192.168.1.33 │ #33│11000000 10101000 00000001│ 00100001┃
┃ Last host │192.168.1.254 │ #254│11000000 10101000 00000001│ 11111110┃
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┛
ipcalc -> sans argument effectue la liste de toutes les IPv4 configurées localement
> - getLocalNet Get local config from /proc/net/ pseudo files
getLocalNet -> affichera interface, ip locale, mask et routeur par défaut, soit
un truc du genre: eth0:192.168.1.33/24:192.168.1.1
> - commonNet compute smallest common network for many IP/net
commonNet 10.167.233.15 10.163.21.1 -> calcule le plus petit commun réseau:
┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━┓
┃ Network base│10.160.0.0 │ #0│00001010 10100│000 00000000 00000000┃
┃ Mask │255.248.0.0 │/13 │11111111 11111│000 00000000 00000000┃
┃ Broadcast │10.167.255.255 │ #524287│00001010 10100│111 11111111 11111111┃
┃ Host/net │524286 │Class A │ │ ┃
┠─────────────┼───────────────┼───────────┼──────────────┼─────────────────────┨
┃ First host │10.160.0.1 │ #1│00001010 10100│000 00000000 00000001┃
┃▸IP min │10.163.21.1 │ #201985│00001010 10100│011 00010101 00000001┃
┃ IP max │10.167.233.15 │ #518415│00001010 10100│111 11101001 00001111┃
┃ Last host │10.167.255.254 │ #524286│00001010 10100│111 11111111 11111110┃
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━┛
> - reCIDR Compute shortened list of CIDR for argument or STDIN
reCIDR 192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4
192.168.1.1/32
192.168.1.2/31
192.168.1.4/32
reCIDR 192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.0
192.168.1.0/30
reCIDR 192.168.1.1/25 192.168.1.200/25
192.168.1.0/24
> - netfuncFList List functions (this.) [-v]
--
Félix Hauri - <felix at f-hauri.ch> - http://www.f-hauri.ch
More information about the gull
mailing list