feat: enhance networking capabilities with improved egress handling and automatic host sharing rules
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
`uvm` is a small, local Firecracker microVM command-line manager for Ubuntu.
|
||||
It creates one Firecracker process per VM, attaches it to a host TAP device,
|
||||
and keeps a private disk and local registry for named VMs. The CLI supports
|
||||
create, start, stop, restart, resize, delete, inspection, SSH, logs, diagnostics, and
|
||||
enforced private-IPv4 TCP port allowlists.
|
||||
create, start, stop, restart, resize, delete, inspection, SSH, logs, diagnostics,
|
||||
host-shared IPv4 internet access, and enforced private-IPv4 TCP port allowlists.
|
||||
|
||||
This directory is a self-contained project. All UVM code, tests, packaging
|
||||
metadata, launcher scripts, and documentation live here.
|
||||
@@ -255,7 +255,7 @@ well as new connections. This is packet dropping, not a guaranteed TCP RST or
|
||||
immediate application disconnect.
|
||||
|
||||
These rules govern access to the **guest private IP**. They do not start a
|
||||
guest service or provide public connectivity, host-port mappings, DNS,
|
||||
guest service or provide public inbound connectivity, host-port mappings, DNS publication,
|
||||
reverse proxies, or guest-service TLS. UDP and IPv6 service policies are not
|
||||
yet supported. Guest-initiated IPv4 TCP/UDP egress, its replies, and required
|
||||
ARP/ICMP traffic remain allowed; managed TAPs block IPv6.
|
||||
@@ -420,13 +420,33 @@ Bridge: uvm0
|
||||
TAPs: uvm-<unique suffix>
|
||||
```
|
||||
|
||||
It creates the bridge when absent, validates an existing bridge before using
|
||||
it, enables IPv4 forwarding, adds an egress masquerade rule, and adds matching
|
||||
forward rules for return traffic. Guest IPs, gateway, bridge name, and guest
|
||||
boot netmask derive from the configured CIDR.
|
||||
VMs share the host's IPv4 internet connection by default. When the host has
|
||||
internet access, guests can initiate outbound connections through it. When
|
||||
the host loses connectivity, guest internet access is lost too; the private
|
||||
VM network remains usable. Reconnecting the host restores guest egress.
|
||||
|
||||
The existing `iptables` egress NAT/forwarding behavior is unchanged. Private
|
||||
VM creation and start require an RFC 1918 subnet (`10.0.0.0/8`,
|
||||
UVM creates the bridge when absent, validates an existing bridge before using
|
||||
it, enables IPv4 forwarding, and installs subnet-scoped `iptables` masquerade
|
||||
and forward/return rules. These rules are installed even while the host is
|
||||
offline and follow its current routing table, so switching uplinks does not
|
||||
require restarting VMs. Existing connections may need application retries
|
||||
after an outage or upstream address change. Guest IPs, gateway, bridge name,
|
||||
and guest boot netmask derive from the configured CIDR.
|
||||
|
||||
Forwarding exceptions are inserted ahead of existing host-chain rules and
|
||||
allow guest-originated traffic and its replies. Masquerading excludes traffic
|
||||
back onto the UVM bridge, preserving private peer addresses.
|
||||
|
||||
To apply updated sharing rules to an existing running VM, use:
|
||||
|
||||
```sh
|
||||
sudo ./uvm.py start web
|
||||
```
|
||||
|
||||
On a running VM, `start` refreshes its private policy and shared host networking
|
||||
without rebooting it. New VM boots set up the same networking automatically.
|
||||
|
||||
Private VM creation and start require an RFC 1918 subnet (`10.0.0.0/8`,
|
||||
`172.16.0.0/12`, or `192.168.0.0/16`). Retained VMs prevent incompatible
|
||||
gateway, subnet, or bridge changes within the same registry. Private
|
||||
port enforcement uses separate per-VM native nftables `bridge` tables, not
|
||||
@@ -443,8 +463,9 @@ firewalld, Docker, or other external firewall managers remains deferred.
|
||||
Do not offload traffic around the software bridge hooks.
|
||||
|
||||
There is no autostart service or daemon reconciliation. After externally lost
|
||||
or changed UVM rules, inspect policy status and explicitly run `ports sync`.
|
||||
Read-only commands do not repair rules; sync does not boot stopped VMs.
|
||||
or changed private policy, inspect its status and explicitly run `ports sync`.
|
||||
Use `start` to restore shared bridge/NAT/forwarding rules as well. Read-only
|
||||
commands do not repair rules; port sync does not boot stopped VMs.
|
||||
|
||||
Use one authoritative registry per bridge/subnet. Independent `UVM_BASE`
|
||||
directories do not coordinate IP or MAC allocation with each other.
|
||||
@@ -568,8 +589,10 @@ UVM_FIREWALL_INTEGRATION=1 python3 -B -m unittest discover -s tests/integration
|
||||
|
||||
The packet test was skipped in this workspace because namespace creation was
|
||||
denied (`Operation not permitted`). A skip is not packet-path or real-host
|
||||
validation. The harness uses veths in place of TAPs and does not boot a real VM;
|
||||
validate KVM, TAP, NAT, SSH, and guest connectivity on an isolated Linux host.
|
||||
validation. The harness uses veths in place of TAPs and simulated upstream
|
||||
networks to check NAT, offline startup, reconnects, and uplink changes alongside
|
||||
private port policies. It does not boot a real VM; validate KVM, TAP, SSH, and
|
||||
guest connectivity on an isolated Linux host.
|
||||
|
||||
## Current Boundaries
|
||||
|
||||
|
||||
Reference in New Issue
Block a user