Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/nightshift/vm/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@ async def create_tap(vm_id: str) -> TapConfig:
tap_name = f"tap-{vm_id[:8]}"
host_ip = f"172.16.{vm_index}.1"
guest_ip = f"172.16.{vm_index}.2"
mask = "255.255.255.252" # /30 in dotted decimal for kernel ip= boot arg
# Keep dotted netmask for Firecracker kernel boot arg ip=... (see vm/manager.py).
mask = "255.255.255.252"
# iproute2 expects prefix length notation, not dotted netmask.
prefix_len = "30"

# Create TAP device
await _run(f"ip tuntap add dev {tap_name} mode tap")
await _run(f"ip addr add {host_ip}/{mask} dev {tap_name}")
await _run(f"ip addr add {host_ip}/{prefix_len} dev {tap_name}")
await _run(f"ip link set {tap_name} up")

# Enable IP forwarding
Expand Down