Kali Raspberry Pi/WirelessRouter: Difference between revisions
From charlesreid1
| Line 102: | Line 102: | ||
standard config creates a new wireless network called wifi with password YourPassPhrase. Change parameter "ssid=wifi" to your desired wireless network name, change parameter "wpa_passphrase=YourPassword" to set a wpa2 passphrase. | standard config creates a new wireless network called wifi with password YourPassPhrase. Change parameter "ssid=wifi" to your desired wireless network name, change parameter "wpa_passphrase=YourPassword" to set a wpa2 passphrase. | ||
<pre> | |||
$ cat /etc/hostapd/hostapd.conf | |||
ssid=cowabunga | |||
wpa_passphrase=Shredder | |||
</pre> | |||
==setup NAT network address translation== | |||
Next is setting up NAT, edit <code>/etc/sysctl.conf</code> | |||
add the line | |||
<pre> | |||
net.ipv4.ip_forward=1 | |||
</pre> | |||
start the NAT translation: | |||
<pre> | |||
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" | |||
</pre> | |||
fire up the wifi card | |||
<pre> | |||
ifconfig wlan0 up | |||
</pre> | |||
==ip table rules== | |||
set up a few iptables rules that will allow you to forward packets from the wlan0 interface to the eth0 interface | |||
<pre> | |||
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |||
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT | |||
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT | |||
</pre> | |||
Revision as of 23:41, 4 March 2016
Making the Raspberry Pi into a wireless router
Following http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/
instructions
installing software
first install a daemon for taking care of access point and authentication server details:
$ apt-get install hostapd
then install a dhcp server:
$ apt-get install isc-dhcp-server
dhcp config
edit the file /etc/dhcp/dhcp.conf:
remove the lines
# ------------------------------------ # option definitions common to all supported networks... ##### option domain-name "example.org"; ##### option domain-name-servers ns1.example.org, ns2.example.org; # ------------------------------------
change the line:
# ------------------------------------ # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative; # ------------------------------------
add the lines:
# http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/
# Next we need to define the network and network addresses
# that the DHCP server will be serving. This is done by adding
# the following block of configuration to the end of file:
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.10 192.168.10.20;
option broadcast-address 192.168.10.255;
option routers 192.168.10.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local-network";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
isc dhcp server config
we just set some general, system-wide dhcp settings, so now we set things specific to the isc-dhcp-server software we'll be using to create a dhcp server.
edit the file /etc/default/isc-dhcp-server
change the following line:
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="wlan0"
static ip in network config
finally, edit the network configuration for the pi to give it a static ip address (since it will be defining its own private network, it hands out its own ip addresses, so it needs an address.)
start by taking your wireless card down:
$ ifconfig wlan0 down
now edit the file /etc/network/interfaces and add:
iface wlan0 inet static
address 192.168.10.1
netmask 255.255.255.0
hostapd config
Now configure hostapd:
edit the file /etc/hostapd/hostapd.conf
standard config creates a new wireless network called wifi with password YourPassPhrase. Change parameter "ssid=wifi" to your desired wireless network name, change parameter "wpa_passphrase=YourPassword" to set a wpa2 passphrase.
$ cat /etc/hostapd/hostapd.conf ssid=cowabunga wpa_passphrase=Shredder
setup NAT network address translation
Next is setting up NAT, edit /etc/sysctl.conf
add the line
net.ipv4.ip_forward=1
start the NAT translation:
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
fire up the wifi card
ifconfig wlan0 up
ip table rules
set up a few iptables rules that will allow you to forward packets from the wlan0 interface to the eth0 interface
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT