Created
May 16, 2015 08:17
-
-
Save wugh/5ed0f4d7bf98a3741409 to your computer and use it in GitHub Desktop.
根据脚本获取ip地址,并且打印出可用的ipv6地址,需要调用getip.py脚本,该脚本依赖python3
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
#!/usr/bin/env python3 | |
# encoding: utf-8 | |
import ipaddress | |
from random import shuffle | |
#iprange = ipaddress.ip_network('2800:3f0:4000::/36') | |
iprange = ipaddress.ip_network('2607:f8b0:4005:802::1002/112', strict=False) | |
addresses = [] | |
for ip in iprange.hosts(): | |
addresses.append(ip) | |
shuffle(addresses) | |
for ip in addresses[:20]: | |
print(ip) |
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 | |
python3 getip.py | tee t_ip.txt | xargs -n 1 ping6 -c 2 | |
cat t_ip.txt | tr '\n' '|' > ip.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment