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

# ng\_device(4)

device interface netgraph node

## NAME

**ng\_device** – device interface netgraph node

## SYNOPSIS

**#include \<netgraph/ng\_device.h\>**

## DESCRIPTION

A **device** node is both a netgraph node and a system device interface. When a **device** node is created, a new device entry appears which is accessible via the regular file operators such as [open(2)](/open/2.md), [close(2)](/close/2.md), [read(2)](/read/2.md), [write(2)](/write/2.md), etc.

The first node is created as */dev/ngd0*, subsequent nodes are */dev/ngd1*, */dev/ngd2*, etc.

## HOOKS

A **device** node has a single hook with an arbitrary name. All data coming in over the hook will be presented to the device for [read(2)](/read/2.md). All data coming in from the device entry by [write(2)](/write/2.md) will be forwarded to the hook.

## CONTROL MESSAGES

The **device** node supports the generic control messages, plus the following:

- NGM\_DEVICE\_GET\_DEVNAME

  Returns the device name corresponding to the node.

- NGM\_DEVICE\_ETHERALIGN

  Apply the system ETHER\_ALIGN offset to mbufs sent out the node's hook, if running on an architecture that requires strict alignment. Use this option when the data being injected via the device node ultimately ends up being fed into the protocol stack as ethernet packets (e.g., via an [ng\_eiface(4)](/ng_eiface/4.md) node).

## SHUTDOWN

This node shuts down upon receipt of a NGM\_SHUTDOWN control message, or upon hook disconnection. The associated device entry is removed and becomes available for use by future **device** nodes.

## SEE ALSO

[netgraph(4)](/netgraph/4.md), [ngctl(8)](/ngctl/8.md)

## HISTORY

The **device** node type was first implemented in FreeBSD 5.0.

## AUTHORS

Mark Santcroos ⟨*marks@ripe.net*⟩ Gleb Smirnoff ⟨*glebius@FreeBSD.org*⟩
