minor fixes and dns
[automated-distro-installer] / wrt-setup-local
1 #!/bin/bash
2 # Copyright (C) 2016 Ian Kelling
3
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 set -eE -o pipefail
19 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
20
21
22 usage() {
23 cat <<EOF
24 usage: ${0##*/} [-h] [-t 2|3|test] [-m WIRELESS_MAC]
25 setup my router in general: dhcp, dns, etc.
26
27 Type 2 or 3 is for setting up a backup device, there are two kinds so
28 that you can switch the main device to a backup, then a backup to the
29 main. Type test is for setting up a testing device.
30
31 Passing an empty string for WIRELESS_MAC will cause the device's native
32 mac to be used.
33
34 EOF
35
36 exit $1
37 }
38
39
40
41
42 dnsmasq_restart=false
43 firewall_restart=false
44 dev2=false
45 test=false
46 libremanage_host=wrt2
47
48 secrets=false
49 if [[ -e /root/router-secrets ]]; then
50 secrets=true
51 source /root/router-secrets
52 fi
53 rmac=$(cat /sys/class/net/eth0/address)
54 if $secrets; then
55 hostname=${rhost[$rmac]}
56 fi
57 : ${hostname:=wrt}
58
59
60 lanip=1
61 while getopts hm:t: opt; do
62 case $opt in
63 h) usage ;;
64 t)
65 case $2 in
66 2|3)
67 dev2=true
68 libremanage_host=$hostname
69 ;;&
70 2)
71 lanip=4
72 hostname=wrt2
73 ;;
74 3)
75 lanip=14
76 hostname=wrt3
77 ;;
78 test)
79 test=true
80 ;;
81 *) echo "$0: unexpected arg to -t: $*" >&2; usage 1 ;;
82 esac
83 ;;
84 m) mac=$OPTARG ;;
85 *) echo "$0: Internal error! unexpected args: $*" >&2 ; usage 1 ;;
86 esac
87 done
88 shift "$((OPTIND-1))" # Discard the options and sentinel --
89
90 if [[ ! $mac ]] && ! $test && $secrets; then
91 # if we wanted to increment it
92 #mac=${mac:0: -1}$((${mac: -1} + 2))
93 mac=${rwmac[$rmac]}
94 fi
95
96 if (( $# != 0 )); then
97 usage 1
98 fi
99
100
101 macpre=${mac:0: -1}
102 macsuf=${mac: -1}
103
104
105 p_updated=false
106 pmirror() {
107 if $p_updated; then
108 return
109 fi
110 # background: upgrading all packages is not recommended because it
111 # doesn't go into the firmware. build new firmware if you want
112 # lots of upgrades. I think /tmp/opkg-lists is a pre openwrt 14 location.
113 f=(/var/opkg-lists/*)
114 if ! (( $(date -r $f +%s) + 60*60*24 > $(date +%s) )); then
115 if ! opkg update; then
116 echo "$0: warning: opkg update failed" >&2
117 fi
118 p_updated=true
119 fi
120 }
121
122 pi() {
123 to_install=()
124 for p in "$@"; do
125 pname=${p##*/}
126 pname=${pname%%_*}
127 if [[ ! $(opkg list-installed "$pname") ]]; then
128 to_install+=($p)
129 pmirror
130 fi
131 done
132 if [[ $to_install ]]; then
133 opkg install ${to_install[@]}
134 fi
135 }
136
137 v() {
138 printf "+ %s\n" "$*"
139 "$@"
140 }
141
142 ######### uci example:#######
143 # # https://wiki.openwrt.org/doc/uci
144 # wan_index=$(uci show firewall | sed -rn 's/firewall\.@zone\[([0-9])+\]\.name=wan/\1/p')
145 # wan="firewall.@zone[$wan_index]"
146 # if [[ $(uci get firewall.@forwarding[0].dest) != $forward_dest ]]; then
147 # # default is wan
148 # v uci set firewall.@forwarding[0].dest=$forward_dest
149 # uci commit firewall
150 # firewall_restart=true
151 # fi
152 ####### end uci example #####
153
154 uset() {
155 printf "+ uset %s\n" "$*"
156 local key="$1"
157 local val="$2"
158 local service="${key%%.*}"
159 restart_var=${service}_restart
160 if [[ ! ${!restart_var} ]]; then
161 eval $restart_var=false
162 fi
163 if [[ $(uci get "$key") != "$val" ]]; then
164 v uci set "$key"="$val"
165 uci commit $service
166 eval $restart_var=true
167 fi
168 }
169
170 udel() {
171 printf "+ udel %s\n" "$*"
172 local key="$1"
173 local val="$2"
174 local service="${key%%.*}"
175 restart_var=${service}_restart
176 if [[ ! ${!restart_var} ]]; then
177 eval $restart_var=false
178 fi
179 if uci get "$key" &>/dev/null; then
180 v uci set "$key"="$val"
181 uci commit $service
182 eval $restart_var=true
183 fi
184 }
185
186
187
188 ### network config
189 ###
190 lan=10.0.0.0
191 if $test; then
192 lan=10.1.0.0
193 elif [[ $hostname == cmc ]]; then
194 lan=10.2.0.0
195 fi
196
197 if $test; then
198 ssid="gnuv3"
199 elif $secrets; then
200 ssid=${rssid[$rmac]}
201 fi
202
203 : ${ssid:=librecmc}
204
205
206 if $secrets; then
207 key=${rkey[$rmac]}
208 fi
209 : ${key:=pictionary49}
210
211 mask=255.255.0.0
212 cidr=16
213 l=${lan%.0}
214
215 passwd -l root ||: #already locked fails
216
217 sed -ibak '/^root:/d' /etc/shadow
218 # /root/router created by manually running passwd then copying the resulting
219 # line. We have no mkpasswd on wrt/librecmc, then we scp it in.
220 cat /root/router >>/etc/shadow
221 # otherwise, serial console gets root login with no password
222 uset system.@system[0].ttylogin 1
223
224
225
226 cat >/usr/bin/archlike-pxe-mount <<'EOFOUTER'
227 #!/bin/bash
228 # symlinks are collapsed for nfs mount points, so use a bind mount.
229 # tried putting this in /etc/config/fstab,
230 # then doing block mount, it didn't work. This doesn't persist across reboots,
231 # todo: figure that out
232 rm -f /etc/fstab
233 for d in /run/{arch,parabola}iso/bootmnt; do
234 cat >>/etc/fstab <<EOF
235 /mnt/usb/tftpboot $d none bind 0 0
236 EOF
237 mount | grep $d &>/dev/null || mount $d
238 done
239 /etc/init.d/nfsd restart
240 EOFOUTER
241 chmod +x /usr/bin/archlike-pxe-mount
242
243 sed -i '/^root:/s,/bin/ash$,/bin/bash,' /etc/passwd
244
245
246
247 uset dropbear.@dropbear[0].PasswordAuth 0
248 uset dropbear.@dropbear[0].RootPasswordAuth 0
249 uset dropbear.@dropbear[0].Port 2220
250 if ! cmp -s /root/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key; then
251 cp /root/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key
252 dropbear_restart=true
253 fi
254
255 if $dropbear_restart; then
256 v /etc/init.d/dropbear restart
257 fi
258
259
260 uset network.lan.ipaddr $l.$lanip
261 uset network.lan.netmask $mask
262 if $dev2; then
263 uset network.lan.gateway $l.1
264 uset network.wan.proto none
265 uset network.wan6.proto none
266 /etc/init.d/dnsmasq stop
267 /etc/init.d/dnsmasq disable
268 /etc/init.d/odhcpd stop
269 /etc/init.d/odhcpd disable
270 rm -f /etc/resolv.conf
271 cat >/etc/resolv.conf <<'EOF'
272 nameserver 8.8.8.8
273 nameserver 8.8.4.4
274 EOF
275
276 # things i tried to keep dnsmasq running but not enabled except local dns,
277 # but it didnt work right and i dont need it anyways.
278 # uset dhcp.wan.ignore $dev2 # default is false
279 # uset dhcp.lan.ignore $dev2 # default is false
280 # uset dhcp.@dnsmasq[0].interface lo
281 # uset dhcp.@dnsmasq[0].localuse 0
282 # uset dhcp.@dnsmasq[0].resolvfile /etc/dnsmasq.conf
283 # uset dhcp.@dnsmasq[0].noresolv 1
284 # todo: populate /etc/resolv.conf with a static value
285
286 else
287 # these are the defaults
288 uset network.lan.gateway ''
289 uset network.wan.proto dhcp
290 uset network.wan6.proto dhcpv6
291 /etc/init.d/dnsmasq start
292 # todo: figure out why this returns 1
293 /etc/init.d/dnsmasq enable ||:
294 /etc/init.d/odhcpd start
295 /etc/init.d/odhcpd enable
296 fi
297
298 wireless_restart=false
299 for x in 0 1; do
300 uset wireless.default_radio$x.ssid "$ssid"
301 uset wireless.default_radio$x.key $key
302 uset wireless.default_radio$x.encryption psk2
303 if [[ $mac ]]; then
304 uset wireless.default_radio$x.macaddr $macpre$((macsuf + 2*x))
305 fi
306 # secondary device has wireless disabled
307 uset wireless.radio$x.disabled $dev2
308 done
309
310 if $wireless_restart; then
311 v wifi
312 fi
313
314
315
316 # usb, screen, relay are for libremanage
317 # rsync is for brc
318 v pi kmod-usb-storage block-mount kmod-fs-ext4 nfs-kernel-server \
319 tcpdump openvpn-openssl adblock libusb-compat /root/relay_1.0-1_mips_24kc.ipk \
320 screen kmod-usb-serial-cp210x kmod-usb-serial-ftdi rsync
321
322 cat >/etc/libremanage.conf <<EOF
323 ${libremanage_host}_type=switch
324 ${libremanage_host}_channel=1
325 EOF
326
327
328
329 v /etc/init.d/fstab enable ||:
330
331 # rebooting makes mounting work, but comparing lsmod,
332 # i'm guessing this will too. todo, test it.
333 # 255 == module already loaded
334 for mod in scsi_mod sd_mod; do v modprobe $mod || [[ $? == 255 ]]; done
335
336 # for archlike pxe. The default settings in the installer expect to find
337 # the NFS at one of these dirs
338 mkdir -p /run/archiso/bootmnt
339 mkdir -p /run/parabolaiso/bootmnt
340
341 # todo: at some later time, i found /mnt/usb not mounted, watch to see if
342 # that is the case after running this or rebooting.
343 # wiki says safe to do in case of fstab changes:
344
345 ## ian: usb broke on old router. if that happens, can just comment this to disable problems
346 # echo | cedit /etc/config/fstab ||:
347 v cedit /etc/config/fstab <<EOF || { v block umount; v block mount; }
348 config global automount
349 option from_fstab 1
350 option anon_mount 1
351
352 config mount
353 # /overlay is an / overlay mount for installing extra packages, etc.
354 # https://openwrt.org/docs/guide-user/additional-software/extroot_configuration
355 option target /mnt/usb
356 # option target /overlay
357 option device /dev/sda1
358 option fstype ext4
359 option options rw,async,noatime,nodiratime
360 option enabled 0
361 EOF
362
363
364 # ian: disabled because afaik I don't need it, no benefit.
365 # config global autoswap
366 # option from_fstab 1
367 # option anon_swap 1
368
369 # config swap
370 # option device /dev/sda1
371 # option enabled 1
372
373
374
375
376 # exportfs -ra wont cut it when its the same path, but now a bind mount
377 # todo: restart nfs when nfs is enabled?
378 #cedit /etc/exports <<EOF || v /etc/init.d/nfsd restart ||:
379 cedit /etc/exports <<EOF ||:
380 /mnt/usb $lan/$cidr(rw,no_root_squash,insecure,sync,no_subtree_check)
381 # for arch pxe
382 /run/archiso/bootmnt $lan/$cidr(rw,no_root_squash,insecure,sync,no_subtree_check)
383 /run/parabolaiso/bootmnt $lan/$cidr(rw,no_root_squash,insecure,sync,no_subtree_check)
384 EOF
385
386
387 # todo: enable nfs when we need it only.
388 # v /etc/init.d/portmap start
389 # v /etc/init.d/nfsd start
390 # v /etc/init.d/portmap enable
391 # v /etc/init.d/nfsd enable
392
393
394
395
396
397
398
399
400 ########## openvpn exampl
401 ########## missing firewall settings for routing lan
402 ########## traffic
403 # v /etc/init.d/openvpn start
404 # v /etc/init.d/openvpn enable
405
406 # # from https://wiki.openwrt.org/doc/uci/firewall
407 # # todo: not sure if /etc/init.d/network needs restarting.
408 # # I did, and I had to restart the vpn afterwards.
409 # # This maps a uci interface to a real interface which is
410 # # managed outside of uci.
411 # v cedit /etc/config/network <<'EOF' ||:
412 # config interface 'tun0'
413 # option ifname 'tun0'
414 # option proto 'none'
415 # EOF
416 # v cedit /etc/config/openvpn <<'EOF' || v /etc/init.d/openvpn restart
417 # config openvpn my_client_config
418 # option enabled 1
419 # option config /etc/openvpn/client.conf
420 # EOF
421
422 wgip4=10.3.0.1/24
423 wgip6=fdfd::1/64
424 wgport=26000
425
426
427 v cedit /etc/config/network <<EOF || v /etc/init.d/network reload
428 config 'route' 'transmission'
429 option 'interface' 'lan'
430 option 'target' '10.173.0.0'
431 option 'netmask' '255.255.0.0'
432 option 'gateway' '$l.3'
433
434 option interface 'wg0'
435 option proto 'wireguard'
436 option private_key '$(cat /root/wg.key)'
437 option listen_port $wgport
438 list addresses '10.3.0.1/24'
439 list addresses 'fdfd::1/64'
440
441 # tp
442 config wireguard_wg0 'wgclient'
443 option public_key '3q+WJGrm85r59NgeXOIvppxoW4ux/+koSw6Fee1c1TI='
444 option preshared_key '$(cat /root/wg.psk)'
445 list allowed_ips '10.3.0.2/24'
446 list allowed_ips 'fdfd::2/64'
447 EOF
448
449
450
451 firewall-cedit() {
452 case $hostname in
453 wrt)
454 v cedit host /etc/config/firewall <<EOF
455 config redirect
456 option name ssh
457 option src wan
458 option src_dport 22
459 option dest_ip $l.3
460 option dest lan
461 EOF
462 ;;
463 cmc)
464 v cedit host /etc/config/firewall <<EOF
465 config redirect
466 option name ssh
467 option src wan
468 option src_dport 22
469 option dest_ip $l.2
470 option dest lan
471 EOF
472 ;;
473 esac
474
475 v cedit /etc/config/firewall <<EOF
476 config rule
477 option src wan
478 option target ACCEPT
479 option dest_port 22
480
481 config redirect
482 option name sshtp
483 option src wan
484 option src_dport 2202
485 option dest_port 22
486 option dest_ip $l.8
487 option dest lan
488 config rule
489 option src wan
490 option target ACCEPT
491 option dest_port 2202
492
493 config redirect
494 option name sshx2
495 option src wan
496 option src_dport 2205
497 option dest_port 22
498 option dest_ip $l.5
499 option dest lan
500 config rule
501 option src wan
502 option target ACCEPT
503 option dest_port 2205
504
505 config redirect
506 option name sshx3
507 option src wan
508 option src_dport 2207
509 option dest_port 22
510 option dest_ip $l.7
511 option dest lan
512 config rule
513 option src wan
514 option target ACCEPT
515 option dest_port 2207
516
517 config redirect
518 option name sshtp
519 option src wan
520 option src_dport 2208
521 option dest_port 22
522 option dest_ip $l.8
523 option dest lan
524 config rule
525 option src wan
526 option target ACCEPT
527 option dest_port 2208
528
529
530 config rule
531 option name sshwrt
532 option src wan
533 option target ACCEPT
534 option dest_port 2220
535
536 config rule
537 option name wg
538 option src wan
539 option target ACCEPT
540 option dest_port $wgport
541 option proto udp
542
543
544 config redirect
545 option name vpntp
546 option src wan
547 option src_dport 1196
548 option dest lan
549 option dest_ip $l.8
550 option proto udp
551 config rule
552 option src wan
553 option target ACCEPT
554 option dest_port 1196
555 option proto udp
556
557
558 config redirect
559 option name httptp
560 option src wan
561 option src_dport 80
562 option dest lan
563 option dest_ip $l.8
564 option proto tcp
565 config rule
566 option src wan
567 option target ACCEPT
568 option dest_port 80
569 option proto tcp
570
571 config redirect
572 option name httpstp
573 option src wan
574 option src_dport 443
575 option dest lan
576 option dest_ip $l.8
577 option proto tcp
578 config rule
579 option src wan
580 option target ACCEPT
581 option dest_port 443
582 option proto tcp
583
584 config redirect
585 option name syncthing
586 option src wan
587 option src_dport 22001
588 option dest_ip $l.8
589 option dest lan
590 config rule
591 option src wan
592 option target ACCEPT
593 option dest_port 22001
594
595
596 config rule
597 option name ssh-ipv6
598 option src wan
599 option dest lan
600 # note, using mac transform, we could allow all traffic to a host like this,
601 # replacing 1 as appropriate
602 #option dest_ip ::111:11ff:fe11:1111/::ffff:ffff:ffff:ffff
603 option dest_port 22
604 option target ACCEPT
605 option family ipv6
606
607 config rule
608 option name http-ipv6
609 option src wan
610 option dest lan
611 option dest_port 80
612 option target ACCEPT
613 option family ipv6
614
615 config rule
616 option name https-ipv6
617 option src wan
618 option dest lan
619 option dest_port 443
620 option target ACCEPT
621 option family ipv6
622
623 config rule
624 option name node-exporter
625 option src wan
626 option dest lan
627 option dest_port 9101
628 option target ACCEPT
629 option family ipv6
630
631 config rule
632 option name mail587-ipv6
633 option src wan
634 option dest lan
635 option dest_port 587
636 option target ACCEPT
637 option family ipv6
638
639 EOF
640 }
641 firewall-cedit || firewall_restart=true
642
643 if ! uci get firewall.@zone[1].network | grep wg0 &>/dev/null; then
644 # cant mix cedit plus uci
645 echo | cedit /etc/config/firewall ||:
646 uci add_list firewall.@zone[1].network=wg0
647 uci commit firewall
648 firewall-cedit ||:
649 firewall_restart=true
650 fi
651
652
653
654 v cedit /etc/hosts <<EOF || dnsmasq_restart=true
655 127.0.1.1 $hostname
656 #$l.7 x3
657 $l.12 demohost
658 $l.13 trp
659 72.14.176.105 li
660 2600:3c00::f03c:91ff:fe6d:baf8 li
661 85.119.83.50 bk
662 2001:ba8:1f1:f0c9::2 bk
663
664 # netns creation looks for next free subnet starting at 10.173, but I only
665 # use one, and I would keep this one as the first created.
666 10.173.0.2 transmission
667 EOF
668 case $hostname in
669 wrt)
670 v cedit host /etc/hosts <<EOF || dnsmasq_restart=true
671 $l.1 $hostname t.b8.nz
672 $l.3 frodo
673 $l.4 wrt2
674 $l.5 x2 faiserver
675 $l.6 x2w
676 EOF
677 v cedit host /etc/dnsmasq.conf <<EOF || dnsmasq_restart=true
678 server=/b8.nz/#
679
680 server=/kd.b8.nz/#
681 server=/x2.b8.nz/#
682 server=/x2w.b8.nz/#
683 server=/tp.b8.nz/#
684 server=/bb8.b8.nz/#
685 server=/wrt3.b8.nz/#
686 EOF
687 ;;
688
689 cmc)
690 v cedit host /etc/hosts <<EOF || dnsmasq_restart=true
691 $l.1 $hostname b8.nz
692 $l.2 kd
693 $l.8 tp
694 $l.9 bb8
695 $l.14 wrt3
696 EOF
697 v cedit host /etc/dnsmasq.conf <<EOF || dnsmasq_restart=true
698 server=/t.b8.nz/#
699 server=/frodo.b8.nz/#
700 server=/wrt.b8.nz/#
701 server=/wrt2.b8.nz/#
702 EOF
703 ;;
704 esac
705
706
707 #mail_host=$(grep -F mail.iankelling.org /etc/hosts | awk '{print $1}')
708 # if [[ $mail_host ]]; then
709 # sed -i '/^$mail_host/a mail.iankelling.org' /etc/hosts
710 # fi
711
712
713 uset dhcp.@dnsmasq[0].domain b8.nz
714 uset dhcp.@dnsmasq[0].local /b8.nz/
715 uset system.@system[0].hostname $hostname
716 # uci doesnt seem to have a way to set an empty value,
717 # if you delete it, it goes back to the default. this seems
718 # to be a decent workaround.
719 uset dhcp.@dnsmasq[0].resolvfile=/dev/null
720
721 # disabled for now. i want to selectively enable it
722 # for specific hosts.
723 if [[ $(uci get adblock.global.adb_enabled) != 0 ]]; then
724 v uci set adblock.global.adb_enabled=0
725 uci commit adblock
726 /etc/init.d/adblock restart
727 fi
728 # https://github.com/openwrt/packages/tree/master/net/adblock/files
729 cat >/etc/crontabs/root <<'EOF'
730 0 06 * * * /etc/init.d/adblock reload
731 EOF
732
733
734 # useful: http://wiki.openwrt.org/doc/howto/dhcp.dnsmasq
735
736 # sometimes /mnt/usb fails, cuz it's just a flash drive,
737 # so make sure we have this dir or else dnsmasq will fail
738 # to start.
739 mkdir -p /mnt/usb/tftpboot
740 v cedit /etc/dnsmasq.conf <<EOF || dnsmasq_restart=true
741 server=/dmarctest.b8.nz/#
742 server=/_domainkey.b8.nz/#
743 server=/_dmarc.b8.nz/#
744 server=/ns1.b8.nz/#
745 server=/ns2.b8.nz/#
746 mx-host=b8.nz,mail.iankelling.org,10
747 txt-record=b8.nz,"v=spf1 a ?all"
748
749
750 # https://ret2got.wordpress.com/2018/01/19/how-your-ethereum-can-be-stolen-using-dns-rebinding/
751 stop-dns-rebind
752
753 # this says the ip of default gateway and dns server,
754 # but I think they are unneded and default
755 #dhcp-option=3,$l.1
756 #dhcp-option=6,$l.1
757
758
759
760 # results from googling around dnsmasq optimizations
761 # about 50k in memory. router has 62 megs.
762 # in a browsing session, I probably won't ever do 5000 lookups
763 # before the ttl expiration or whatever does expiration.
764 cache-size=10000
765
766 # ask all servers, use the one which responds first.
767 # http://ma.ttwagner.com/make-dns-fly-with-dnsmasq-all-servers/
768 all-servers
769
770 # namebench benchmarks dns servers. google's dns was only
771 # slightly less fast than some others, and I trust it more
772 # to give accurate results, stay relatively fast, and
773 # not do anythin too malicious, so just use that.
774 # download namebench and run it like this:
775 # for x in all regional isp global preferred nearby; do ./namebench.py -s \$x -c US -i firefox -m weighted -J 10 -w; echo \$x; hr; done
776 # google
777 server=8.8.4.4
778 server=8.8.8.8
779 server=2001:4860:4860::8888
780 server=2001:4860:4860::8844
781
782
783 # to fixup existin ips, on the client you can do
784 # sudo dhclient -r; sudo dhclient <interface-name>
785
786 # default dhcp range is 100-150
787 # bottom port, iPXE (PCI 03:00.0) in seabios boot menu
788 dhcp-host=c8:60:00:31:6b:75,set:kd,$l.2,kd
789 # top port, iPXE (PCI 04:00.0) in seabios boot menu
790 #dhcp-host=c8:60:00:2b:15:07,set:kd,$l.2,kd
791 dhcp-host=00:26:18:97:bb:16,set:frodo,$l.3,frodo
792 # 4 is reserved for a staticly configured host wrt2
793 # old x2 with bad fan
794 #dhcp-host=00:1f:16:16:39:24,set:x2,$l.5,x2
795 dhcp-host=f0:de:f1:81:ec:88,set:x2,$l.5,x2
796 dhcp-host=c4:8e:8f:44:f5:63,set:x2w,$l.6,x2w
797 # This is so fai can have an explicit name to use for testing,
798 # or else any random machine which did a pxe boot would get
799 # reformatted. The mac is from doing a virt-install, cancelling it,
800 # and copying the generated mac, so it should be randomish.
801 dhcp-host=00:1f:16:14:01:d8,set:tp,$l.7,x3
802 dhcp-host=80:fa:5b:1c:6e:cf,set:tp,$l.8,tp
803 dhcp-host=52:54:00:9c:ef:ad,set:demohost,$l.12,demohost
804 dhcp-host=62:03:cb:a8:3e:a3,set:trp,$1.13,trp
805
806 # faiserver vm
807 dhcp-host=52:54:00:56:09:f9,set:faiserver,$l.15,faiserver
808
809 # This is the ip it picks by default if dhcp fails,
810 # so might as well use it.
811 # hostname is the name it uses according to telnet
812 dhcp-host=b4:75:0e:94:29:ca,set:switch9429ca,$l.251,switch9429ca
813
814 # template
815 # dhcp-host=,$l.,
816
817 # Just leave the tftp server up even if we aren't doing pxe boot.
818 # It has no sensitive info.
819 enable-tftp=br-lan
820 tftp-root=/mnt/usb/tftpboot
821 dhcp-optsfile=/etc/dnsmasq-dhcpopts.conf
822
823 #log-queries=extra
824 EOF
825
826
827
828
829 if $dnsmasq_restart && ! $dev2; then
830 v /etc/init.d/dnsmasq restart
831 fi
832
833 if $firewall_restart; then
834 v /etc/init.d/firewall restart
835 fi
836
837
838 # todo: we should catch errors and still run this if needed
839 if $network_restart; then
840 reboot
841 fi
842
843 exit 0