From 965ec19a2ec0283fe7f43c19dc424af649433370 Mon Sep 17 00:00:00 2001 From: 0x-0ddc0de <133626972+0x-0ddc0de@users.noreply.github.com> Date: Wed, 17 Dec 2025 16:25:55 -0800 Subject: [PATCH] Fix interface IP for point-to-point links - For point-to-point links, IFA_ADDRESS is the peer rather than local interface IP; we need to instead use IFA_LOCAL --- scapy/arch/linux/rtnetlink.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scapy/arch/linux/rtnetlink.py b/scapy/arch/linux/rtnetlink.py index d5d267df10a..5e0e72d404b 100644 --- a/scapy/arch/linux/rtnetlink.py +++ b/scapy/arch/linux/rtnetlink.py @@ -774,18 +774,23 @@ def _get_ips(af_family=socket.AF_UNSPEC): ifindex = msg.ifa_index address = None family = msg.ifa_family + local = None for attr in msg.data: if attr.rta_type == 0x01: # IFA_ADDRESS address = attr.rta_data - break - if address is not None: + elif attr.rta_type == 0x02: # IFA_LOCAL + local = attr.rta_data + # include/uapi/linux/if_addr.h: for point-to-point links, IFA_LOCAL is the local + # interface address and IFA_ADDRESS is the peer address + local_address = local if local is not None else address + if local_address is not None: data = { "af_family": family, "index": ifindex, - "address": address, + "address": local_address, } if family == 10: # ipv6 - data["scope"] = scapy.utils6.in6_getscope(address) + data["scope"] = scapy.utils6.in6_getscope(local_address) ips.setdefault(ifindex, list()).append(data) return ips