check the automatically assigned names to interfaces:

 

#ifconfig -l
ale0 re0 vr0 sk0 lo0

I’m going to change the name of “ale0” to “if1”, “re0” to “if2”, then assign the IP address and default gateway.
I will configure IP aliases (secondary IP addresses) as well.

# vi /etc/rc.conf

 

#change the interface name

ifconfig_ale0_name="if1"
ifconfig_re0_name="if2"

#assign ip to interface using new name

ifconfig_if1="192.168.1.1 netmask 255.255.255.0"
ifconfig_if2="192.168.1.1 netmask 255.255.255.0"

#assign secondary IP

ifconfig_if1_alias0="192.168.2.1 netmask 255.255.255.0"
ifconfig_if1_alias1="192.168.4.1 netmask 255.255.255.0"

#setting default Route
defaultrouter="192.168.1.254"

...
...
...
...

temporary route:

route add destination_network gateway

 

route add 192.168.10.0/24 192.168.100.1

permanent route:

# vi /etc/rc.conf

...
...
static_routes="mynet vpnnet"
route_mynet="-net 192.168.10.0/24 192.168.100.1"
route_vpnnet="-net 192.168.102.0/24 192.168.100.1"
...
...

By: Mehdi Sadighian
Contact: mehdi.sadighian@hotmail.com
TAG: FreeBSD, rc.conf, IP alias, secondary IP, change interface name, static route