-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate network-setup to nftables and improve it into a better state #4877
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: kanpov <[email protected]>
Signed-off-by: kanpov <[email protected]>
Signed-off-by: kanpov <[email protected]>
Signed-off-by: kanpov <[email protected]>
I'm welcome to critique of the new sections in the doc, since I think this is the real minimal amount of information needed for a Firecracker user to get a proper networking setup with support for multiple guests and other improvements. Back when I started working with Firecracker, I found this specific area of the docs to be especially frustrating to use (and led to me spending far, far too much of my time developing fcnet to make networking bearable):
With this, I've tried to address these. |
Signed-off-by: kanpov <[email protected]>
Signed-off-by: kanpov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I need to try the commands myself, but looks good so far.
I have a couple of asks: could we squash the commits together? I think it becomes easier to review. And we would like to keep the iptables
commands for some time until nft
becomes more spread.
_Advanced:_ If you created a bridge interface, delete it using the following: | ||
```bash | ||
sudo ip link del br0 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could move to the bridge section below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unchanged from the current version, but sure.
|
||
Set IPv4 forwarding back to disabled: | ||
```bash | ||
sudo sh -c "echo 0 > /proc/sys/net/ipv4/ip_forward" # usually the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo 0 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo nft delete table firecracker | ||
``` | ||
|
||
## Advanced: Multiple guests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to add another section for multiple guests with namespaces (and restored from snapshots). Could this just reference docs/snapshotting/network-for-clones.md
as they will be very similar?
Substituting our values, we get: `ip=172.16.0.2::172.16.0.1:255.255.255.252::eth0:off`. Insert this | ||
at the end of your boot arguments for your microVM, and the guest Linux kernel will automatically | ||
perform the routing configuration done in the _In the Guest_ section without needing `iproute2` | ||
installed in the guest. (This argument doesn't configure DNS, however). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually one can configure DNS with it in an additional parameter https://www.kernel.org/doc/html/v6.1/admin-guide/nfs/nfsroot.html?highlight=ip=
This should work ip=172.16.0.2::172.16.0.1:255.255.255.252::eth0:off:8.8.8.8
|
||
If you don't have anything else using `iptables` on your machine, clean up those | ||
rules: | ||
## Advanced: Guest network configuration at kernel level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Advanced: Guest network configuration using kernel command line
The `nftables` Linux firewall with the `nft` command should be used instead of | ||
`iptables`, since `iptables` and the associated tools are | ||
[no longer recommended](https://access.redhat.com/solutions/6739041) for use on | ||
production Linux systems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most people are still more familiar with iptables than nftables. Can we can keep the equivalent iptables
commands with collapsible sections like so:
using iptables
iptables X Y Z
<details>
<summary>using iptables</summary>
<code>iptables X Y Z</code>
</details>
I'll apply the squash and, as for iptables, I like your idea for collapsible blocks as opt-in for using it. Iptables, however, is most certainly no longer the default and, even when it's used, it's used only through the iptables-nft compat layer which is already itself deprecated on some distros (including RHEL). So I'll do a collapsible choice between iptables-nft and just nft. |
Changes
network-for-clones is not changed in this PR since it's a whole another can of worms I'd like to deal with later.
These changes are to network-setup:
Migrate to nftables
Improve the documentation itself to convert it from a rather basic getting started guide to something more usable in the real world:
Multiple guests section
Guest kernel configuration at kernel level section (
ip
kernel boot arg)Reason
Fulfills #4874
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md
.PR Checklist
PR.
CHANGELOG.md
.TODO
s link to an issue.contribution quality standards.
rust-vmm
.