Getting Started Firecracker Network Setup
This is a very simple quick-start guide to getting a Firecracker guest connected to the network. If you're using Firecracker in production, or even want to run multiple guests, you'll need to adapt this setup.
The simple steps in this guide assume that your internet-facing interface is eth0, you have nothing else using tap0 and no other iptables rules. Check out the Advanced: sections if that doesn't work for you.
On The Host
The first step on the host is to create a tap device:
Then you have a few options for routing traffic out of the tap device, through your host's network interface. One option is NAT, set up like this:
Advanced: If you are running multiple Firecracker MicroVMs in parallel, or have something else on your system using tap0 then you need to create a tap for each one, with a unique name.
Advanced: You also need to do the iptables set up for each new tap. If you have iptables rules you care about on your host, you may want to save those rules before starting.
Setting Up Firecracker
Before starting the guest, configure the network interface using Firecracker's API:
If you are using a configuration file instead of the API, add a section to your configuration file like this:
Alternatively, if you are using firectl, add --tap-device=tap0/AA:FC:00:00:00:01` to your command line.
In The Guest
Once you have booted the guest, bring up networking within the guest:
Now your guest should be able to route traffic to the internet (assuming that your host can get to the internet). To do anything useful, you probably want to resolve DNS names. In production, you'd want to use the right DNS server for your environment. For testing, you can add a public DNS server to /etc/resolv.conf by adding a line like this:
Cleaning up
The first step to cleaning up is deleting the tap device:
If you don't have anything else using iptables on your machine, clean up those rules:
If you have an existing iptables setup, you'll want to be more careful about cleaning up.
Advanced: If you saved your iptables rules in the first step, then you can restore them like this: