-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.py
More file actions
26 lines (20 loc) · 722 Bytes
/
test.py
File metadata and controls
26 lines (20 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import netifaces
print 'Found interfaces:'
for iface in netifaces.interfaces():
print ' %s' % iface
print '\n'
for iface in netifaces.interfaces():
allAddrs = netifaces.ifaddresses(iface)
print 'Interface %s:' % iface
for family,addrs in allAddrs.iteritems():
fam_name = netifaces.address_families[family]
print ' Address family: %s' % fam_name
for addr in addrs:
print ' Address : %s' % addr['addr']
nmask = addr.get('netmask', None)
if nmask:
print ' Netmask : %s' % nmask
bcast = addr.get('broadcast', None)
if bcast:
print ' Broadcast: %s' % bcast
print '\n'