CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

| Download

ddclient debug

Project: ddclient
Views: 23
Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2204
Kernel: Python 3 (system-wide)
import ipaddress
service = 'if' ifconfig_out = """em0_vlan10: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 description: WAN (wan) options=4000000<NOMAP> ether ec:a8:6b:f2:97:08 inet 10.80.1.109 netmask 0xffffff00 broadcast 10.80.1.255 groups: vlan vlan: 10 vlanproto: 802.1q vlanpcp: 0 parent interface: em0 media: Ethernet autoselect (1000baseT <full-duplex>) status: active nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>"""
for line in ifconfig_out.split('\n'): if line.startswith('\tinet'): parts = line.split() print(parts) if (parts[0] == 'inet' and service == 'if') or (parts[0] == 'inet6' and service == 'if6'): try: address = ipaddress.ip_address(parts[1]) if address.is_global: print(str(address)) except ValueError: continue
['inet', '10.80.1.109', 'netmask', '0xffffff00', 'broadcast', '10.80.1.255']
print(address) print(address.is_global)
10.80.1.109 False