|
NAMEng_macfilter —
packet filtering netgraph node using ethernet MAC
addresses
SYNOPSIS#include <sys/types.h>
#include
<netgraph/ng_macfilter.h>
DESCRIPTIONThemacfilter allows routing ethernet packets over
different hooks based on the sender MAC address.
This processing is done when traffic flows from the
“ether” hook through Packets are not altered in any way. If hooks are not connected, packets are dropped. HOOKSThis node type by default has anether hook, to be
connected to the lower hook of the NIC, and a
default hook where packets are sent if the MAC
adddress is not found in the table. macfilter supports
up to NG_MACFILTER_UPPER_NUM hooks to be connected to
the NIC's upper hook. Other nodes can be inserted to provide additional
processing. All outbound can be combined back into one by using
ng_one2many .
CONTROL MESSAGESThis node type supports the generic control messages, plus the following:
SHUTDOWNThis node shuts down upon receipt of aNGM_SHUTDOWN
control message or when all have been disconnected.
EXAMPLESThe following netgraph configuration will apply ipfw(8) tag 42 to each packet that is routed over the “accepted” hook. The graph looks like the following:/------<one>-[combiner]-<many1>--------\ <upper> | <out> / <many0> \ [em0] | [tagger] \ <default> / <lower> | <in> \----<ether>-[macfilter]-<accepted>-----/ Commands: ngctl mkpeer em0: macfilter lower ether ngctl name em0:lower macfilter # Funnel both streams back into ether:upper ngctl mkpeer em0: one2many upper one ngctl name em0:upper recombiner # Connect macfilter:default to recombiner:many0 ngctl connect macfilter: recombiner: default many0 # Connect macfilter:accepted to tagger:in ngctl mkpeer macfilter: tag accepted in ngctl name macfilter:accepted tagger # Connect tagger:out to recombiner:many1 ngctl connect tagger: recombiner: out many1 # Mark tag all traffic through tagger in -> out with an ipfw tag 42 ngctl msg tagger: sethookin '{ thisHook="in" ifNotMatch="out" }' ngctl msg tagger: sethookout '{ thisHook="out" tag_cookie=1148380143 tag_id=42 }' # Pass traffic from ether:upper / combiner:one via combiner:many0 on to # macfilter:default and on to ether:lower. ngctl msg recombiner: setconfig '{ xmitAlg=3 failAlg=1 enabledLinks=[ 1 1 ] }' Note: The tag_cookie 1148380143 was retrieved
from The following command can be used to add a MAC address to be
output via ngctl msg macfilter: direct '{ hookname="known" ether=08:00:27:92:eb:aa }' The following command can be used to retrieve the packet and byte counters : ngctl msg macfilter: getmacs It will return the contents of the MAC table: Rec'd response "getmacs" (4) from "[54]:": Args: { n=1 macs=[ { ether=08:00:27:92:eb:aa hookid=1 packets_in=3571 bytes_in=592631 packets_out=3437 bytes_out=777142 } ] } SEE ALSOdivert(4), ipfw(4), netgraph(4), ng_ether(4), ng_one2many(4), ng_tag(4), ngctl(8)AUTHORSThe original version of this code was written by Pekka Nikander, and subsequently modified heavily by Nick Hibma <n_hibma@FreeBSD.org>.BUGSNone known.
Visit the GSP FreeBSD Man Page Interface. |