Created
October 3, 2015 23:26
-
-
Save cleverca22/99571cb7ae6b88e86339 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ system ? builtins.currentSystem }: | |
let | |
configuration = { config, pkgs, ...}: { | |
imports = [ | |
<nixos/modules/virtualisation/qemu-vm.nix> | |
./configuration.nix | |
]; | |
config = { | |
virtualisation = { | |
graphics = false; | |
qemu.networkingOptions = [ | |
"-net nic,vlan=0,model=virtio" "-net socket,vlan=0,connect=127.0.0.1:5002" | |
]; | |
}; | |
users.extraUsers.root.password = "root"; | |
networking.hostName = "lan1"; | |
}; | |
}; | |
eval = import <nixos/lib/eval-config.nix> { | |
inherit system; | |
modules = [ configuration ]; | |
}; | |
in | |
{ | |
raw = eval; | |
vm = eval.config.system.build.vm; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ system ? builtins.currentSystem }: | |
let | |
configuration = { config, pkgs, ...}: { | |
imports = [ <nixos/modules/virtualisation/qemu-vm.nix> ]; | |
config = { | |
virtualisation = { | |
graphics = false; | |
qemu.networkingOptions = [ | |
"-net nic,vlan=0,model=virtio" "-net user,vlan=0" | |
"-net nic,vlan=1,model=virtio" "-net socket,vlan=1,listen=0.0.0.0:5001" "-net dump,vlan=1,file=/home/clever/router/modem/1q.cap" | |
]; | |
}; | |
services = { | |
dhcpd = { | |
interfaces = [ "eth1.34" "eth1.35" ]; | |
enable = true; | |
extraConfig = '' | |
subnet 10.0.0.0 netmask 255.255.255.0 { | |
range 10.0.0.100 10.0.0.200; | |
} | |
subnet 192.168.100.0 netmask 255.255.255.0 { | |
range 192.168.100.100 192.168.100.200; | |
} | |
''; | |
}; | |
}; | |
networking = { | |
enableIPv6 = false; | |
hostName = "modem"; | |
firewall.enable = false; | |
interfaces = { | |
eth1.useDHCP = false; | |
"eth1.34" = { | |
ipAddress = "10.0.0.1"; | |
prefixLength = 24; | |
}; | |
"eth1.35" = { | |
ipAddress = "192.168.100.1"; | |
prefixLength = 24; | |
}; | |
}; | |
}; | |
boot.kernelModules = [ "8021q" ]; | |
users.extraUsers.root.password = "root"; | |
environment.systemPackages = with pkgs; [ vlan nmap tcpdump ]; | |
systemd.services = { | |
network-local-commands.path = with pkgs; [ iproute vlan ]; | |
network-vlans = { | |
description = "network vlan-start"; | |
before = [ "network-pre.target" ]; | |
wantedBy = [ "network-pre.target" ]; | |
unitConfig.ConditionCapability = "CAP_NET_ADMIN"; | |
serviceConfig.Type = "oneshot"; | |
serviceConfig.RemainAfterExit = true; | |
path = [ pkgs.vlan pkgs.iproute ]; | |
script = '' | |
vconfig add eth1 34 | |
vconfig add eth1 35 | |
ip link set eth1 up | |
''; | |
}; | |
}; | |
}; | |
}; | |
eval = import <nixos/lib/eval-config.nix> { | |
inherit system; | |
modules = [ configuration ]; | |
}; | |
in | |
{ | |
raw = eval; | |
vm = eval.config.system.build.vm; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ system ? builtins.currentSystem }: | |
let | |
configuration = { config, pkgs, ...}: { | |
imports = [ | |
<nixos/modules/virtualisation/qemu-vm.nix> | |
../nixcfg/router.nix | |
]; | |
config = { | |
virtualisation = { | |
graphics = false; | |
qemu.networkingOptions = [ | |
"-net nic,vlan=0,model=virtio" "-net socket,vlan=0,connect=127.0.0.1:5001" "-net dump,vlan=0,file=/home/clever/router/router/1q.cap" | |
"-net nic,vlan=1,model=virtio" "-net socket,vlan=1,listen=0.0.0.0:5002" | |
]; | |
}; | |
users.extraUsers.root.password = "root"; | |
networking.hostName = "router"; | |
}; | |
}; | |
eval = import <nixos/lib/eval-config.nix> { | |
inherit system; | |
modules = [ configuration ]; | |
}; | |
in | |
{ | |
raw = eval; | |
vm = eval.config.system.build.vm; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment