<commit_before>Notes on setting up DNS and DHCP
================================

This document sets out the steps and edits needed to a standard Piratebox install to get it to route traffic through a wired connection _except_ a chosen domain (eg communifi.cb).

Tested on a TP-LINK MR3040 running PB 0.6.3.

## /etc/config/network

/etc/config/network only needs to be set up to get the piratebox packages, so if you've installed the PB already via http, then nothing needed here.

1. Add external DNS to PB for use by DHCP clients connecting, by
adding this to /etc/piratebox.common alongside the "nameserver
127.0.0.1" line:

  echo "nameserver 192.168.1.254" >> /tmp/resolv.conf

Were 192.168.1.254 is your router IP. Alternatively, use Google's DNS (8.8.8.8) to avoid having to set this if you move the box.

2. Comment out the 'no-resolv' setting in
/opt/piratebox/conf/dnsmasq_default.conf to allow the box to use other
DNS servers (specified, I believe, in /etc/config/network as 'dns'
options):

  # no-resolv 

3. Amend the PB config generation script at
/opt/piratebox/bin/generate_config_files.sh to only redirect a single
domain name, changing:

  dns_redirect="/#/$net.$ip_pb"

to:

  dns_redirect="/piratebox.lan/$net.$ip_pb"

(Where "piratebox.lan" is the domain you want to use. This doesn't need to be .lan - I use "exmosis.cb")

4. Enable iptables by editing /etc/sysctl.conf and commenting out:

  net.bridge.bridge-nf-call-iptables=0
  
ie. change it to:

  # net.bridge.bridge-nf-call-iptables=0


5. I found I had to tell iptables to be permissive, as it seemed
locked down by default. I added this to /etc/firewall.user:

  iptables -I zone_wan_ACCEPT -j ACCEPT
<commit_msg>Fixed formatting<commit_after># Notes on setting up DNS and DHCP


This document sets out the steps and edits needed to a standard Piratebox install to get it to route traffic through a wired connection _except_ a chosen domain (eg communifi.cb).

Tested on a TP-LINK MR3040 running PB 0.6.3.

/etc/config/network only needs to be set up to get the piratebox packages, so if you've installed the PB already via http, then nothing needed here.

1. Add external DNS to PB for use by DHCP clients connecting, by
adding this to /etc/piratebox.common alongside the "nameserver
127.0.0.1" line:

  echo "nameserver 192.168.1.254" >> /tmp/resolv.conf

Were 192.168.1.254 is your router IP. Alternatively, use Google's DNS (8.8.8.8) to avoid having to set this if you move the box.

2. Comment out the 'no-resolv' setting in
/opt/piratebox/conf/dnsmasq_default.conf to allow the box to use other
DNS servers (specified, I believe, in /etc/config/network as 'dns'
options):

 \# no-resolv

3. Amend the PB config generation script at
/opt/piratebox/bin/generate_config_files.sh to only redirect a single
domain name, changing:

  dns_redirect="/#/$net.$ip_pb"

to:

  dns_redirect="/piratebox.lan/$net.$ip_pb"

(Where "piratebox.lan" is the domain you want to use. This doesn't need to be .lan - I use "exmosis.cb")

4. Enable iptables by editing /etc/sysctl.conf and commenting out:

  net.bridge.bridge-nf-call-iptables=0
  
ie. change it to:

  # net.bridge.bridge-nf-call-iptables=0


5. I found I had to tell iptables to be permissive, as it seemed
locked down by default. I added this to /etc/firewall.user:

  iptables -I zone_wan_ACCEPT -j ACCEPT

{'fraction_non_alphanumeric': 0.09539473684210527, 'fraction_numerical': 0.02631578947368421, 'mean_word_length': 3.737960339943343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6686246', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1080, 'n_words': 453}