diff options
author | lassulus <lass@lassul.us> | 2016-12-26 13:29:39 +0100 |
---|---|---|
committer | lassulus <lass@lassul.us> | 2016-12-26 13:29:39 +0100 |
commit | 205d0f0d21c0f62aac0590873a6741415f9416fa (patch) | |
tree | ebef9970264b1bf40b04e966d67e5987cbb6ef9a /lass/2configs/libvirt.nix | |
parent | 512f90d10096e81180730374d5d9664384894807 (diff) |
l 2 libvirt: add iptables config for NAT
Diffstat (limited to 'lass/2configs/libvirt.nix')
-rw-r--r-- | lass/2configs/libvirt.nix | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lass/2configs/libvirt.nix b/lass/2configs/libvirt.nix index 8c095bb01..a71638323 100644 --- a/lass/2configs/libvirt.nix +++ b/lass/2configs/libvirt.nix @@ -4,4 +4,27 @@ users.users.mainUser.extraGroups = [ "libvirtd" ]; virtualisation.libvirtd.enable = true; + krebs.iptables.tables.filter.INPUT.rules = [ + { v6 = false; predicate = "-i virbr0 -p udp -m udp --dport 53"; target = "ACCEPT"; } + { v6 = false; predicate = "-i virbr0 -p tcp -m tcp --dport 53"; target = "ACCEPT"; } + { v6 = false; predicate = "-i virbr0 -p udp -m udp --dport 67"; target = "ACCEPT"; } + { v6 = false; predicate = "-i virbr0 -p tcp -m tcp --dport 67"; target = "ACCEPT"; } + ]; + krebs.iptables.tables.filter.FORWARD.rules = [ + { v6 = false; predicate = "-d 192.168.122.0/24 -o virbr0 -m conntrack --ctstate RELATED,ESTABLISHED"; target = "ACCEPT"; } + { v6 = false; predicate = "-s 192.168.122.0/24 -i virbr0"; target = "ACCEPT"; } + { v6 = false; predicate = "-i virbr0 -o virbr0"; target = "ACCEPT"; } + { v6 = false; predicate = "-o virbr0"; target = "REJECT --reject-with icmp-port-unreachable"; } + { v6 = false; predicate = "-i virbr0"; target = "REJECT --reject-with icmp-port-unreachable"; } + ]; + krebs.iptables.tables.filter.OUTPUT.rules = [ + { v6 = false; predicate = "-o virbr0 -p udp -m udp --dport 68"; target = "ACCEPT"; } + ]; + krebs.iptables.tables.nat.POSTROUTING.rules = [ + { v6 = false; predicate = "-s 192.168.122.0/24 -d 224.0.0.0/24"; target = "RETURN"; } + { v6 = false; predicate = "-s 192.168.122.0/24 -d 255.255.255.255"; target = "RETURN"; } + { v6 = false; predicate = "-s 192.168.122.0/24 ! -d 192.168.122.0/24"; target = "MASQUERADE"; } + { v6 = false; predicate = "-s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp"; target = "MASQUERADE --to-ports 1024-65535"; } + { v6 = false; predicate = "-s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp"; target = "MASQUERADE --to-ports 1024-65535"; } + ]; } |