Skip to content

get_if_addr for macOS vlan iface not returning correct address #4704

Open
@jhgorse

Description

@jhgorse

Brief description

get_if_addr(iface="vlan0") returns 0.0.0.0 instead of the IP address.

Scapy version

2.6.1

Python version

3.12.3

Operating system

macOS 15.3.2

Additional environment information

No response

How to reproduce

Expect get_if_hwaddr("vlan0") to return 10.0.2.7, instead we see 0.0.0.0:

vlan_ifaces_list=["vlan1", "vlan0"]
for iface in vlan_ifaces_list:
    print(f"get_if_hwaddr({iface}) \t{get_if_hwaddr(iface)}")
    print(f"get_if_addr({iface}) \t{get_if_addr(iface)}")
>>>
get_if_hwaddr(vlan1) 	00:e0:4c:68:24:00
get_if_addr(vlan1) 	0.0.0.0
get_if_hwaddr(vlan0) 	00:e0:4c:08:1b:1b
get_if_addr(vlan0) 	0.0.0.0

read_routes() has the correct information in columns 3 and 4, but it appears to be drawing from column 2, the gateway entry if I am reading this right.

s = set() # there will be redundencies so we'll use set to remove them
for line in read_routes():
    s.add(line[2:5])
s

>>>
{
 ('0.0.0.0', 'vlan0', '10.0.2.7'),
 ('0.0.0.0', 'vlan1', '10.0.2.11'),
 ('10.0.2.7', 'vlan1', '10.0.2.11'),
snip
}

The IPs are indicated by ifconfig:

vlan1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=6063<RXCSUM,TXCSUM,TSO4,TSO6,PARTIAL_CSUM,ZEROINVERT_CSUM>
	ether 00:e0:4c:68:24:00
	inet 10.0.2.11 netmask 0xffff0000 broadcast 10.0.255.255
	nd6 options=201<PERFORMNUD,DAD>
	vlan: 2 parent interface: en7
	media: autoselect (1000baseT <full-duplex>)
	status: active
vlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=6063<RXCSUM,TXCSUM,TSO4,TSO6,PARTIAL_CSUM,ZEROINVERT_CSUM>
	ether 00:e0:4c:08:1b:1b
	inet 10.0.2.7 netmask 0xffff0000 broadcast 10.0.255.255
	nd6 options=201<PERFORMNUD,DAD>
	vlan: 2 parent interface: en11
	media: autoselect (1000baseT <full-duplex>)
	status: active
snip

Actual result

get_if_addr("vlan1") 	0.0.0.0
get_if_addr("vlan0") 	0.0.0.0

Expected result

get_if_addr("vlan1") 	10.0.2.11
get_if_addr("vlan0") 	10.0.2.7

Related resources

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions