Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Get IP address

from netifaces import interfaces, ifaddresses, AF_INET
for ifaceName in interfaces():
    addresses = [i['addr'] for i in ifaddresses(ifaceName).setdefault(AF_INET, [{'addr':'No IP addr'}] )]
    print('%s: %s' % (ifaceName, ', '.join(addresses)))
    
>>>
  lo: 127.0.0.1
  enp30s0: No IP addr
  wlp31s0: 192.168.1.56
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Get #IP #address
ADD COMMENT
Topic
Name
8+7 =