news
Serverspace has added a new Rocky Linux OS
WB
William Bell
February 11, 2020
Updated June 7, 2023

Configuring network adapter in FreeBSD

FreeBSD Networks VPS

Using another OS?

Select the desired version or distribution.

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<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:

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:

The local IP value can be found in the control panel

 

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.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 4
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.