# Netgraph Bridge



## Phishfry (Jun 16, 2022)

I really think a good article on Netgraph bridges is needed. This seems to be a good primer from the author..





						Daemon News '200003' : '"All About Netgraph "'
					






					people.freebsd.org
				




The netgraph (4) manual is really busy and not real helpful for beginners.





						netgraph(4)
					






					www.freebsd.org
				




I did find these useful:


			http://www.netbsd.org/gallery/presentations/ast/2012_AsiaBSDCon/Tutorial_NETGRAPH.pdf
		


Klara has a useful article with Netgraph for Bhyve








						Using Netgraph for FreeBSD’s Bhyve Networking
					

FreeBSD 13 adds new support for a netgraph backend for virtual network devices under bhyve. Netgraph is a modular networking framework that allows for arbitrary stacking of protocols and transports, along with filtering, tunneling, redirection, inspection, injection and more—fast and...




					klarasystems.com
				




Basic. Not real helpful.


			https://www.unix7.org/ict/netgraph
		


Content here is Jail oriented ng_bridge.


			FreeBSD | Devin Teske
		

ngctl dot | dot -Tsvg -o vgraph.svg

I changed the focus of the post to something more positive. I had disparaged Klara and that was not appropriate.
Netgraph is the subject. Any articles are helpful.


----------



## Phishfry (Jun 16, 2022)

Several of our members have written helpful posts on Netgraph bridge.

Good example on last post








						Ethernet interfaces on bridge using netgraph
					

Hello,  I have some trouble while trying to implement 2 ethernet interfaces connected via a bridge using  netgraph. I am using FreeBSD 10.1 release. What I want to do seems to be as simple as shown in the code section below, however I can't make sending/receiving broadcast messages...




					forums.freebsd.org
				




User benoitc has been struggling with this too:








						failing to mix bridge, vlans and lagg with netgraph
					

I am trying touse netgraph for the bhyve vms with the following goals:   I setup 2 bridge using an LACP bond one dedicated bridge for the vlan 1002 one bridge for all others vlans  The network coming on the bridge that has untagged vlan 1002 is working, but it seems I can only get the vlan 1 on...




					forums.freebsd.org
				











						netgraph ng_bridge: can't ge an IP using DHCP when creating a vlan
					

I am using a bridge `bridge0` that will contain a native nic interface ixl3  and add a tap interface in it:  ifconfig bridge0 create ifconfig bridge0 addm ixl3 addm tap0 ifconfig bridge0 bridge0: flags=8843 metric 0 mtu 1500     ether 58:9c:fc:10:e7:20     id 00:00:00:00:00:00 priority 32768...




					forums.freebsd.org
				




The manual for ng_bridge(4) was unhelpful as well.

I have found these instructions that look promising:

```
• Create the virtual ethernet interface
• # ngctl mkpeer . eiface hook ether
• Verify the interface exists, observe the MAC address is zeroed out
• # ifconfig ngeth0
• ngeth0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
• ether 00:00:00:00:00:00
• Bring up the virtual ethernet interface
• # ifconfig ngeth0 up
• ngeth0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
• inet6 fe80::2d0:9ff:fe4c:9e5f%ngeth0 prefixlen 64 scopeid 0x4
• ether 00:00:00:00:00:00
• Create the bridge and connect the lower link of the virtual interface
# ngctl mkpeer ngeth0: bridge lower link0
• Name the bridge
# ngctl name ngeth0:lower mybridge
• Connect the lower link to the physical interface
# ngctl connect dc0: mybridge: lower link1
• Connect the upper link to the physical interface
# ngctl connect dc0: mybridge: upper link2
• Connect the upper link to the virtual interface
# ngctl connect ngeth0: mybridge: upper link3
• Set the physical interface to not overwrite its source route
# ngctl msg dc0: setautosrc 0
• Set the physical interface into promiscous mode
# ngctl msg dc0: setpromisc 1
• Set the MAC address of the virtual interface
• # ifconfig ngeth0 link 00:5c:16:10:dd:79
• Set the IP address of the virtual interface
• # dhclient ngeth0
• # ifconfig ngeth0
• ngeth0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
• inet6 fe80::2de:adff:fe12:1212%ngeth0 prefixlen 64 scopeid 0x4
• inet 192.168.1.21 netmask 0xffffff00 broadcast 192.168.1.255
• ether 00:5c:16:10:dd:aa
```

Most all netgraph bridge instructions seem to miss the most basic first step.
Make the virtual interface ngeth0


----------

