Best way no rename an interface ?

Posted September 4, 2017 3k views
DigitalOceanConfiguration ManagementFreeBSD

I usually like to rename my interfaces to names like wan, lan, dmz etc.

I usually do this by adding an entry to /etc/rc.conf such as the following.


This works find on my digital ocean machine and my interface is correctly renamed, however I lock myself out of the machine because of the custom digital ocean config entries that are appended to the end of the file which set the ip address etc. These entries are commented as “DigitalOcean Dynamic Configuration”.

Is there a preferred way to rename the interfaces that works safely with the dynamic config ?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

cloud-init seems to have quite a learning curve and since I am working with an existing droplet, I took what seemed like a much easier path.

I added to my /etc/rc.conf the lines to rename the interfece, but then also added the lines that DigitalOcean is adding, edited with the new if name so that I get the correct IP address etc. I ended up with the following lines added.

ifconfigwanalias0=“description WideAreaNetwork”
ifconfigwan=“inet XX.XX.XX.XX netmask”
wan_alias0=“inet XX.XX.X.X netmask”

DigitalOcean deletes are re-appends lines on each reboot, which I just ignore. Although they are now trying to assign an IP no a Interface (vtnet0) which does not exist, they seem to cause no problems or negative effects. Since the IP is static on the Droplet, it should be no problem.

If I do discover any subtle issues, I will modify their script to append them as commented lines.

The script that does the deleting/appending is


This script could be vastly better if they just edited their lines in place, maybe locating them by having the comment on the end of the line instead of the line above. If they did an in-place edit, I could simply have my interface rename at the end of the script which should be much cleaner.

When creating the droplet you get an option to add your preferred cloud-init field in it. I have never messed with those settings. So I don’t really know what things you can or can’t do in it.

Or you can have a firewall set up and NAT things in and out of your interfaces, if you intend on doing this on multiple droplets including your current one.

Thanks for the reply. I see that when creating a FreeBSD droplet, you can select “User Data” under
“Select additional options” to make a text box available for the entry of Couud-Init configuration.

I found this tutorial which gives a high level overview and a few examples.

And this looks useful too.

This looks like it has potential, I’ll learn more about this, thanks for making me aware of this.

by Justin Ellingwood
The DigitalOcean metadata service includes a field called "user-data", which can be used to specify a script that will be run as your server is brought online. The CloudInit program, which runs these scripts, can process a special script type called "cloud-config". In this guide, we'll explore how to create cloud-config files and the best ways to leverage their power.