Configuring network adapter in FreeBSD
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:
flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=60039b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,TSO6,RXCSUM_IPV6,TXCSUM_IPV6>
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<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
vmx1:
flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=60039b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,TSO6,RXCSUM_IPV6,TXCSUM_IPV6>
ether 00:50:56:02:0c:98
media: Ethernet autoselect
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0:
flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet 127.0.0.1 netmask 0xff000000
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
The output of the command shows, that the vmx0 interface is configured and ready (<up,broadcast,running,simplex,multicast>), 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:
Add the command line with correct parameters:
For example:
The local IP value can be found in the control panel, Networks section:
Sample of the file contents: /etc/rc.conf.
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:
For example:
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.