Okay, so, I’ve been messing around with Alpine Linux in CML2 lately, specifically trying to figure out how to add an interface. It’s not super straightforward, but I finally got it figured out, so I thought I’d share my experience here.
First things first, I booted up my Alpine Linux VM in CML2. I already had it installed, but if you don’t, there are a bunch of tutorials out there on how to do that. I won’t bore you with the details on that part.
Now, the thing about Alpine is that it’s pretty barebones. It’s great for keeping things lightweight, but it also means you have to do a lot of stuff manually. Adding an interface is one of those things.
I started by looking around online. Some folks mentioned hovering over the node in CML2 to get some info, and that actually helped a bit. It gave me some clues about editing the config, but it wasn’t a full solution.
Then I found this Alpine User Handbook thing. It had some installation instructions, but they were pretty general. Didn’t really address what I was trying to do.
Then I remembered a conversation we had in the Cisco Learning Network (CLN) a while back. Someone mentioned that you could add scripts to the Config tab of a device, and that gave me an idea.
So, here’s what I did. In the CML2 interface, I went to the Config tab for my Alpine node. There’s this field where you can put in shell commands, and it says that they get executed as root when the node starts up. This is based on how Alpine Linux works, apparently.
I did a little digging on how to configure network interfaces in Alpine, and it turns out you can do it through the /etc/network/interfaces
file. But I didn’t want to edit the file directly every time. So, I thought, why not just use shell commands to do it automatically?
Here’s the command I ended up using:
echo "auto eth1" >> /etc/network/interfaces
echo "iface eth1 inet dhcp" >> /etc/network/interfaces
ifup eth1
Let me break it down for you:
- The first line adds “auto eth1” to the interfaces file. This tells Alpine to automatically configure the interface named eth1.
- The second line adds “iface eth1 inet dhcp” to the file. This configures eth1 to use DHCP to get an IP address.
- The last line, “ifup eth1”, brings the interface up.
I pasted these commands into the Config tab of my Alpine node, saved the config, and then restarted the node. And guess what? It worked! My Alpine VM now had a new interface, eth1, configured with DHCP.
This is just a basic example, of course. You can modify these commands to configure static IP addresses, add more interfaces, or whatever you need. It took me a bit of trial and error, but I’m pretty happy with this solution. It’s a clean and easy way to add interfaces to an Alpine Linux VM in CML2.
Oh, and one more thing. I also saw something about bonding multiple interfaces together. That might be something to explore in the future, but for now, I’m just happy I got this basic setup working.
If anyone has a better way to do this, or any other tips on working with Alpine in CML2, I’m all ears. Always open to learning new tricks!