secdev / secdev/scapy

get_if_addr for macOS vlan iface not returning correct address

Open
#4,704 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
12.6k
Forks
2.2k
Avg merge
1d 4h
Merged PRs (30d)
56

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the get_if_addr() and read_routes() entry points, comparing their handling of macOS VLAN interfaces with the supplied ifconfig output. Reproduce the vlan0 and vlan1 cases, then verify that get_if_addr("vlan1") returns 10.0.2.11 and get_if_addr("vlan0") returns 10.0.2.7.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.