Los paquetes a instalar son hostapd,dnsmasq
yum install -y hostapd dnsmasq
Posteriormente le indicaremos al kernel que permita la opcion de retrasmitir paquetes entre la interface wifi y una de ethernet
[root@linux ~]# tail -n 1 /etc/sysctl.conf
net.ipv4.ip_forward = 1
#sysctl -p
La configuracion que se usara para para hostapd:
# cat /etc/hostapd.conf
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
#########
#beacon_int=100
#dtim_period=2
#max_num_sta=20
#rts_threshold=2347
#fragm_threshold=2346
#preamble=1
#########
# Some usable default settings...
#macaddr_acl=1
macaddr_acl=0
#accept_mac_file=/etc/hostapd/accept
auth_algs=3
ignore_broadcast_ssid=0
# Uncomment these for base WPA & WPA2 support with a pre-shared key
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
# DO NOT FORGET TO SET A WPA PASSPHRASE!!
wpa_passphrase=qwertyuiop
# Most modern wireless drivers in the kernel need driver=nl80211
driver=nl80211
# Customize these for your local configuration...
interface=variable1
hw_mode=g
channel=11
ssid=kernel panic
Ahora para configurar el el dhcp, dns y el bloqueo de paginas publicitarias usaremos dnsmasq
# cat /etc/dnsmasq.conf
#dns externos , se recomiendas de google
server=8.8.8.8
server=8.8.4.4
#las interfaces , en micaso tendo un bridge y el wifi
interface=br0
interface=variable1
#se indica que la interface de ethernet solo servira dns y no dhcp
no-dhcp-interface=br0
#indicamos el rango para el pool de dhcp
dhcp-range=192.166.0.10,192.166.0.100
#indicamos el tipo de servicio que dara cada interface (3-gateway,6-dnsserver)
dhcp-option=variable1,3,192.166.0.1
dhcp-option=6,192.166.0.1
#numero de direcciones que estaran en el cache del dns
cache-size=10000
#incluimos archivos extra(ads-lista)
conf-dir=/etc/dnsmasq.d
Ahora indicaremos las listas de publicidad y las redireccionamos al host local
[root@linux ~]# head -n 10 /etc/dnsmasq.d/ads_block.conf
address=/ihatepops.com/127.0.0.1
address=/ad319m.adk2.co/127.0.0.1
address=/ads.doktoronline.no/127.0.0.1
address=/www.leadgenetwork.com/127.0.0.1
address=/ads.v-links.net/127.0.0.1
address=/www.marketingtips.com/127.0.0.1
address=/ycv.clearshieldredirect.com/127.0.0.1
address=/tom2.ixn.local.vmsn.de/127.0.0.1
address=/ssdc.icelandair.com/127.0.0.1
address=/oxcash.com/127.0.0.1
Procedemos a activar los servicios de hostapd y dnsmasq
service dnsmasq start
service hostapd start
Los activamos al arranque del sistema
chkconfig dnsmasq on
chkconfig hostapd on
Es necesario abrir el puerto 67 para solicitud de ip en el firewall, iptables
-A IN_public_allow -p udp -m udp --dport 67 -m conntrack --ctstate NEW -j ACCEPT
Con estas configuraciones ya tenemos un ap funcional con dhcp, dns cache con bloqueador de publicidad
Nota: La tarjeta wifi tiene a tener fallos cuando esta encendida por largos periodos de tiempo 2 a 3 dias, por lo que hay que cambiarla de puerto usb, realize el siguiente script para facilitar el cambio de nombre de la tarjeta
cat wifi_upload_dnsmasq.sh
#!/bin/bash
v1=$(ip link show| grep wl | awk '{print $2}' | tr -d ":");
cat hostapd.conf | sed s/variable1/$v1/g > /etc/hostapd/hostapd.conf
cat dnsmasq.conf | sed s/variable1/$v1/g > /etc/dnsmasq.conf
ifconfig $v1 192.166.0.1 netmask 255.255.255.0 up
service dnsmasq stop; service dnsmasq start
service hostapd stop; service hostapd start

No hay comentarios:
Publicar un comentario