Skip to content

Instantly share code, notes, and snippets.

@tawateer
Last active March 26, 2019 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tawateer/b6df50f890af3503b43369f17b535baf to your computer and use it in GitHub Desktop.
Save tawateer/b6df50f890af3503b43369f17b535baf to your computer and use it in GitHub Desktop.
根据网段和掩码计算起始 IP 和终止 IP

下载 ip.py 到本机, 执行 python ip.py 网段 掩码

> python ip.py 111.10.40.128 255.255.255.192

 111.10.40.128 111.10.40.191

输出即是起始和终止 IP。

#!/bin/env python
# -*- coding:utf-8 -*-
from IPy import IP
import sys
def process(ip, mask):
x = IP(ip).make_net(mask)
print str(x[0]), str(x[-1])
process(sys.argv[1], sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment