* Use the NAT module. * Create a hosts file for dnsmasq to ensure that dnsmasq returns hostnames for machines that are down (usually it only allows looking up the name of machines that have an active DHCP lease).
* Use the NAT module. * Create a hosts file for dnsmasq to ensure that dnsmasq returns hostnames for machines that are down (usually it only allows looking up the name of machines that have an active DHCP lease). svn path=/configurations/trunk/tud/; revision=26250
Eelco Dolstra committed
Mar 10, 2011 at 13:37 UTC
a65f9f8c74b7a5a313df220dcbc34dab66597ef3
1 file changed
+30
-32
cartman.nix
+30
-32
@@ -89,29 +89,17 @@ rec {
89
firewall.allowedUDPPorts = [ 53 67 ];
90
firewall.rejectPackets = true;
91
firewall.allowPing = true;
92
+
93
+ nat.enable = true;
94
+ nat.internalIPs = "192.168.1.0/24";
95
+ nat.externalInterface = "eth1";
96
+ nat.externalIP = myIP;
97
98
localCommands =
99
''
95
- # Provide NATting for the build machines on 192.168.1.*.
96
- # Obviously, this should be something that NixOS provides.
97
- export PATH=${pkgs.iptables}/sbin:$PATH
98
-
99
- modprobe ip_tables
100
- modprobe ip_conntrack_ftp
101
- modprobe ip_nat_ftp
102
- modprobe ipt_LOG
103
- modprobe ip_nat
104
- modprobe xt_tcpudp
105
-
106
- iptables -t nat -F
107
- iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d 192.168.1.0/24 -j ACCEPT
108
- iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source ${myIP}
109
-
100
# lucifer ssh (to give Karl/Armijn access for the BAT project)
101
#iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 22222 -j DNAT --to 192.168.1.25:22
102
113
- echo 1 > /proc/sys/net/ipv4/ip_forward
114
-
103
# Set up a 6to4 tunnel for IPv6 connectivity.
104
105
# cleanup
@@ -516,24 +504,34 @@ rec {
504
# Needed for the Nixpkgs mirror script.
505
environment.pathsToLink = [ "/libexec" ];
506
507
+ environment.systemPackages = [ pkgs.dnsmasq ];
508
+
509
jobs.dnsmasq =
520
- let confFile = pkgs.writeText "dnsmasq.conf"
521
- ''
522
- keep-in-foreground
523
- expand-hosts
524
- domain=buildfarm
525
- interface=eth0
526
-
527
- server=130.161.158.4
528
- server=130.161.33.17
529
- server=130.161.180.1
510
+ let
511
+
512
+ confFile = pkgs.writeText "dnsmasq.conf"
513
+ ''
514
+ keep-in-foreground
515
+ no-hosts
516
+ addn-hosts=${hostsFile}
517
+ expand-hosts
518
+ domain=buildfarm
519
+ interface=eth0
520
+
521
+ server=130.161.158.4
522
+ server=130.161.33.17
523
+ server=130.161.180.1
524
+
525
+ dhcp-range=192.168.1.150,192.168.1.200
526
+
527
+ ${flip concatMapStrings machines (m: optionalString (m ? ethernetAddress) ''
528
+ dhcp-host=${m.ethernetAddress},${m.ipAddress},${m.hostName}
529
+ '')}
530
+ '';
531
531
- dhcp-range=192.168.1.150,192.168.1.200
532
+ hostsFile = pkgs.writeText "extra-hosts"
533
+ (flip concatMapStrings machines (m: "${m.ipAddress} ${m.hostName}\n"));
534
533
- ${flip concatMapStrings machines (m: optionalString (m ? ethernetAddress) ''
534
- dhcp-host=${m.ethernetAddress},${m.ipAddress},${m.hostName}
535
- '')}
536
- '';
535
in
536
{ startOn = "network-interfaces";
537
exec = "${pkgs.dnsmasq}/bin/dnsmasq --conf-file=${confFile}";