I'm trying to bridge two of several NICs to act like a switching hub.
To do so, need to enable the promiscuous mode on the NICs.
Even if I set it to “promisc on” with the “ip link” command, the setting will be reset when I reboot the PC.
How can I enable Promiscuous Mode permanently, even if I reboot my PC?
The environment is Ubuntu Desktop 20.04 LTS.
For this reason, the network configuration is based on NetworkManager.
A sample of the minimum configuration is shown below:
Vagrant.configure("2") do |config|
config.vm.define :bridge do |machine|
machine.vm.box = "bento/ubuntu-20.04"
machine.vm.network :private_network, auto_config: false, virtualbox__intnet: "intnet_a"
machine.vm.network :private_network, auto_config: false, virtualbox__intnet: "intnet_b"
machine.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y network-manager
cat > /etc/netplan/50-bridge.yaml <<'EOS'
network:
version: 2
ethernets:
eth1:
addresses:
- 0.0.0.0/32
eth2:
addresses:
- 0.0.0.0/32
bridges:
br0:
interfaces:
- eth1
- eth2
EOS
echo 'network: { version: 2, renderer: NetworkManager }' > /etc/netplan/99-NetworkManager.yaml
netplan apply
SHELL
end
end
The "ip link" command activates the PROMISC status of the NIC, as shown below.
$ sudo ip link set dev eth1 promisc on
$ sudo ip link set dev eth2 promisc on
$ ip addr
[...]
3: eth1: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether xx:xx:xx:xx:c4:f5 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether xx:xx:xx:xx:48:57 brd ff:ff:ff:ff:ff:ff
5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether xx:xx:xx:xx:c4:f5 brd ff:ff:ff:ff:ff:ff
[...]
However, after rebooting the OS, the PROMISC status will be reset.
$ sudo reboot
[...]
$ ip addr
[...]
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether xx:xx:xx:xx:c4:f5 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether xx:xx:xx:xx:48:57 brd ff:ff:ff:ff:ff:ff
5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether xx:xx:xx:xx:c4:f5 brd ff:ff:ff:ff:ff:ff
[...]
In this example, I used Vagrant for the purpose of showing a reproducible environment.
Vagrant is not a requirement, what I really want to use is Ubuntu on a physical PC.
Simply enabling Promiscuous Mode through a Vagrant provisioning run does not solve this problem.