Last week I made a documentational post about setting up a hypervisor at OVH and how to properly configure a Debian VPS to work with their network. Now it’s time to install a more exotic operating system, FreeBSD. That’s right folks, this isn’t exclusively a Linux show.
If you haven’t already, check out the post from last week. More specifically, the parts about how to create and configure the VM. That stuff is all the same so I’m not going to go over it again. Also, if you don’t have a hypervisor yet, that post explains how to get that set up too. I’ll briefly cover the OS installation, but the focus of this post is the post-install network configuration.
If you’re not comfortable with the FreeBSD installation process, it’s pretty straightforward, but a bit different from most Linux installers, so install it a few times on VirtualBox at home to get yourself warmed up before you do it for real. Similarly to with Debian, skip the network configuration if you’re not using the temporary NAT interface or only configure the NAT interface if you are using it. Alright, without further ado, “How to configure OVH networking on FreeBSD VMs”.
The first thing to do is identify our network cards. If the OVH card is the only one in your machine, it’s probably
vtnet0, but there is actually a lot more variation here than there is on Linux, so it’s even more important to double check in this case. The command you want to run to find out about the network interfaces here is simply
ifconfig and we’re interested again in the interface that has the OVH assigned MAC address on it. This probably starts with
02: and if you have a NAT card it’s MAC probably starts with
52:, so that’s a good starting point. If the output of
ifconfig looks like Japanese to you, the image below should show you what you’re looking for.
Now we’re going to take a look at
/etc/rc.conf. This file is responsible for a lot of things in FreeBSD, one of which is networking. It should look something like this.
You can see in my
/etc/rc.conf I have a line about DHCP on the NAT interface. That’s because I set it up that way during the installation, but we want to disable that interface now, so I’ll just delete that line. In it’s place, we’ll put in the OVH configuration, which looks something like this.
# Static Routing Order
# OVH IPv4
ifconfig_<INTERFACE>="inet <VM IP> netmask 255.255.255.255 broadcast <VM IP>"
route_ovhgw="-net <GATEWAY IP> <VM IP>"
route_ovhint="default <GATEWAY IP>"
<VM IP> obviously should be replaced with your VM’s IP address and
<INTERFACE> should be the name of the interface we found earlier. But wait, what is the
<GATEWAY IP>? Well, it’s actually quite simple. Use the first three octets of the hypervisor’s public IP address with the fourth octet being
254. For example, if your hypervisor’s IP address is
<GATEWAY IP> is
126.96.36.199. Note that the first three octets need to be from the hypervisor’s IP, NOT the failover IP you’re using for the guest. For example, if your failover IP is
<GATEWAY IP> is not
188.8.131.52, and that won’t work. Also note that I put the
static_routes option in it’s own block above the rest of the configuration. This is because the last
static_routes in your config is the one that will be used, so if you have multiple interfaces with their own static routing, you will have to make sure to have all of them ordered properly on one line. This isn’t too important for now, but it might come in handy later. Additionally, the line beginning with
ifconfig is very long. If you like, you can put a linebreak in place of any of the spaces and it won’t hurt anything as long as the quotes are still in the right place. At the end your
/etc/rc.conf should look something like this.
Now reboot the machine. Simply restarting the networking system will do the trick too, but rebooting is the safest bet to make sure the old routing tables and caches get cleared properly. Now we should be online, so let’s ping Google’s DNS server at
184.108.40.206 to confirm.
Awesome! We’re online. Now we just have to do one more thing before we’re ready to go. Similarly to Linux, name resolution in FreeBSD is handled by
/etc/resolv.conf, which should contain only two lines. Set them to your favourite DNS servers (I used Google Public DNS) and delete any extras.
Go ahead and send a ping test to
google.com to make sure that your name resolution is working correctly and you should be good to go. You’re free to set up your FreeBSD VPS however you like it. 🙂