diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2023-01-13 21:47:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-13 21:47:21 +0100 |
commit | e973da60cdd84e1de9a0e510c6fbe39849d443e1 (patch) | |
tree | 662411e212d17df18095707f146f723950d6e5e8 /nixos/modules/virtualisation | |
parent | eea5d792766e23b874811d88ef736a4a06f0682d (diff) | |
parent | b25e0e8ebcd90009462765bb8c49c337ba6af082 (diff) | |
download | nixpkgs-e973da60cdd84e1de9a0e510c6fbe39849d443e1.tar nixpkgs-e973da60cdd84e1de9a0e510c6fbe39849d443e1.tar.gz nixpkgs-e973da60cdd84e1de9a0e510c6fbe39849d443e1.tar.bz2 nixpkgs-e973da60cdd84e1de9a0e510c6fbe39849d443e1.tar.lz nixpkgs-e973da60cdd84e1de9a0e510c6fbe39849d443e1.tar.xz nixpkgs-e973da60cdd84e1de9a0e510c6fbe39849d443e1.tar.zst nixpkgs-e973da60cdd84e1de9a0e510c6fbe39849d443e1.zip |
Merge pull request #200225 from pacien/nixos-qemu-vm-restrictnetwork
nixos/qemu-vm: add option "restrictNetwork"
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r-- | nixos/modules/virtualisation/qemu-vm.nix | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 1b3c0e23f97..4520408ca33 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -528,6 +528,20 @@ in ''; }; + virtualisation.restrictNetwork = + mkOption { + type = types.bool; + default = false; + example = true; + description = + lib.mdDoc '' + If this option is enabled, the guest will be isolated, i.e. it will + not be able to contact the host and no guest IP packets will be + routed over the host to the outside. This option does not affect + any explicitly set forwarding rules. + ''; + }; + virtualisation.vlans = mkOption { type = types.listOf types.ints.unsigned; @@ -936,10 +950,11 @@ in else "'guestfwd=${proto}:${guest.address}:${toString guest.port}-" + "cmd:${pkgs.netcat}/bin/nc ${host.address} ${toString host.port}'," ); + restrictNetworkOption = lib.optionalString cfg.restrictNetwork "restrict=on,"; in [ "-net nic,netdev=user.0,model=virtio" - "-netdev user,id=user.0,${forwardingOptions}\"$QEMU_NET_OPTS\"" + "-netdev user,id=user.0,${forwardingOptions}${restrictNetworkOption}\"$QEMU_NET_OPTS\"" ]; # FIXME: Consolidate this one day. |