Problem with creating virtual devices in rc.conf

freeBSDNew

New Member


Messages: 4

Hello,

I*m relativley new to Unix, Shell and FreeBSD. So, please, please, are not to angry with me, if my question is stupid. I did allways some internet-research, but could not find any answers to my problem.

I'm running 12.1-RELEASE-p5 FreeBSD 12.1-RELEASE-p5 GENERIC amd64 as guest in VirtualBox 6, with one virtual nic attached.

My goal is, to create a virtual network-stack. So I play with the system, to learn, how to do things. Actually I try to create several virtual devices.

in loader.conf I have
Code:
if_bridge_load="YES"
if_epair_load="YES"
But, when I create more than one virtual device in rc.conf, f. e.
Code:
cloned_interfaces="bridge0"
cloned_interfaces="epair0"
cloned_interfaces="bridge1"
or
Code:
cloned_interfaces="bridge0"
cloned_interfaces="epair0"
or
Code:
cloned_interfaces="bridge0"
cloned_interfaces="bridge1"
if I do something like this
Code:
cloned_interfaces="bridge0"
cloned_interfaces="bridge1"
ifconfig_bridge0="up"
ifconfig_bridge1="up"
the result will be always the same: ifconfig always only shows the last cloned interface in the list

like this
Code:
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=81009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,VLAN_HWFILTER>
    ether 08:00:27:4e:81:3d
    inet 10.0.2.9 netmask 0xffffff00 broadcast 10.0.2.255
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
    inet 127.0.0.1 netmask 0xff000000
    groups: lo
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

bridge1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether 02:a8:c0:24:88:01
    id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
    maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
    root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
    groups: bridge
    nd6 options=9<PERFORMNUD,IFDISABLED>
where "bridge1" will be epair0 a/b or bridge1, depending, on what is the last created device in rc.conf. Bridge0 will be only shown there, if there are no other devices created in rc.conf. Even a "ifconfig bridge0" will show "ifconfig: interface bridge0 does not exist" in the other cases.

But if I create a bridge manually, like "ifconfig bridge0" will create that, and list it, if I give a "ifconfig" in the terminal.

What could be / is the problem, how to solve it?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,085
Messages: 33,642

In essence rc.conf is a shell script. Entries are variables, not commands. You're assigning values to the same variable, so only the last will be valid:
Code:
#!/bin/sh

var="1"
var="2"

echo $var
This will print "2". Same with rc.conf.

If you need more than one cloned interfaces add them all, separated by spaces:
Code:
cloned_interfaces="bridge0 bridge1"
This will also work:
Code:
cloned_interfaces="bridge0"
cloned_interfaces+="bridge1"
Note the +=.
 
Top