Know How...

Nov 9th 2017

Know How... 355

Raspberry Pi-Hole!

Killing ads with a Raspberry Pi-Hole!

Although the show is no longer in production, you can enjoy episodes from the TWiT Archives.
Category: Help & How To

Want a low-cost, hardware-based ad-blocker that can stop third-party ads for ALL devices on your network without choking your bandwidth to a crawl? Padre and Patrick Delehanty (Big and Tall) user a Raspberry Pi 3 and the "Pi-hole" project to create a data closet device that lets you do just that!

Parts:
1. Raspberry Pi 3b
2. Any MicroSD Card larger than 8GB


Let's talk about how DNS works!
* DNS = "Domain Name System"
* When you type in a domain name, DNS converts that into IPv4 and IPv6 addresses
* IPv4 is a 32-bit address space (2^32 = (4.3 billion) 4,294,967,296 possible addresses)
  -- Separated into 4 x 8-bit segments (or octets)
  -- "192.168.10.55"
* IPv6 is a 128-bit address space (2^128 = A CRAP TON = 7.9 x 10^28 times as many as IPv4)
  -- Separated into 8 x 4 Hexadecimal segments
  -- "2001:abcd:ef12:3456:7890:aaaa:bbbb"
* With those addresses, you traffic can be routed to its destination and back

Routers vs. Switches (See Episode 291 for More!)
* Both Routers and Switches look for the most efficient path to route data
* However, HOW they do it is different
* Switches work with physical addresses (i.e. MAC addresses)
* Routers work with network addresses (i.e. IP addresses)

Basics:
* Switches have a table of MAC (Media Access Control) Addresses that let it know where frames should be sent.
* This works ok for a network of dozens to a few hundred PCs
* However, once you start having THOUSANDS of nodes, a MAC table doesn't work (There's just too many)
* Routers: Typically use BGP (Border Gateway Protocol)
-- Instead of every device having a table of every device on the Internet, BGP just knows "best routes"
-- Every device knows the devices closest to it, and the best way to transit the Internet to get CLOSER to the router that actually has the path to the desired device.


The EASIEST way to think of switching & routing is this:
-- You use a switch when you are sending/receiving data across your network
-- You use a router when you are sending/receiving data BETWEEN networks

Home routers are REALLY dumbed-down versions of core routers. (Technically, they're EDGE routers) --- They just need to have enough power and smarts to talk to your ISP's routers.

DNS allows us to use a name that's easy to remember (or advertise) instead of either an IPv4 or IPv6 address

What basic services does a typical Consumer Router offer?
1. NAT
2. DHCP
3. Firewall (Part of the NAT Functionality)
4. Wireless

NAT: (Network Address Translation)
* NAT remaps an IP address in one address space, into a different address space
* NAT came around because of IPv4 Exhaustion (Way back in the 80's)
* We USED to all have devices that had REAL addresses, and we were running out.
* NAT allowed us to greatly expand the lifspan of IPv4 because a network really only needed ONE routable address, and everything else was behind the NAT
* NAT, DOES have an impact on both the reliability and performance of your connection.

Firewall
* The ability to turn off services and close ports
* With NAT on an edge router, the Firewall basically serves two functions:
  - Manage what ports and services you've turned on (and otherwise keep the ports closed)
  - Map ports to particular IP addresses in your network.

Wireless
* DUH!

But WE want to focus on the parameters that are received by DHCP...
* Most notably:
  -- Local IP address (Non-routable address, INSIDE the network)
  -- Gateway (This is the router itself... routing packets between the OUTSIDE network and the LOCAL network

DHCP (Dynamic Host Configuration Protocol)
* It's a way for a client to obtain all the necessary IP configuration parameters when connecting to a network
* Before DHCP, we had to input IP config information into each client manually. (AKA "Static IP Addressing")
* DHCP uses UDP (User Datagram Protocol) and NOT TCP. (TCP requires a handshake and error checking --- UDP is "connectionless")

It's a multi-part process:
1) Discovery: The client broadcasts (again via UDP) a message, "DHCPDISCOVER" on the network to the IP address 255.255.255.255
2) Offer: The DHCP server recieves the broadcasted discovery message. It then reserves and IP address for that client and sends a "DHCPOFFER" message to the client that contains the client's MAC address // IP Address // Subnet Mask // Lease Duration // Gateway address // DNS Server
3) Request: The client receives the offer and broadcasts back to the server, "DHCPREQUEST" telling it that it will accept the offered address.
4) Acknowledge:  The server receives the "DHCPREQUEST" from the client and returns a "DHCPACK" 

Setup Instructions
1. Install your favorite RasPi distro
2. Drop into a shell at execute the following command
    - curl -sSL https://install.pi-hole.net | bash
3. Set a static address

 

Connect with us!

Thanks to CacheFly for the bandwidth for this show.