Configuring network adapter in FreeBSD

DP
Denis Pochtarenko
June 26, 2020

This guideline describes how to configure interfaces and connect virtual server, which operates under control of the FreeBSD operating system.

Configuring Interface

To display the configuration for the network interfaces on your system, enter the following command:

ifconfig

vmx0:
flags=8843 metric 0 mtu 1500
options=60039b
ether 00:50:56:02:0a:65
inet 45.XXX.XXX.XXX netmask 0xffffff00 broadcast 45.XXX.XXX.255
media: Ethernet autoselect
status: active
nd6 options=29
vmx1:
flags=8802 metric 0 mtu 1500
options=60039b
ether 00:50:56:02:0c:98
media: Ethernet autoselect
status: active
nd6 options=29
lo0:
flags=8049 metric 0 mtu 16384
options=680003
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet 127.0.0.1 netmask 0xff000000
groups: lo
nd6 options=21

The output of the command shows, that the vmx0 interface is configured and ready (), which means that you need to configure the em0 interface to work on a private network.

Note: The lo0 interface: The loopback device.

All following actions are performed in superuser mode.

Configuring a network connection without DHCP

Use a text editor such as vi to open the file /etc/rc.conf:

vi /etc/rc.conf

Add the command line with correct parameters:

ifconfig_<interface name>="inet <local IP> netmask <mask>"

For example:

ifconfig_em0="inet 10.0.1.2 netmask 255.255.255.0"

The local IP value can be found in the control panel, Networks section:

 

Sample of the file contents: /etc/rc.conf.

clear_tmp_enable="YES"
sshd_enable="YES"
ntpd_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
hostname="freebsd12"
ifconfig_vmx0="inet 45.XXX.XXX.XXX netmask 255.255.255.0"
ifconfig_em0="inet 10.0.1.2 netmask 255.255.255.0"
defaultrouter="45.XXX.XXX.1"

After making changes to the file, be sure to reboot the server using the OS to apply the new settings.

Configuring a network connection with DHCP

If the DHCP function has been enabled when creating a network, make sure Obtain an IP address automatically is selected. This can be done using the following command, specifying the interface name:

dhclient <interface>

For example:

dhclient vmx1

DHCPDISCOVER on vmx1 to 255.255.255.255 port 67 interval 7
DHCPOFFER from 10.0.1.1
DHCPREQUEST on vmx1 to 255.255.255.255 port 67
DHCPACK from 10.0.1.1
bound to 10.0.1.2 -- renewal in 3600 seconds.

Have questions before you deploy? Contact our Customer Success team to get answers.
We use cookies to provide our services and for analytics and marketing. To find out more about our use of cookies, please see our Privacy Policy. By continuing to browse our website, you agree to our use of cookies.