18 lines
536 B
Python
18 lines
536 B
Python
import netifaces
|
|
|
|
|
|
def print_ethernet_interfaces():
|
|
"""Prints all Ethernet interfaces and their IP addresses."""
|
|
|
|
interfaces = netifaces.interfaces()
|
|
for interface in interfaces:
|
|
addresses = netifaces.ifaddresses(interface)
|
|
if netifaces.AF_INET in addresses:
|
|
for addr in addresses[netifaces.AF_INET]:
|
|
ip_address = addr["addr"]
|
|
print(f"Interface: {interface}, IP Address: {ip_address}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print_ethernet_interfaces()
|