---
name: "pcap_lookupnet"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pcap_lookupnet"
---

# pcap\_lookupnet(3)

find the IPv4 network number and netmask for a device

## NAME

pcap\_lookupnet - find the IPv4 network number and netmask for a device

## SYNOPSIS

```
#include <pcap/pcap.h>
```

```
char errbuf[PCAP_ERRBUF_SIZE];
```

**int pcap\_lookupnet(const char \*device, bpf\_u\_int32 \*netp,**\
     **bpf\_u\_int32 \*maskp, char \*errbuf);**

## DESCRIPTION

**pcap\_lookupnet**() is used to determine the IPv4 network number and mask associated with the network device *device*. Both *netp* and *maskp* are **bpf\_u\_int32** pointers. *errbuf* is a buffer large enough to hold at least **PCAP\_ERRBUF\_SIZE** chars.

This function is not available on Windows.  It supports neither IPv6 nor multiple IPv4 addresses per interface, which obviously is not practical in modern networks.  See [**pcap\_findalldevs**(3)](/pcap_findalldevs/3.md) for a more elaborate solution to the problem.

## RETURN VALUE

**pcap\_lookupnet**() returns **0** on success and **PCAP\_ERROR** on failure. If **PCAP\_ERROR** is returned, *errbuf* is filled in with an appropriate error message.

## SEE ALSO

[**pcap**(3)](/pcap/3.md)
