Skip to content

Instantly share code, notes, and snippets.

@wugh
Created May 16, 2015 08:17
Show Gist options
  • Save wugh/5ed0f4d7bf98a3741409 to your computer and use it in GitHub Desktop.
Save wugh/5ed0f4d7bf98a3741409 to your computer and use it in GitHub Desktop.
根据脚本获取ip地址,并且打印出可用的ipv6地址,需要调用getip.py脚本,该脚本依赖python3
#!/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)
#!/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