With cloned_interfaces you can do multiple things, for example:
Adjusting FreeBSD Virtual LAN Configuration: VLAN is a group of hosts with a common set of requirements that communicate as if they were attached to the same wire, regardless of their physical location. A VLAN has the same attributes as a physical LAN, but it allows for end stations to be grouped together even if they are not located on the same LAN segment. Network reconfiguration can be done through software instead of physically relocating devices. To make configuration persistence, open /etc/rc.conf:
vi /etc/rc.conf
Append / modify as follows:
cloned_interfaces="vlan0" ifconfig_vlan0="inet x.x.x.x netmask y.y.y.y vlan 2 vlandev em0"
- Creating a permanent loopback interface (FreeBSD), by using
ifconfig lo1 create, then adding the following to /etc/rc.conf:
cloned_interfaces="lo1"
ifconfig_lo1="inet a.b.c.d/netmask"
where a.b.c.d is the ip address.
Linking aggregation/bonding in FreeBSD using link aggregation control protocol LACP: to bond multiple ethernet links together in FreeBSD is fairly simple, for example use LACP which does require some switch configuration to work, then ensure the link aggregation module is started at boot, so edit /boot/loader.conf and add the following line:
if_lagg_load=”YES”
Now configure the port… in this example we will bond igb0 and bge0 together into a two port LACP bundle. We will assign the IP 192.0.2.10/24 to the interface. Add the following to /etc/rc.conf:
cloned_interfaces=”lagg0″ ifconfig_igb0=”up” ifconfig_bge0=”up” ifconfig_lagg0=”laggproto lacp laggport igb0 laggport bge0 up” ifconfig_lagg0_alias0=”inet 192.0.2.10/24″
- FreeBSD Jail with Single IP, let's say we have the following scenario: you have a FreeBSD VPS with a single IP and you wish to create a FreeBSD jail for additional security and/or isolation. For this write up I’ll illustrate how you can use a single VPS with a jail create on an internal IP with both NAT access and port-forwarding to the jail for specific ports (web, ssh, etc). Then create the local interface as follows:
In your rc.conf clone the loopback interface to lo1 so that we can use the 192.168., 10., or 172.16.* for our private jail network.
cloned_interfaces="lo1" ipv4_addrs_lo1="192.168.0.1-9/29"
The above will create a lo1 loopback device with 192.168.0.1 thru 192.168.0.9 created on that interface. From here we’ll create a jail with 192.168.0.2. Then we’ll configure PF to allow outbound traffic (NAT) from those local addresses as well as pass web (80) and SSH port to a specific jail IP.
Enabling the Bridge: In FreeBSD, if_bridge is a kernel module which is automatically loaded by ifconfig when creating a bridge interface. It is also possible to compile bridge support into a custom kernel by adding device if_bridge to the custom kernel configuration file. The bridge is created using interface cloning. To create the bridge interface:
# ifconfig bridge create bridge0 # ifconfig bridge0
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500 ether 96:3d:4b:f1:79:7a id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200 root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0
When a bridge interface is created, it is automatically assigned a randomly generated Ethernet address. The maxaddr and timeout parameters control how many MAC addresses the bridge will keep in its forwarding table and how many seconds before each entry is removed after it is last seen. The other parameters control how STP operates.
Next, specify which network interfaces to add as members of the bridge. For the bridge to forward packets, all member interfaces and the bridge need to be up:
# ifconfig bridge0 addm fxp0 addm fxp1 up # ifconfig fxp0 up # ifconfig fxp1 up
The bridge can now forward Ethernet frames between fxp0 and fxp1. Add the following lines to /etc/rc.conf so the bridge is created at startup:
cloned_interfaces="bridge0" ifconfig_bridge0="addm fxp0 addm fxp1 up" ifconfig_fxp0="up" ifconfig_fxp1="up"
If the bridge host needs an IP address, set it on the bridge interface, not on the member interfaces. The address can be set statically or via DHCP. This example sets a static IP address:
# ifconfig bridge0 inet 192.168.0.1/24
It is also possible to assign an IPv6 address to a bridge interface. To make the changes permanent, add the addressing information to /etc/rc.conf.
These are some of the applications of cloned_interfaces!!
More: 1, 2, 3, 4
cloned_interfacesis just shorthand forifconfig ... createand implemented in/etc/network.subr? Are you asking why you need to callifconfig ... create?network.subr, or one of the scripts under/etc/rc.d. It was a process of elimination with some help fromgrep.