In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the basic processing of IP addresses and network segments in the IP address processing module IPy. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
First, install IPy
Wget http://www.mylinuxer.com/down/IPy-0.82a.tar.gz
[root@localhost opt] # tar-zxvf IPy-0.82a.tar.gz
[root@localhost opt] # cd python-ipy-IPy-0.82a/
[root@localhost python-ipy-IPy-0.82a] # python setup.py install
2. Basic processing of IP address and network segment
[root@localhost ~] # python
Python 2.6.6 (r266 84292, Oct 12 2012, 14:23:48)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
> from IPy import IP
> ip=IP ('192.168.0.0 Universe 16')
> print ip.len () # output the number of IP of this network segment
65536
> ip=IP ('192.168.1.108')
> ip.reverseNames () # reverse resolution address format
['108.1.168.192.in addr.arpa.']
> ip.iptype () # returns the network type
'PRIVATE'
> ip.int () # returns the decimal format
3232235884
> ip.strHex () # returns hexadecimal format
'0xc0a8016c'
> > ip.strDec ()
'3232235884'
Generate network segment format based on IP and mask
> ip.make_net ('255.255.0.0')
IP ('192.168.0.0amp 16')
> print ('192.168.1.108tick 255.255.255.0)
192.168.1.0/24
> print (IP ('192.168.1.108 take 255.255.0))
192.168.0.0/16
> print (IP ('192.168.1.0-192.168.1.255))
192.168.1.0/24
Specify different wantperfixlen parameter values through the strNormal method to customize network segments of different output types, which are strings.
> IP ('192.168.1.0 amp 24') .strNormal (0)
'192.168.1.0'
> IP ('192.168.1.0 amp 24') .strNormal (1)
'192.168.1.0 Compact 24'
> IP ('192.168.1.0 amp 24'). StrNormal (2)
'192.168.1.0 Compact 255.255.255.0'
> IP ('192.168.1.0 amp 24'). StrNormal (3)
'192.168.1.0-192.168.1.255'
After reading the above, do you have any further understanding of the basic processing of IP address and network segment in IP address processing module IPy? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.