File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed
Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -85,13 +85,12 @@ Or switch to qemu console with `Ctrl-a c` and type:
8585
8686## Port forwarding
8787
88- To forward ports from the virtual machine to the host, override the
89- ` virtualisation.qemu.networkingOptions ` NixOS option.
88+ To forward ports from the virtual machine to the host, use the
89+ ` virtualisation.forwardPorts ` NixOS option.
9090See ` examples/vm-forward.nix ` where the ssh server running on port 22 in the
9191virtual machine is made accessible through port 2222 on the host.
9292
93- If ` virtualisation.qemu.networkingOptions ` is not overridden the same can be
94- also achieved by using the ` QEMU_NET_OPTS ` environment variable.
93+ The same can be also achieved by using the ` QEMU_NET_OPTS ` environment variable.
9594
9695``` console
9796$ QEMU_NET_OPTS=" hostfwd=tcp::2222-:22" nixos-shell
Original file line number Diff line number Diff line change 11{ pkgs , ... } : {
22 services . openssh . enable = true ;
3- virtualisation . qemu . networkingOptions = [
4- # We need to re-define our usermode network driver
5- # since we are overriding the default value.
6- "-net nic,netdev=user.0,model=virtio"
7- # Than we can use qemu's hostfwd option to forward ports.
8- "-netdev user,id=user.0,hostfwd=tcp::2222-:22"
9- ] ;
3+ virtualisation = {
4+ forwardPorts = [
5+ { from = "host" ; host . port = 2222 ; guest . port = 22 ; }
6+ ] ;
7+ } ;
8+
109}
You can’t perform that action at this time.
0 commit comments