Sei sulla pagina 1di 3

HOW TO ROUTER PI

1.-Asignar una ip fija a la tarjeta inalmbrica(La ultima lnea up iptables-restore /etc/iptables.ipv4.nat es importante ya que se usara mas adelante,
poner atencion)

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd


# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:


source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet static
address 10.10.1.254
netmask 255.255.255.0
network 10.10.1.0
broadcast 10.10.1.255
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#allow-hotplug wlan1
#iface wlan1 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

up iptables-restore /etc/iptables.ipv4.nat

2.- Descargar los siguientes paquetes

sudo apt-get install isc-dhcp-server hostapd

3.-Crear copia al archivo /etc/dhcp/dhcpd.conf y vaciar el contenido del original. (Ejecutar los comandos en ese orden por linea)

sudo cp /etc/dhcp/dhcpd.conf dhcpd.conf.back


sudo su
cat /dev/null > dhcpd.conf
exit

4.- Ahora editamos el archivo original /etc/dhcp/dhcpd.conf para dejarlo como en la siguiente imagen(La ips asignadas y parametros en la imagen
pueden ser diferentes):

sudo nano /etc/dhcp/dhcpd.conf

# Sample configuration file for ISC dhcpd for Debian

ddns-update-style none;

log-facility local7;

# A slightly different configuration for an internal subnet.

subnet 10.10.1.0 netmask 255.255.255.0 {


range 10.10.1.10 10.10.1.20;
option domain-name-servers 8.8.8.8, 8.8.4.4;
option domain-name "neomatrix";
option subnet-mask 255.255.255.0;
option routers 10.10.1.254;
option broadcast-address 10.10.1.255;
default-lease-time 600;
max-lease-time 7200;
}

#host servidorweb {
# hardware ethernet f0:92:1c:55:7a:33;
# fixed-address 10.10.1.253;
#}
5.- Ahora crearemos el archivo para el punto de acceso en /etc/hostapd/ para dejarlo como en la imagen(igual los parmetros pueden cambiar asu
criterio) link de Documentacion Hostapd https://wireless.wiki.kernel.org/en/users/documentation

sudo nano /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=RouterPi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=483db6b147
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

6.-Definir en el archivo /etc/default/hostapd la ruta del fichero de configuracin, modificar la siguiente lnea(Editar con nano):

DAEMON_CONF="/etc/hostapd/hostapd.conf"

7.-Definir en /etc/default/isc-dhcp-server la siguiente lnea(Editar con nano):

INTERFACES="wlan0"

8.-Aplicar las siguientes reglas al iptables(Ejecutar uno por uno)(No debe mostrar nada por cada comando de iptables que se ejecute):

sudo iptables F

sudo iptables -t nat F

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

9.- Posteriormente salvar las lneas de comandos ejecutadas para el firewall iptables(respetar las comillas)

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

10.-Establecer que cada que arraque el servidor ejecute la configuracin de iptables, para asignar al final del archivo /etc/rc.local

iptables-restore < /etc/iptables.ipv4.nat

El archivo debe quedar asi:


#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address


_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi

iptables-restore < /etc/iptables.ipv4.nat

exit 0

11.- Por ultimo establecer que automticamente se inicien los servicios hostapd y dhcp server

sudo update-rc.d isc-dhcp-server enable

sudo update-rc.d hostapd enable

12.-Por ultimo editar y modificar la siguiente lnea en el archivo /etc/sysctl.conf

net.ipv4.ip_forward = 0

cambiar el 0 a 1

net.ipv4.ip_forward = 1

Guardar y ejecutar:

sudo sysctl p

13.- Reiniciar el sistema y listo

Potrebbero piacerti anche