gitr.daemon.contact
This is a working implementation, you can start from this.
It builds bridges and point-to-point connections.
To build a bridge (in /etc/rc.conf.local):
Code:
ngbridge_names="... lan ..."
# physical interfaces to connect (if applicable):
ngbridge_lan_physifs="alc0 fxp2"
# physical interface you want to see from the OS (not recommended, because
# then the bridge is offline when this iface is unplugged):
ngbridge_lan_hostif="alc0"
# virtual interfaces and their configurations:
ngbridge_lan_eifaces="nge_1u nge_2u"
ngbridge_nge_1u_mac="00:37:92:01:02:02"
ngbridge_nge_1u_addr_num="1"
ngbridge_nge_1u_addr_1="inet 192.168.0.17/28"
ngbridge_nge_2u_mac="00:37:92:01:02:01"
ngbridge_nge_2u_addr_num="2"
ngbridge_nge_2u_addr_1="inet 192.168.0.19/28"
ngbridge_nge_2u_addr_2="inet6 fd00::9876 prefixlen 120 auto_linklocal"
# interfaces you want to persist during "service ngbridge restart":
ngbridge_lan_eifaces_keep="nge_1u"
# routes that can only be configured after the bridge is up (invoked in descending seq):
ngbridge_lan_route_num=2
ngbridge_lan_route_2="-6 -net fd00::/64 fd00::1234"
ngbridge_lan_route_1="-net default 192.168.33.1"
ngbridge_lan_vlans="NO"
To connect a jail to this bridge via an additional eiface, put this in /etc/jail.conf:
Code:
myjail {
vnet = "new";
$ifname1l = n${name}1l;
$ifname1l_mac = 00:37:92:01:01:02;
vnet.interface = "$ifname1l";
exec.prestart = "
echo -e \"mkpeer eiface crhook ether\nname .:crhook $ifname1l\" \
| /usr/sbin/ngctl -f -
/usr/sbin/ngctl connect ${ifname1l}: lanbridge: ether link17
ifname=`/usr/sbin/ngctl msg ${ifname1l}: getifname | \
awk '$1 == \"Args:\" { print substr($2, 2, length($2)-2)}'`
/sbin/ifconfig \$ifname name $ifname1l
/sbin/ifconfig $ifname1l link $ifname1l_mac
";
exec.poststop = "
sleep 1 ;
/usr/sbin/ngctl shutdown ${ifname1l}: ;
";
}
To build a point-to-point connection:
(A point-to-point connection has exactly two virtual ifaces and nothing else, so there is no point in creating a bridge for that)
Code:
ngbridge_names="... tele ..."
# two virtual interfaces and their configurations:
ngbridge_tele_eifaces="ngtele1u ngtele1l"
ngbridge_ngtele1u_mac="00:37:92:01:03:01"
ngbridge_ngtele1l_mac="00:37:92:01:03:02"
ngbridge_ntele1u_addr_num=2
ngbridge_ntele1u_addr_1="inet 192.168.0.129/30"
ngbridge_ntele1u_addr_2="inet6 fd00::abcd prefixlen 120 auto_linklocal"
ngbridge_tele_vlans="NO"
To use this for a jail:
Code:
tele {
vnet = "new";
vnet.interface = "n${name}1l";
}
If you need vlans, you can create like this:
Code:
ngbridge_names="... vl ..."
ngbridge_vl_physifs="igb0"
ngbridge_vl_vlans="YES"
This creates a bridge, and a
ng_vlan(4) node attached to it. You can then wire to that node from anywhere else and add a filter for some vlan -
like it's done in my bhyve rc.d.
Code:
Name: igb0 Type: ether ID: 00000002 Num hooks: 1
Local hook Peer name Peer type Peer ID Peer hook
---------- --------- --------- ------- ---------
lower vlbridge bridge 0000000c link0
Name: vlbridge Type: bridge ID: 0000000c Num hooks: 2
Local hook Peer name Peer type Peer ID Peer hook
---------- --------- --------- ------- ---------
link1 vl_vlan vlan 00000011 downstream
link0 igb0 ether 00000002 lower
Name: vl_vlan Type: vlan ID: 00000011 Num hooks: 2
Local hook Peer name Peer type Peer ID Peer hook
---------- --------- --------- ------- ---------
vlan7 tap1 ether 00000042 lower
downstream vlbridge bridge 0000000c link1