Is it possible to configure a single nic to have two mac addresses?

FreeBSD-12.3p5

This is a theoretical question.

I have a single homed (igb0) host which has a bridge configured so:
Code:
### Networking
## Setup a bridge to enable vnet

cloned_interfaces="bridge0"
ifconfig_bridge0="addm igb0"
ifconfig_igb0="up"

### Base system - this is bridged on igb0
ifconfig_igb0="inet 216.185.71.41/25"

I use this with an IOCAGE jail on the host that uses vnet0 as its i/f and has a unique mac address.

What I wish to obtain is a virtual network interface on the host with an address from 192.168.0.0/16. A simple alias on igb0 will not suffice due to the i/f arrangement on the gateway router. The 192.168 address has to have a different mac address.

Is this possible ? If so then how do I do it?
 
I discovered this old message on the FreeBSD mailing list.
Code:
Virtual Network Interface Card
rozhuk.im at gmail.com rozhuk.im at gmail.com
Fri Dec 17 21:30:31 UTC 2010


You can make virtual NIC via netgraph.

1. ng_ether automatic attached to every physical NICs on load module.

2. connect ng_bridge to upper and lower hooks on ng_ether

3. create and connect ng_eiface to ng_bridge and you will get new NIC ngethX
    with its own MAC address and IP addrs too.

4. repeat 3 :)

But, do not connect physical NICs to one ng_bridge!

Example

# 1. loading netgraph modules
kldload ng_ether
kldload ng_bridge
kldload ng_eiface

# 2. create and connect bridge to physical NIC
ngctl mkpeer em0: bridge lower link0
ngctl connect em0: em0:lower upper link1

# we can set name for bridge, and replace em0:lower -> em0Bridge in ngctl
calls
ngctl name em0:lower em0Bridge

# 3.1 create and connect first virtual NIC
ngctl mkpeer em0:lower eiface link3 ether

# 3.2 create and connect second virtual NIC
ngctl mkpeer em0:lower eiface link4 ether


# configure virtual NICs
ifconfig ngeth0 link 00:11:22:33:44:01
ifconfig ngeth0 inet 192.168.1.254 netmask 255.255.255.0

ifconfig ngeth1 link 00:11:22:33:44:02
ifconfig ngeth1 inet 192.168.2.254 netmask 255.255.255.0

I have verified that the kernel modules still exist in the present day and that the utilities are still available.

Code:
ll /boot/kernel/ng_ether.ko /boot/kernel/ng_bridge.ko /boot/kernel/ng_eiface.ko
-r-xr-xr-x  2 root  wheel  31800 Dec 24 09:35 /boot/kernel/ng_bridge.ko
-r-xr-xr-x  2 root  wheel  29200 Dec 24 09:35 /boot/kernel/ng_eiface.ko
-r-xr-xr-x  2 root  wheel  31272 Dec 24 09:35 /boot/kernel/ng_ether.ko

Does anyone have any experience with this? I am going to experiment later but if this is a dead end from the get-go then I would appreciate knowing.
 
Back
Top