# HOWTO: Setting up FreeBSD 13 on a IONOS VPS Server



## subnetspider (Mar 13, 2022)

This Post was inspired by Thread point-to-point-connection-32-network.82257 and Adding a Public IPv4 and IPv6 Address to a Linux Server (Ubuntu and Debian).

Hello everyone,

in this guide, I want to show you how I have set up the network and installed the VMware tools on my FreeBSD 13 VPS server hosted by IONOS.
Since I've only worked with IONOS so far, I don't know if these instructions can also be used with other VPS providers.
I'm in no way a FreeBSD or network expert, if there are any errors or possible improvements, feel free to let me know. 

Prerequisites

I am assuming that FreeBSD is already installed on the VPS Server and that you have access to the root shell via the KVM Console.
I am assuming that local-unbound(8) is used as the DNS resolver and was selected at "System configuration" during the installation.
If not, set one or more public DNS servers in /etc/resolv.conf (see resolv.conf(5) for details).

I am assuming that during the installation, no IPv4 or IPv6 configuration was made.
If so, remove the entries for networking in /etc/resolv.conf.

I will be using the vi(1) text editor since it comes pre-installed, feel free to install and use any other text editor as soon as the Internet connection is working.
Setting up Networking​Setting up a working internet connection on a IONOS VPS server can be a bit tricky, since we have to work with a static /32 IPv4 and a /128 IPv6 address on our host.
This is done in part to increase security by prohibiting direct communication with other VPS servers hosted in the same datacenter network.
IONIS uses the IP addresses *10.255.255.1* as the IPv4 gateway and *fe80::1* as the IPv6 gateway. The network interface of the VM is *vmx0*.

FreeBSD networking​The settings we need to set are held in the configuration file rc.conf(5).
All changes to the network have to be saved in this file or they will be lost when the host is rebooted.

IPv4 Networking​Run the following command to edit the file rc.conf:

`# vi /etc/rc.conf`

Switch to Insert mode to insert the following lines with `Esc` and `i`:

```
ifconfig_vmx0="inet 212.227.xxx.xxx netmask 255.255.255.255"
defaultrouter="10.255.255.1"
static_routes="wan"
route_wan="-host 10.255.255.1 -iface vmx0"
```


The first entry tells the system to assign the IPv4 address *212.227.xxx.xxx/32* to the Interface *vmx0*.
Replace *212.227.xxx.xxx* with the IPv4 address assigned to you and the interface name *vmx0* if needed.

The second entry sets the address *10.255.255.1* of the default gateway.
The third entry creates a route with the name *wan*, other names can used aswell.
The fourth entry *route_wan* sets the destination to *10.255.255.1* via the interface *vmx0*
You can replace *route_wan* with route__<route name>_ you've set in static_routes="_<route name>_" (see route(8) for more information).


IPv6 Networking​Next, insert the following lines for setting up IPv6:

```
ifconfig_vmx0_ipv6="2001:ba0:xxxx:xxxx::1/128"
ipv6_defaultrouter="fe80::1%vmx0"
```


The first entry tells the system to assign the IPv6 address *2001:ba0:xxxx:xxxx::1/128* to the interface *vmx0*.
Replace *2001:ba0:xxxx:xxxx::1* with the IPv6 address assigned to you and the interface name *vmx0* if needed.

The second entry sets the address *fe80::1* of the default gateway on the interface *vmx0*.
In FreeBSD, every interface automatically gets assigned a link local IPv6 address in the fe80::/10 range.
If we don't specify the interface where the IPv6 default gateway should connect, FreeBSD might assign it to the loopback interface *lo0* and routing will not be possible.

Save and quit with `Esc` and `:wq`, then press `Enter` to confirm.

Testing​To see if everything worked, we can use ping(8) to ping FreeBSD.org (for example).

If we run `# ping -4 -c 3 freebsd.org`, we should get something like this:

```
PING freebsd.org (96.47.72.84): 56 data bytes
64 bytes from 96.47.72.84: icmp_seq=0 ttl=49 time=105.049 ms
64 bytes from 96.47.72.84: icmp_seq=1 ttl=49 time=104.598 ms
64 bytes from 96.47.72.84: icmp_seq=2 ttl=49 time=104.672 ms
```

If we run `# ping -6 -c 3 freebsd.org`, we should get something like this:

```
PING6(56=40+8+8 bytes) 2001:ba0:xxxx:xxxx::1 --> 2610:1c1:1:606c::50:15
16 bytes from 2610:1c1:1:606c::50:15, icmp_seq=0 hlim=49 time=106.029 ms
16 bytes from 2610:1c1:1:606c::50:15, icmp_seq=1 hlim=49 time=106.005 ms
16 bytes from 2610:1c1:1:606c::50:15, icmp_seq=2 hlim=49 time=105.858 ms
```

If there are any errors, check if your settings in /etc/rc.conf and /etc/resolv.conf are correct and/or local-unbound is running.

Installing VMware Tools​IONOS use VMware vSphere as their hypervisor, for improved resource monitoring and other VM improvements it is recommended to install VM Guest tools.
I will be using emulators/open-vm-tools-nox11 in this guide (see https://kb.vmware.com/s/article/2149806 for more information).

Bootstrap pkg​To install packages, we must first bootstrap pkg(8):

`# pkg bootstrap`

... and update the repository catalog:

`# pkg update -f`

Installation​Next we install the package with the following command:

`# pkg install -y open-vm-tools-nox11`

Enable at startup​After the installation, we get promted to load the fusefs(5) kernel module, so lets add an entry to /boot/loader.conf:

`# vi /boot/loader.conf`

Switch to Insert mode to insert the following line with `Esc` and `i`:

```
fusefs_load="YES"
```

Save and quit with `Esc` and `:wq`, then press `Enter` to confirm.

To automatically start the VM guest tools at boot, we have to add the following line to /etc/rc.conf: `vi /etc/rc.conf`

Switch to Insert mode to insert the following line with `Esc` and `i`:

```
vmware_guestd_enable="YES"
```

Save and quit with `Esc` and `:wq`, then press `Enter` to confirm.

To make shure the VM guest tools can communicate with the VMware hypervisor, we need to shut down (not reboot) the VM:

`# poweroff`

If we start the VM again, we should now be able to ssh into it, download and install other packages etc.

To see if the VM guest tools are running, we can run the following command:

`# ps aux | grep vmware | grep -v grep`

The output should look something like this:

```
root    70538   0.0  1.0  22404   4984  -  S    16:14      0:45.89 /usr/local/bin/vmtoolsd -c /usr/local/share/vmware-tools/tools.conf -p /usr/local/lib/open-vm-tools/plugins/vmsvc
```

Example rc.conf​

```
# Host
clear_tmp_enable="YES"
syslogd_flags="-ss"
sendmail_enable="NONE"
hostname="xxxxxxx.online-server.cloud"
keymap="de.kbd"

# IPv4 Network
ifconfig_vmx0="inet 212.227.xxxx.xxxx netmask 255.255.255.225"
defaultrouter="10.255.255.1"
static_routes="wan"
route_wan="-host 10.255.255.1 -iface vmx0"

# IPv6 Network
ifconfig_vmx0_ipv6="2001:ba0:xxxx:xxxx::1/128"
ipv6_defaultrouter="fe80::1%vmx0"

# Services
local_unbound_enable="YES"
sshd_enable="YES"
ntpd_enable="YES"
vmware_guest_enable="YES"

# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
```

Summing up​We should now have:

Working IPv4 Internet connection
Working IPv6 Internet connection
VM guest tools installed and working
I wrote this guide because it took me the better part of two days to figure out how to get Internet working on my FreeBSD VM.
I hope someone else finds this useful.


----------



## Async (Jul 1, 2022)

Hey! Thanks for this guide!

I followed it but got a little problem.

I have working network on my VPS, but I can't reach it from the outside. No ping, no ssh.


```
7  ae-14.bb-b.fr7.fra.de.net.ionos.com (212.227.120.149)  21.002 ms
    ae-9.bb-b.bs.kae.de.net.ionos.com (212.227.120.168)  20.761 ms  20.567 ms
 8  ae-9.bb-b.bs.kae.de.net.ionos.com (212.227.120.168)  21.146 ms
    port-channel-3.de-rhr-bangdsr02.oneandone.net (212.227.121.10)  21.903 ms  20.757 ms
 9  212.227.218.246 (212.227.218.246)  22.070 ms  22.480 ms  23.401 ms
10  212.227.218.246 (212.227.218.246)  22.501 ms *  22.679 ms
11  * * *
12  * * *
13  * * *
```

Traceroute hits ionos but stops on one if it's servers.
Do you have an Idea what went wrong?
My rc.conf looks like yours, except a missing IPv6. (I got no IPv6 address from IONOS for my VPS.)

EDIT:
The Netmask has to be 255.255.255.0 (correct?)
I completely overlooked that.


----------



## subnetspider (Jul 3, 2022)

Async said:


> I have working network on my VPS, but I can't reach it from the outside. No ping, no ssh.


Have you opened the ports in the IONOS Firewall?
If I remember correctly, SSH (port 22) should be enabled by default?


Async said:


> My rc.conf looks like yours, except a missing IPv6. (I got no IPv6 address from IONOS for my VPS.)


I think I manually added a IPv6 address to my VPS 3-4 months ago.


Async said:


> The Netmask has to be 255.255.255.0 (correct?)


I needed to use a 255.255.255.255 Netmask (or /32) to get networking to work, at least IONOS does it like this.


----------

