os:archlinux:pidns
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| os:archlinux:pidns [2021/12/29 19:59] – ↷ Page moved from archlinux:pidns to os:archlinux:pidns warnaud | os:archlinux:pidns [2021/12/29 21:03] (current) – ↷ Links adapted because of a move operation warnaud | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | Installation and configuration reminder for my RaspBerry Pi Model B as DNS | ||
| + | :!: Doesn' | ||
| + | It is now fully working under [[os: | ||
| + | ====== Overview ====== | ||
| + | To strengthen and add some fun at home I build a DNS out of the RaspBerry Pi.\\ | ||
| + | :!: This is for home use only, this dns is not resolved from outside :!: | ||
| + | |||
| + | Here's the output of lsusb | ||
| + | <code bash> | ||
| + | lsusb | ||
| + | Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/ | ||
| + | Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/ | ||
| + | Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub | ||
| + | </ | ||
| + | |||
| + | Here's the output of cpuinfo | ||
| + | <code bash> | ||
| + | Processor | ||
| + | BogoMIPS | ||
| + | Features | ||
| + | CPU implementer : 0x41 | ||
| + | CPU architecture: | ||
| + | CPU variant | ||
| + | CPU part : 0xb76 | ||
| + | CPU revision | ||
| + | |||
| + | Hardware | ||
| + | Revision | ||
| + | </ | ||
| + | ====== Partition table ====== | ||
| + | ^Disk^Partition^Name^Label^Size^Format^Comment^ | ||
| + | |MMC|1|mmcblk0p1|/ | ||
| + | |MMC|5|mmcblk0p5|/ | ||
| + | |||
| + | ====== Base install ====== | ||
| + | ===== References ===== | ||
| + | * [[http:// | ||
| + | * [[https:// | ||
| + | |||
| + | ===== First install ===== | ||
| + | Check the archlinuxarm.org page for latest img | ||
| + | <code bash> | ||
| + | dd if=archlinux-hf-2013-07-22.img of=/ | ||
| + | </ | ||
| + | Extend the root partition with the free space: gparted :-) | ||
| + | \\ \\ | ||
| + | Move the MMC card to the Raspberry Pi | ||
| + | ===== Remote access ===== | ||
| + | Headless (for my case) so I check on the DHCP for a newcomer.\\ | ||
| + | SSH to it | ||
| + | <code bash> | ||
| + | ssh root@192.168.1.156 | ||
| + | </ | ||
| + | Default password is root | ||
| + | ===== Basic configuration ===== | ||
| + | First change this root password | ||
| + | <code bash> | ||
| + | passwd | ||
| + | </ | ||
| + | ==== System Upgrade ==== | ||
| + | Simple as | ||
| + | <code bash> | ||
| + | ==== Change Vi to Vim ==== | ||
| + | <code bash> | ||
| + | pacman -S vim | ||
| + | rm /usr/bin/vi && | ||
| + | </ | ||
| + | ==== LOCALE ==== | ||
| + | <code bash>vi / | ||
| + | I'll use en_US.utf-8/ | ||
| + | < | ||
| + | en_US.UTF-8 UTF-8 | ||
| + | en_US ISO-8859-1 | ||
| + | </ | ||
| + | Then generate locales | ||
| + | <code bash> locale-gen </ | ||
| + | Configure them [[https:// | ||
| + | <code bash>vi / | ||
| + | <code bash> | ||
| + | LANG=" | ||
| + | |||
| + | # Keep the default sort order (e.g. files starting with a ' | ||
| + | # should appear at the start of a directory listing.) | ||
| + | LC_COLLATE=" | ||
| + | </ | ||
| + | Configure the console (in case of direct connection): | ||
| + | Default keyboard in console (US variant international ... with a different mapping than on X11! Well done) | ||
| + | <code bash> | ||
| + | ==== TIMEZONE ==== | ||
| + | <code bash>ln -s / | ||
| + | ==== Network configuration ==== | ||
| + | Let's change the hostname | ||
| + | <code bash> echo dns1.home > / | ||
| + | I will use a static netctl config\\ | ||
| + | Reference: [[https:// | ||
| + | <code bash> | ||
| + | cp / | ||
| + | vi / | ||
| + | </ | ||
| + | <code bash> | ||
| + | Description=' | ||
| + | Interface=eth0 | ||
| + | Connection=ethernet | ||
| + | IP=static | ||
| + | Address=(' | ||
| + | # | ||
| + | Gateway=' | ||
| + | # | ||
| + | DNS=(127.0.0.1' | ||
| + | SkipNoCarrier=yes | ||
| + | ExecUpPost='/ | ||
| + | |||
| + | ## For IPv6 autoconfiguration | ||
| + | # | ||
| + | |||
| + | ## For IPv6 static address configuration | ||
| + | #IP6=static | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | </ | ||
| + | Disable dhcpcd on eth0 | ||
| + | <code bash> | ||
| + | Make it default | ||
| + | <code bash> | ||
| + | <code bash> | ||
| + | :!:A nice reboot is mandatory ... didn't find a way to reload network configuration | ||
| + | ==== Some tools ==== | ||
| + | <code bash> | ||
| + | Select all base-devel tools even if some are already in place | ||
| + | ==== NTP ==== | ||
| + | Reference: [[https:// | ||
| + | <code bash> | ||
| + | Normally already installed and started | ||
| + | <code bash>vi / | ||
| + | <code bash> | ||
| + | server 0.fr.pool.ntp.org iburst | ||
| + | server 1.fr.pool.ntp.org iburst | ||
| + | server 2.fr.pool.ntp.org iburst | ||
| + | server 3.fr.pool.ntp.org iburst | ||
| + | </ | ||
| + | <code bash> | ||
| + | systemctl start ntpd</ | ||
| + | ===== DNS ===== | ||
| + | Reference: [[https:// | ||
| + | Would have been nice with a chroot but thanks to systemd no scripts are available for arch yet (and no I won't even try to make some) | ||
| + | ==== Bind ==== | ||
| + | Installation is pretty straight forward: | ||
| + | <code bash> | ||
| + | === named.conf === | ||
| + | <code bash>vi / | ||
| + | Add your local zone and the reverse | ||
| + | <code bash> | ||
| + | zone " | ||
| + | type master; | ||
| + | file " | ||
| + | }; | ||
| + | |||
| + | zone " | ||
| + | type master; | ||
| + | file " | ||
| + | }; | ||
| + | </ | ||
| + | === Zones === | ||
| + | Then configure files for the zones: | ||
| + | * / | ||
| + | <code bash> | ||
| + | $TTL 3h | ||
| + | @ IN SOA dns1.home. root.home. ( | ||
| + | 2013083101 ; serial | ||
| + | 3h ; refresh after 3 hours | ||
| + | 1h ; retry after 1 hour | ||
| + | 1w ; expire after 1 week | ||
| + | 1h ) ; negative caching TTL of 1 hour | ||
| + | |||
| + | IN NS dns1.home. | ||
| + | |||
| + | ;network devices and Services [1-30] | ||
| + | router | ||
| + | dns IN A 192.168.1.2 | ||
| + | wifi IN A 192.168.1.3 | ||
| + | [...] | ||
| + | </ | ||
| + | |||
| + | * / | ||
| + | <code bash> | ||
| + | $TTL 3h | ||
| + | @ IN SOA dns1.home. root.home. ( | ||
| + | 2013083101 ; serial | ||
| + | 3h ; refresh after 3 hours | ||
| + | 1h ; retry after 1 hour | ||
| + | 1w ; expire after 1 week | ||
| + | 1h ) ; negative caching TTL of 1 hour | ||
| + | |||
| + | IN NS dns1.home. | ||
| + | |||
| + | ;network devices and Services [1-30] | ||
| + | 1 IN PTR router.home. | ||
| + | 2 IN PTR dns.home. | ||
| + | 3 IN PTR wifi.home. | ||
| + | [...] | ||
| + | </ | ||
| + | === Resolv.conf === | ||
| + | Change it to simply: | ||
| + | <code bash> | ||
| + | search home | ||
| + | nameserver 127.0.0.1 | ||
| + | </ | ||
| + | Search < | ||
| + | :!: Important, since a lot of stupid services try to rewrite resolv.conf BLOCK it :!: | ||
| + | <code bash> | ||
| + | No comments on standards - I deeply regret not having openBSD here ... | ||
| + | === Final step === | ||
| + | Enable it | ||
| + | <code bash> | ||
| + | Start it | ||
| + | <code bash> | ||
| + | ==== Tests ==== | ||
| + | Weel first try to dig/ | ||
| + | <code bash> | ||
| + | #nslookup 192.168.1.1 | ||
| + | Server: | ||
| + | Address: | ||
| + | |||
| + | 1.1.168.192.in-addr.arpa | ||
| + | |||
| + | #nslookup router.home | ||
| + | Server: | ||
| + | Address: | ||
| + | |||
| + | Name: | ||
| + | Address: 192.168.1.1 | ||
| + | |||
| + | </ | ||
| + | See the performances: | ||
| + | <code bash>for i in {1..30}; do echo google.com; done | xargs -I^ -P10 dig ^ | grep time | awk / | ||
| + | |||
| + | Average query = 33.6667 ms | ||
| + | |||
| + | </ | ||
| + | Reference: [[http:// | ||
| + | |||
| + | ==== Tweaks ==== | ||
| + | You can check this wiki [[network: | ||
| + | You need | ||
| + | <code bash> | ||
| + | Add in / | ||
| + | < | ||
| + | include " | ||
| + | </ | ||
| + | In /var/named create a file called blockeddomain.hosts with: | ||
| + | <code bash> | ||
| + | $TTL 3h | ||
| + | @ IN SOA dns.home. root.home. ( | ||
| + | 2013071502 ; serial | ||
| + | 3h ; refresh after 3 hours | ||
| + | 1h ; retry after 1 hour | ||
| + | 1w ; expire after 1 week | ||
| + | 1h ) ; negative caching TTL of 1 hour | ||
| + | |||
| + | | ||
| + | IN NS dns.home. | ||
| + | A | ||
| + | * | ||
| + | * | ||
| + | </ | ||
| + | then use this script to generate the blockeddomains.zones file: | ||
| + | <code bash> | ||
| + | #! /bin/sh | ||
| + | # Script that generate a blockeddomains.zones according to a nice hosts file on the internet | ||
| + | |||
| + | # First rm previous version of downloaded and generated files | ||
| + | rm blockeddomains.zones hosts.txt | ||
| + | # Get the hosts file | ||
| + | wget http:// | ||
| + | # Convert to Unix | ||
| + | dos2unix hosts.txt | ||
| + | # For each line in the file that starts with 127, doesn' | ||
| + | for line in `cat hosts.txt | grep ^127 | grep -v localhost | cut -d " " -f 3` | ||
| + | do | ||
| + | # Create an entry in blockeddomain.zones with the correct syntax pretending we own this domain :P | ||
| + | | ||
| + | done | ||
| + | </ | ||
| + | Then copy it to /var/named and relaunch named | ||
| + | <code bash> | ||
| + | copy blockeddomains.zones / | ||
| + | systemctl reload named | ||
| + | </ | ||
| + | |||
| + | try a nslookup/ | ||
