Skip to content

Instantly share code, notes, and snippets.

@malefs
Created January 13, 2016 09:43
Show Gist options
  • Select an option

  • Save malefs/253aea0b6d007123f01f to your computer and use it in GitHub Desktop.

Select an option

Save malefs/253aea0b6d007123f01f to your computer and use it in GitHub Desktop.
Raspberry PI router
#/etc/dhcp/dhcpd.conf
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
max-lease-time 3600;
default-lease-time 3600;
log-facility local7;
#one-lease-per-client true;
ddns-update-style interim;
include "/etc/bind/rndc.key";
authoritative;
zone local {
primary 10.10.0.1;
key rndc-key;
}
subnet 10.10.0.0 netmask 255.255.255.0 {
range 10.10.0.50 10.10.0.60;
option routers 10.10.0.1;
option subnet-mask 255.255.255.0;
default-lease-time 1209600;
max-lease-time 1814400;
option domain-name "local";
option domain-name-servers 10.10.0.1;
option broadcast-address 10.10.0.255;
}
#/etc/hostapd/hostapd.conf
logger_syslog=2
logger_syslog_level=2
logger_stdout=2
logger_stdout_level=2
interface=wlan0
ssid=WIRELESS_NETWORK
hw_mode=g
channel=11
wpa=2
wpa_passphrase=PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_ptk_rekey=600
# The interface driver
driver=rtl871xdrv
#!/bin/bash
# /etc/init-router.sh
# chmod +x /etc/init-router.sh
date
#
# Initialize date because raspberry has no battery
#
NTP=1
while [ $NTP -eq 1 ]; do
/usr/sbin/ntpdate pool.ntp.org | grep "adjust time server"
let NTP=$?
sleep 5s
echo "NTP setup: $NTP"
done
#
# Initialize wlan0
#
ifup wlan0
#
# Initialize DHCP and DNS server
#
/etc/init.d/isc-dhcp-server restart
/etc/init.d/bind9 restart
#
# Initialize hostpad access point
#
/etc/init.d/hostapd restart
#!/bin/sh
# /etc/init.d/init-router
#
### BEGIN INIT INFO
# Provides: init-router
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
echo "Init init-router script"
/home/pi/config/stargate/init-router.sh > /var/log/init-router.log &
#/etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet static
address 10.0.0.2
netmask 255.255.255.0
network 10.0.0.0
gateway 10.0.0.1
broadcast 10.0.0.255
iface wlan0 inet static
address 10.10.0.1
netmask 255.255.255.0
up iptables-restore < /etc/iptables.config
#
# The 10.0.0.1 is needed because when the raspberry starts it needs
# to call rtp update and is needed a DNS lookup for that reason
#
dns-nameservers 10.10.0.1 10.0.0.1
dns-search local
dns-domain local
#/etc/iptables.config
# Generated by iptables-save v1.4.14 on Tue Jan 14 10:08:57 2014
*filter
:INPUT ACCEPT [781:59298]
:FORWARD ACCEPT [26:1912]
:OUTPUT ACCEPT [499:60790]
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
COMMIT
# Completed on Tue Jan 14 10:08:57 2014
# Generated by iptables-save v1.4.14 on Tue Jan 14 10:08:57 2014
*nat
:PREROUTING ACCEPT [28:2515]
:INPUT ACCEPT [12:1326]
:OUTPUT ACCEPT [10:760]
:POSTROUTING ACCEPT [25:1876]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Tue Jan 14 10:08:57 2014
#/etc/bind/named.conf.local
# To allow DNS Updates
# > sudo chown bind /etc/bind/
include "/etc/bind/rndc.key";
zone "local" {
type master;
file "/etc/bind/db.local";
allow-update { key "rndc-key"; };
};
zone "0.10.0.in-addr.arpa" {
type master;
file "/etc/bind/zones/rev.0.10.0.in-addr.arpa";
allow-update { key "rndc-key"; };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment