Question

Best way no rename an interface ?

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.

ifconfig_vtnet0_name=“wan”

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 ?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

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.

ifconfig_vtnet0_name=“wan” ifconfig_wan_alias0=“description Wide_Area_Network” ifconfig_wan=“inet XX.XX.XX.XX netmask 255.255.255.0” ifconfig_wan_alias0=“inet XX.XX.X.X netmask 255.255.0.0”

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

/usr/local/etc/rc.d/digitalocean

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.

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. https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting

And this looks useful too. http://cloudinit.readthedocs.io/en/latest/topics/boot.html

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

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.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel