# Configuring aliases on a renamed bridge interface in rc.conf



## Koen Martens (Jan 13, 2022)

I'm experimenting a bit with vnet and jails and wanted to create a situation where I have two bridges and a bunch of epair devices as members. To keep things clear, I'd like to rename all interfaces to have a meaningful name.
As an example, I'd like to do something like this:

```
hostname="vnettest"
cloned_interfaces="epair0 epair1 epair2 bridge0 bridge1"
ifconfig_em0="up"
ifconfig_epair0a="name web_ext_host up"
ifconfig_epair0b="name web_ext_jail up"
ifconfig_epair1a="name web_int_host up"
ifconfig epair1b="name web_int_jail up"
ifconfig_epair2a="name crm_int_host up"
ifconfig epair2b="name crm_int_jail up"
ifconfig_bridge0="inet 10.0.2.15 netmask 0xffffff00 addm web_ext_host addm em0 up name ext_bridge"
ifconfig_bridge0_alias0="inet 10.0.2.16 netmask 0xffffff00"
ifconfig_bridge1="inet 10.1.0.1 netmask 0xffffff00 addm crm_int_host addm web_int_host up name int_bridge"
default_gateway="10.0.2.2"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
sshd_enable="YES"
```
Of course, this does not work. The epair interface are created and renamed properly, and the bridges are assigned their primary IP addresses and the members are added. However, the line starting with `ifconfig_bridge0_alias0` obviously is not processed correctly. By the time aliases are added, the interface is already renamed. So logically, it should be `ifconfig_ext_bridge_alias0`, but that won't be processed since `ext_bridge` is not in the `network_interfaces` variable.
I could maybe do something like this:

```
hostname="vnettest"
network_interfaces="epair0 epair1 epair2 ext_bridge int_bridge em0 lo0"
cloned_interfaces="epair0 epair1 epair2 bridge0 bridge1"
create_args_bridge0="name ext_bridge"
create_args_bridge1="name int_bridge"
ifconfig_em0="up"
ifconfig_epair0a="name web_ext_host up"
ifconfig_epair0b="name web_ext_jail up"
ifconfig_epair1a="name web_int_host up"
ifconfig epair1b="name web_int_jail up"
ifconfig_epair2a="name crm_int_host up"
ifconfig epair2b="name crm_int_jail up"
ifconfig_ext_bridge="inet 10.0.2.15 netmask 0xffffff00 addm web_ext_host addm em0 up"
ifconfig_ext_bridge_alias0="inet 10.0.2.16 netmask 0xffffff00"
ifconfig_int_bridge="inet 10.1.0.1 netmask 0xffffff00 addm crm_int_host addm web_int_host up"
default_gateway="10.0.2.2"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
sshd_enable="YES"
```

But the documentation (man rc.conf) says setting network_interfaces to anything other than `AUTO` is deprecated. I'd prefer not to rely on deprecated functionality (plus, there seems to be some issue with epair1b and epair2b, which don't get renamed).

Any way to accomplish this in a neat way?


----------



## SirDice (Jan 13, 2022)

Use `ifconfig_<int>_name` to rename an interface.


```
#ifconfig_em0_name="net0"       # Change interface name from em0 to net0.
```


----------



## Koen Martens (Jan 13, 2022)

SirDice said:


> Use `ifconfig_<int>_name` to rename an interface.
> 
> 
> ```
> ...


Excellent, that did the trick:

```
hostname="vnettest"
cloned_interfaces="epair0 epair1 epair2 bridge0 bridge1"
ifconfig_bridge0_name="ext_bridge"
ifconfig_bridge1_name="int_bridge"
ifconfig_epair0a_name="web_ext_host"
ifconfig_epair0b_name="web_ext_jail"
ifconfig_epair1a_name="web_int_host"
ifconfig_epair1b_name="web_int_jail"
ifconfig_epair2a_name="crm_int_host"
ifconfig_epair2b_name="crm_int_jail"
ifconfig_em0="up"
ifconfig_ext_bridge="inet 10.0.2.15 netmask 0xffffff00 addm web_ext_host addm em0 up"
ifconfig_ext_bridge_alias0="inet 10.0.2.16 netmask 0xffffff00"
ifconfig_int_bridge="inet 10.1.0.1 netmask 0xffffff00 addm crm_int_host addm web_int_host up"
default_gateway="10.0.2.2"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
sshd_enable="YES"
```


----------



## SirDice (Jan 13, 2022)

Not everything is properly documented in rc.conf(5). Have a look through /etc/defaults/rc.conf, you can find interesting information hidden in the comments there.


----------



## Koen Martens (Jan 13, 2022)

In hind-sight, it is documented in rc.conf(5), all the way at the bottom of the entry on `network_interfaces`:


> It is also possible to    rename an interface by doing:
> 
> ifconfig_em0_name="net0"
> ifconfig_net0="inet 192.0.2.1 netmask 0xffffff00"


Completely missed that, started to browse through `network.subr`, but looking at the defaults is a much better suggestion.


----------

