# Clean networking deployment for Ansible



## junialter (Oct 21, 2021)

Hi,

I would like to deploy network configuration to some FreeBSD machines. I have simple setups with just a NIC and static addresses. I also have setups with bridging and vlan so I can put my iocage jails into a specific vlan.

Before I start writing a new Ansible role I just wanted to check with you. My approach would be to make sure that /etc/rc.conf is free of any network configuration whatsoever. I don't want to use Ansible builtins like lineinfile or replace. That would be extremely cumbersome and error prone.
Instead I would like to generate clean networking only files and then put them somewhere, but where?

Might that be possible or does the networking config has to be in /etc/rc.conf
Juni


----------



## Jose (Oct 21, 2021)

From the rc.conf(5) man page:


> The file _/etc/defaults/vendor.conf_ allows vendors to override FreeBSD defaults...
> In    addition to _/etc/rc.conf.local_ you can also place smaller configura-
> tion files    for each rc(8) script in the _/etc/rc.conf.d_ directory or
> <_dir_>_/rc.conf.d_ directories specified in _local___startup_, which will    be in-
> cluded by the _load___rc___config_ function...


----------



## junialter (Oct 21, 2021)

Ah that's wonderful, thank you so much.


----------



## junialter (Oct 26, 2021)

I just tried on a freshly installed system to put those lines into /etc/rc.conf.d/network and purged them from /etc/rc.conf

```
ifconfig_vtnet0="inet 10.10.129.8 netmask 255.255.255.192"
defaultrouter="10.10.129.1"
ifconfig_vtnet0_ipv6="inet6 2001:1234:4321:7300::f/64"
ipv6_defaultrouter="2001:1234:4321:7300::1"
```
The IP addresses are being set but no default gateways.
I will try different setups and split everything up, meaning default routes into rc.conf and everything else into dedicated file. I'll keep you updated.


----------



## junialter (Oct 27, 2021)

Currently I'm trying to create bridges with children and static IP addresses.
My resulting config looks like this:

```
cloned_interfaces="bridge0 bridge1"
ifconfig_bridge0="addm vtnet0 up"
ifconfig_vtnet0="up"
ifconfig_bridge0="inet 10.10.129.8 netmask 255.255.255.0"
ifconfig_bridge0_ipv6="inet6 2001:1234:4321:7300::f prefixlen 64 auto_linklocal"
```
Yet when the system boots up the vtnet0 child is missing on the bridge.
The moment I run `ifconfig bridge0 addm vtnet0 up` everything is up and running. Does somebody have an idea why that is? I cannot find the error.


----------

