Cov txheej txheem:

Raspberry Pi -> Wifi Hotspot: 10 Kauj Ruam
Raspberry Pi -> Wifi Hotspot: 10 Kauj Ruam

Video: Raspberry Pi -> Wifi Hotspot: 10 Kauj Ruam

Video: Raspberry Pi -> Wifi Hotspot: 10 Kauj Ruam
Video: Turn your Raspberry Pi 3 into a Wi-Fi Hotspot 2024, Kaum ib hlis
Anonim
Raspberry Pi Kev Sib Tw 2020
Raspberry Pi Kev Sib Tw 2020

Wifi Hotspot "src =" https://content.instructables.com/ORIG/F4E/T89P/K78SLNTN/F4ET89PK78SLNTN-j.webp

Wifi Hotspot "src =" {{file.large_url | ntxiv: 'pib = webp & thav duab = 1 & qhov siab = 300' %} ">

Koj puas tau mus rau qhov chaw tsis muaj wifi, thiab koj cov phooj ywg yuav tsis muab hotspot? Kuv muaj, thiab hauv cov ntawv qhia no, Kuv yuav qhia koj ib qib zuj zus ntawm yuav ua li cas tig koj li Raspberry Pi rau hauv wifi hotspot. Txawm tias zoo dua, txoj haujlwm no yuav raug nqi koj tsawg dua 100 USD!

Khoom siv

BOM:

Raspberry Pi 3 (thev naus laus zis txhua tus qauv yuav ua haujlwm tab sis kuv pom cov qauv no zoo ib yam):

Wifi Stick (qhov no yog nyob ntawm yeem raws li raspberry pi twb tau tsim wifi, tab sis lub teeb liab yuav zoo dua nrog wifi stick): https://www.amazon.com/Adapter-1200Mbps-TECHKEY-Wireless-Network-300Mbps/dp /B07J65G9DD/ref = sr_1_3? Keywords = wifi+stick & qid = 1583146106 & sr = 8-3

Koj kuj tseem yuav xav tau keyboard nas, tshuaj ntsuam/saib, thiab lub zog siv uas kuv tau txais los ntawm lub txhab nyiaj, (piv txwv tias koj twb muaj lawm.)

Kauj ruam 1: Nruab thiab Hloov Kho Raspbian

Hloov kho Raspbian los ntawm kev ntaus cov lus txib no:

sudo apt-tau hloov tshiabudo apt-tau hloov tshiab

Yog tias koj tau txais kev txhim kho, Nws yog lub tswv yim zoo kom rov pib dua nrog sudo rov pib dua.

Kauj Ruam 2: Nruab Hostapd thiab Dnsmasq

Nov yog ob txoj haujlwm peb yuav siv los ua koj li Raspberry Pi rau hauv qhov chaw nkag tau yooj yim. Kom tau lawv, tsuas yog ntaus cov kab no rau hauv lub davhlau ya nyob twg:

sudo apt-tau nruab hostapd

sudo apt-tau nruab dnsmasq

Ob lub sijhawm, koj yuav tsum ntaus y kom txuas ntxiv. hostapd yog pob uas cia peb tsim lub wireless hotspot siv Raspberry Pi, thiab dnsmasq yog qhov yooj yim-rau-siv DHCP thiab DNS server. Peb tab tom yuav hloov kho cov txheej txheem teeb tsa cov ntaub ntawv hauv ib pliag, yog li cia peb kaw cov haujlwm ua ntej peb pib tinkering:

sudo systemctl nres hostapd

sudo systemctl nres dnsmasq

Kauj Ruam 3: Kho tus IP Static rau Wlan0 Interface

Rau peb lub hom phiaj ntawm no, Kuv xav tias peb tab tom siv tus qauv hauv tsev network IP chaw nyob, zoo li 192.168. ###. ###. Muab qhov kev xav ntawd, cia muab tus IP chaw nyob 192.168.0.10 rau wlan0

interface los ntawm kev kho cov ntaub ntawv teeb tsa dhcpcd. Pib kho nrog cov lus txib no:

sudo nano /etc/dhcpcd.conf

Tam sim no koj nyob hauv cov ntawv, ntxiv cov kab hauv qab no thaum kawg:

wb wl0

ip_address zoo li qub = 192.168.0.10/24

rejectinterfaces eth0

tsis lees paub qhov chaw wlan0

(Qhov kawg ob kab xav tau txhawm rau ua kom peb cov choj ua haujlwm but- tab sis ntau ntxiv ntawm qhov ntawd hauv Kauj Ruam 8.) Tom qab ntawd, nias Ctrl+X, tom qab ntawd Y, tom qab ntawd Nkag mus rau khaws cov ntaub ntawv thiab tawm ntawm tus editor.

Kauj Ruam 4: Kho DHCP Server (dnsmasq)

Peb yuav siv dnsmasq ua peb li DHCP server. Lub tswv yim ntawm DHCP server yog

dynamically faib network teeb tsa tsis, xws li IP chaw nyob, rau cuam tshuam thiab cov kev pabcuam. dnsmasq cov ntaub ntawv teeb tsa ua ntej muaj ntau cov ntaub ntawv tsis tsim nyog, yog li nws yooj yim dua rau peb kom pib los ntawm kos. Cia peb hloov npe cov ntaub ntawv teeb tsa ua ntej thiab sau ib qho tshiab:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

sudo nano /etc/dnsmasq.conf

Koj yuav tau kho cov ntaub ntawv tshiab tam sim no, thiab nrog lub qub hloov npe, qhov no yog cov ntaub ntawv teeb tsa uas dnsmasq yuav siv. Ntaus cov kab no rau hauv koj cov ntaub ntawv teeb tsa tshiab:

interface = wlan0

dhcp-range = 192.168.0.11, 192.168.0.30, 255.255.255.0, 24 h

Cov kab peb ntxiv txhais tau tias peb yuav muab IP chaw nyob ntawm 192.168.0.11 thiab 192.168.0.30 rau wlan0 interface.

Kauj ruam 5:

Lwm cov ntaub ntawv teeb tsa! Lub sijhawm no, peb tab tom cuam tshuam nrog hostapd teeb tsa cov ntaub ntawv. Qhib qhov:

sudo nano /etc/hostapd/hostapd.conf

Qhov no yuav tsum tsim cov ntawv tshiab. Ntaus hauv qhov no:

interface = wlan0

choj = br0

hwj_mode = g

cov channel = 7

wmm_enabled = 0

macaddr_acl = 0

auth_algs = 1

tsis quav ntsej_broadcast_ssid = 0

npw = 2

wpa_key_mgmt = WPA-PSK

wpa_pairwise = TKIP

rsn_pairwise = CCMP

ssid = NETWORK

wpa_passphrase = PASSWORD

Nco ntsoov tias qhov twg kuv muaj "NETWORK" thiab "PASSWORD," koj yuav tsum tuaj nrog koj lub npe. Nov yog qhov koj yuav koom nrog Pi lub network los ntawm lwm cov khoom siv. Peb tseem yuav tsum qhia lub kaw lus qhov chaw ntawm cov ntawv teeb tsa:

sudo nano/etc/default/hostapd

Hauv cov ntawv no, taug qab kab uas hais tias # DAEMON_CONF =”” - tshem qhov # thiab muab txoj hauv kev rau peb cov ntawv teeb tsa hauv kab lus, kom nws zoo li qhov no: DAEMON_CONF = "/etc/hostapd/hostapd.conf" Tus # khaws kab ntawm tsis tau nyeem ua tus lej, yog li koj ib txwm coj txoj kab no los rau lub neej ntawm no thaum muab nws txoj hauv kev rau peb cov ntaub ntawv teeb tsa.

Kauj Ruam 6: Teeb Kev Mus Los Tom Qab

Lub tswv yim ntawm no yog tias thaum koj txuas rau koj Pi, nws yuav xa cov tsheb hla koj li Ethernet cable. Yog li peb yuav muaj wlan0 rau tom ntej ntawm Ethernet cable rau koj lub modem. Qhov no cuam tshuam nrog hloov kho lwm cov ntaub ntawv teeb tsa:

sudo nano /etc/sysctl.conf

Tam sim no nrhiav kab no: #net.ipv4.ip_forward = 1… thiab rho tawm “#” - tawm qhov seem, yog li nws tsuas yog nyeem:

net.ipv4.ip_forward = 1

Kauj Ruam 7: Ntxiv Txoj Cai Tshiab Iptables

Tom ntej no, peb yuav ntxiv IP qhov tsis zoo rau kev khiav tawm ntawm eth0 siv iptables:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

… Thiab txuag txoj cai tshiab iptables:

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

Txhawm rau thauj txoj cai ntawm khau raj, peb yuav tsum kho cov ntaub ntawv /etc/rc.local thiab ntxiv cov kab hauv qab no tsuas yog saum kab kab tawm 0:

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

Kauj Ruam 8: Ua kom Internet Sib Txuas

Tam sim no Raspberry Pi tau ua lub luag haujlwm nkag mus rau lwm yam khoom siv uas tuaj yeem txuas tau. Txawm li cas los xij, cov khoom siv no tsis tuaj yeem siv Pi nkag mus rau hauv internet tam sim no. Txhawm rau ua tau, peb yuav tsum tsim tus choj uas yuav hla txhua qhov kev sib kis ntawm wlan0 thiab eth0 cuam tshuam.

Txhawm rau tsim tus choj, cia nruab ib pob ntxiv:

sudo apt-tau nruab bridge-utils

Peb npaj tau ntxiv tus choj tshiab (hu ua br0):

sudo brctl ntxiv br0

Tom ntej no, peb yuav txuas qhov eth0 interface rau peb tus choj:

sudo brctl addif br0 eth0

Thaum kawg, cia hloov cov ntaub ntawv cuam tshuam:

sudo nano/etc/network/interfaces

… Thiab ntxiv kab hauv qab no kawg ntawm cov ntawv:

pib br0

iface br0 inet phau ntawv qhia

bridge_ports eth0 wlan0

Kauj ruam 9: Reboot

Tam sim no uas peb tau npaj tiav, cia rov pib dua nrog sudo rov pib dua.

Tam sim no koj Pi yuav tsum tau ua haujlwm raws li lub wireless nkag mus. Sim nws tawm los ntawm kev dhia ntawm lwm lub cuab yeej thiab nrhiav lub npe network uas koj siv rov qab hauv qib 5.

Kauj ruam 10: Ua tiav

Yog, Tam sim no koj tuaj yeem khav rau koj cov phooj ywg txog koj qhov tshiab hotspot wifi server!

Pom zoo: