How To Setup A Static IP Address In FreeBSD

I have been using FreeBSD for a very long time, And there are some things that are quite different from Linux. When I set-up a static IP address in the latest releases of Ubuntu versions, I have to start dealing with netplan, With my experience across different Linux Distros, Some Linux networking differs across distros, So if you're looking to set up a static IP on your freeBSD server.

How To Setup A Static IP Address In FreeBSD

You will need to edit /etc/rc.conf.

vim /etc/rc.conf

You will see your network interface, it depends on how many network interface are connected to the server, and which of them you want to edit, You can make use of ifconfig command to see, which of the interface you want to edit.

In the /etc/rc.conf, You will something like this:

ifconfig_vmx0="DHCP"

You will need to remove the DHCP and add "inet 10.11.23.15 netmask 255.255.255.0", And also add defaultrouter="10.11.23.254" below.
Your configuration will look like this:

ifconfig_vmx0="inet 10.11.23.15 netmask 255.255.255.0"
defaultrouter="10.11.23.254"

inet: 10.11.23.15 – This is the static IP we want.
netmask: 255.255.255.0 – This is our network netmask
defaultrouter: 10.11.23.254 – This is our network gateway

Configure DNS Server On FreeBSD

You might need to add DNS Server. To add that edit:

vim /etc/resolv.conf

And add the following DNS record. I am using Google DNS Server, You can change to DNS Server of your choice.

nameserver 8.8.8.8

And save

Posted by Shehu Awwal

DevOps Engineer, Interests around Kubernetes, Infrastructure, Security & Automation.

Leave a Reply

Your email address will not be published. Required fields are marked *