@@ -3,34 +3,47 @@
33# client on the inside network, a server on the outside network, and a
44# router connected to both that performs Network Address Translation
55# for the client.
6−import ./make-test.nix ({ pkgs, withFirewall, ... }:
6+import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, ... }:
77 let
88 unit = if withFirewall then "firewall" else "nat";
99 in
1010 {
11− name = "nat${if withFirewall then "WithFirewall" else "Standalone"}";
12− meta = with pkgs.stdenv.lib.maintainers; {
11+ name = "nat" + (if withFirewall then "WithFirewall" else "Standalone")
12+ + (lib.optionalString withConntrackHelpers "withConntrackHelpers");
13+ meta = with pkgs.stdenv.lib.maintainers; {
1314 maintainers = [ eelco chaoflow rob wkennington ];
1415 };
1516
1617 nodes =
1718 { client =
1819 { config, pkgs, nodes, ... }:
19− { virtualisation.vlans = [ 1 ];
20− networking.firewall.allowPing = true;
21− networking.defaultGateway =
22− (pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ip4).address;
23− };
20+ lib.mkMerge [
21+ { virtualisation.vlans = [ 1 ];
22+ networking.firewall.allowPing = true;
23+ networking.defaultGateway =
24+ (pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ip4).address;
25+ }
26+ (lib.optionalAttrs withConntrackHelpers {
27+ networking.firewall.connectionTrackingModules = [ "ftp" ];
28+ networking.firewall.autoLoadConntrackHelpers = true;
29+ })
30+ ];
2431
2532 router =
2633 { config, pkgs, ... }:
27− { virtualisation.vlans = [ 2 1 ];
28− networking.firewall.enable = withFirewall;
29− networking.firewall.allowPing = true;
30− networking.nat.enable = true;
31− networking.nat.internalIPs = [ "192.168.1.0/24" ];
32− networking.nat.externalInterface = "eth1";
33− };
34+ lib.mkMerge [
35+ { virtualisation.vlans = [ 2 1 ];
36+ networking.firewall.enable = withFirewall;
37+ networking.firewall.allowPing = true;
38+ networking.nat.enable = true;
39+ networking.nat.internalIPs = [ "192.168.1.0/24" ];
40+ networking.nat.externalInterface = "eth1";
41+ }
42+ (lib.optionalAttrs withConntrackHelpers {
43+ networking.firewall.connectionTrackingModules = [ "ftp" ];
44+ networking.firewall.autoLoadConntrackHelpers = true;
45+ })
46+ ];
3447
3548 server =
3649 { config, pkgs, ... }:
@@ -66,7 +79,8 @@ import ./make-test.nix ({ pkgs, withFirewall, ... }:
6679 $client->succeed("curl -v ftp://server/foo.txt >&2");
6780
6881 # Test whether active FTP works.
69− $client->succeed("curl -v -P - ftp://server/foo.txt >&2");
82+ $client->${if withConntrackHelpers then "succeed" else "fail"}(
83+ "curl -v -P - ftp://server/foo.txt >&2");
7084
7185 # Test ICMP.
7286 $client->succeed("ping -c 1 router >&2");