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 ?
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!
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.
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
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.
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Sign up now
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.