Raspberry Pi Access Point olarak kullanmak, RaspberryPi,AccsessPoint
Merhaba arkadaşlar raspberry pi ile ilgili yazılarıma devam ediyorum bu yazımızda başlıktan da anlaşılacağı üzere raspberry pi access point gibi kullanmayı anlatacağım.
İşlemler sırasıyla
dnsmasq ve hostapd
wlan0 Ayarları
hostapd Ayarları
dnsmasq Ayarları
Iptables yönlendirme ayarları
Yeniden başlayıyoruz.
wlan0 Ayarları
hostapd Ayarları
dnsmasq Ayarları
Iptables yönlendirme ayarları
Yeniden başlayıyoruz.
Evet vakit kaybetmeden işlemlere başlayalım, her zaman ki gibi ilk önce işletim sistemi güncellemeleri var mı diye hızlıca bakıyoruz.
sudo apt-get updatesudo apt-get upgrade
Güncellemelerimizi yaptıktan sonra dnsmasq ve hostapd aşağıda ki komut ile yüklüyoruz.
sudo apt-get install dnsmasq hostapd
Yükleme tamamlandıktan sonra wifi ayarları için aşağıda ki işlemleri yapıyoruz.
sudo nano /etc/dhcpcd.confdenyinterfaces wlan0
Bunu yapmamız daki amaç wifi için dhpcd ayarlarını iptal etmek.
Daha sonra wifi için dağıtacak olduğu ip adresi bloğunu tanımlayacağız
sudo nano /etc/network/interfaces
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.220.1
netmask 255.255.255.0
network 192.168.220.0
broadcast 192.168.220.255
Nano ile yazıp kaydettikten sonra servisleri aşağıda ki komut ile yeniden başlatıyoruz.
sudo service dhcpcd restart
sudo ifdown wlan0; sudo ifup wlan0
Wifi ayarlarımızı başarıyla yaptıktan sonra sirada ki adıma geçebiliriz.
sudo nano /etc/hostapd/hostapd.conf
Dosyamız içerisine aşağıda ki kodu ekliyoruz.
interface=wlan0
driver=nl80211
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
ignore_broadcast_ssid=0
# Use WPA2
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
# Change these to your choice
# This is the name of the network
ssid=Haydut_Pi3
# The network passphrase
wpa_passphrase=sifresifre
Sırada ki dosyamız
sudo nano /etc/default/hostapd
Açtıktan sonra ister yorum satırı olan kısmı bu şekilde editleyin isterseniz altta ki kodu direk yapıştırın karar sizin.
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Dns ve ip dağıtma işlemleri için sırada ki servisimiz dnsmasq
sudo nano /etc/dnsmasq.conf
interface=wlan0
listen-address=192.168.220.1 #Dagitilacak ip adresleri
bind-interfaces
server=8.8.8.8 #DNS
domain-needed
bogus-priv
dhcp-range=192.168.220.50,192.168.220.150,12h # IP Aralığı ve kiralama süresi
Şimdiye kadar bir sorun ile karşılaşmadıysanız sırada birde iptables ayarları var.
sudo nano /etc/sysctl.conf
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo nano /etc/iptables.test.rules
*nat
# Allow Access Point NAT
-A POSTROUTING -o eth0 -j MASQUERADE
# Redirect SSH to local
# -A PREROUTING -p tcp -m tcp --dport 22 -j REDIRECT --to-ports 22
COMMIT
*filter
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that
# doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accepts all established inbound connections
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# Allows all inbound traffic from wlan0
-A INPUT -i wlan0 -j ACCEPT
# Allows all outbound traffic
# You could modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
# Allows HTTP and HTTPS connections from anywhere (the normal ports
# for websites)
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
# Allows SSH connections
# The --dport number is the same as in /etc/ssh/sshd_config
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
# Limit SSH abuse
# The first rule records the IP address of each new attempt to access
# port 22 using the recent module. The second rule checks to see if that
# IP address has attempted to connect 4 or more times within the last
# 60 seconds, and if not then the packet is accepted.
-A INPUT -p tcp -m state --state NEW -m recent --dport 22 --set --name ssh --rsource
-A INPUT -p tcp -m state --state NEW -m recent --dport 22 ! --rcheck --seconds 60 --hitcount 4 --name ssh --rsource -j ACCEPT
# Allows vncserver connections. Uncomment this to allow VNC. Again, this is
# best restricted to certain IPs
#-A INPUT -p tcp -m state --state NEW --dport 5901 -j ACCEPT
# Allows RDP connections. Uncomment this to allow RDP.
#-A INPUT -p tcp -m state --state NEW --dport 3389 -j ACCEPT
# Allow Zeroconf connections. (Bonjour and Avahi)
-A INPUT -p udp -m state --state NEW --dport 5353 -j ACCEPT
# Allow ping
# note that blocking other types of icmp packets is considered a bad idea
# by some
# remove -m icmp --icmp-type 8 from this line to allow all kinds of icmp:
# https://security.stackexchange.com/questions/22711
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
# Allow forwarded from eth0 to permit NAT and Access Point
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
# log iptables denied calls (access via 'dmesg' command)
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
# Reject all other inbound - default deny unless explicitly allowed policy:
-A INPUT -j DROP
-A FORWARD -j DROP
COMMIT
Yeni ayarları kontrol edip yüklüyoruz
sudo iptables-restore < /etc/iptables.test.rules
sudo iptables -L, sudo iptables -S, sudo iptables -S -t nat
sudo -iİşlemler tamam eğer her şeyi doğru yaptıysanız raspberry pi yeniden başlattıktan sonra wifi noktası olarak kullanabileceksiniz. Makalenin orjinali;
iptables-save > /etc/iptables.up.rules
exit
http://gary-dalton.github.io/RaspberryPi-projects/rpi3_simple_wifi_ap.html

COMMENTS