Cov txheej txheem:

Qhia WiFi Nrog Ethernet Port ntawm Raspberry Pi: 7 Cov Kauj Ruam (nrog Duab)
Qhia WiFi Nrog Ethernet Port ntawm Raspberry Pi: 7 Cov Kauj Ruam (nrog Duab)

Video: Qhia WiFi Nrog Ethernet Port ntawm Raspberry Pi: 7 Cov Kauj Ruam (nrog Duab)

Video: Qhia WiFi Nrog Ethernet Port ntawm Raspberry Pi: 7 Cov Kauj Ruam (nrog Duab)
Video: ? Что такое многополосный 6 атомный хронометраж ? То 2024, Hlis ntuj nqeg
Anonim
Qhia WiFi nrog Ethernet Port ntawm Raspberry Pi
Qhia WiFi nrog Ethernet Port ntawm Raspberry Pi

Koj puas muaj lub tshuab luam ntawv laser qub lossis lub tshuab luam ntawv uas tseem ua haujlwm zoo tab sis tsis yog wifi sib xws? Lossis tej zaum koj xav txuas lub hard drive sab nraud los ua lub cuab yeej thaub qab ntawm koj lub network thiab koj tau khiav tawm ntawm ethernet chaw nres nkoj ntawm koj lub tsev router. Cov lus qhia no yuav pab koj tsim tus choj los ntawm kev txuas wifi mus rau qhov chaw nres nkoj ethernet ntawm Raspberry Pi.

Kuv xav tau ib txoj hauv kev los txuas lub Xerox lub tshuab luam ntawv qub/tshuab luam ntawv uas tau tsim hauv kev sib txuas network thiab software software tab sis tsis yog wifi sib xws. Lub tshuab luam ntawv no tau nyob hauv lub tsev qub thiab lub tshuab luam ntawv tau nyob hauv qhov chaw uas tsis ze rau ntawm ethernet ntaus nrig thiab txav tsis tau. Nrog ob peb ntu uas kuv twb muaj nyob ib puag ncig kuv lub tsev kuv tuaj yeem tso ua ke cov tshuaj uas daws kuv cov kev xav tau.

Qhov kev daws teeb meem DIY yooj yim no yuav ua rau koj muaj peev xwm ntxiv kev sib txuas wifi rau koj li qub tsis tas ua txhaum lub txhab nyiaj los ntawm kev yuav khoom siv lub tshuab luam ntawv wireless.

Kauj Ruam 1: Cov khoom koj xav tau

Cov khoom koj yuav xav tau
Cov khoom koj yuav xav tau
  1. Raspberry Pi (txhua tus qauv yuav ua, tab sis koj yuav pom qhov tshwm sim sai dua nrog tus qauv 3).
  2. Fais fab adapter rau koj Pi.
  3. SD Card los teeb tsa lub operating system rau (koj tuaj yeem siv daim npav 8GB txog qhov loj me uas koj xav tau. Kuv feem ntau mus nrog daim npav 32GB yog tias kuv xav ntxiv ntau txoj hauv kev rau RPi).
  4. Wifi adapter
  5. Ethernet cable
  6. HDML cable (Kuv muaj lub qub DVI saib yog li kuv siv qhov HDMI rau DVI cable).
  7. Keyboard thiab nas
  8. Daim npav nyeem ntawv lossis khoos phis tawj nrog ua daim npav nyeem ntawv.
  9. Ib rooj plaub rau Pi (tsis teb los tau)

Kauj ruam 2: Nruab Raspbian Operating System

Nruab Raspbian Operating System
Nruab Raspbian Operating System
Nruab Raspbian Operating System
Nruab Raspbian Operating System

Rub tawm qhov hloov tshiab kawg ntawm Raspbian (Ncua raws li kev sau ntawv no) kev ua haujlwm los ntawm no. Ntxig daim npav SD hauv lub adapter uas xa nrog nws thiab muab lub adapter nrog daim npav SD tso rau hauv koj daim npav nyeem ntawv. Luam cov duab Raspian operating system mus rau SD card los ntawm kev siv cov lus qhia no:

  • WIndows cov lus qhia
  • Mac OSX instructions
  • Linux cov lus qhia

Kauj Ruam 3: Sib sau Ua Ke

Sib sau Ua Ke
Sib sau Ua Ke
Sib sau Ua Ke
Sib sau Ua Ke
Sib sau Ua Ke
Sib sau Ua Ke

Qhov no yuav siv qee lub sijhawm los theej cov duab rau koj daim npav SD. Sib sau ua ke ntawm RPi thaum koj tab tom tos.

Ntxig lub wifi adapter hauv ib qho ntawm USB chaw nres nkoj. Ntxig cov keyboard thiab nas dongle rau hauv ib qho ntawm lwm USB chaw nres nkoj. Txuas tus saib mus rau Raspberry Pi nrog HDMI cable.

Thaum Raspbian daim duab tau ua tiav kev teeb tsa ntawm SD daim npav, tshem daim npav SD los ntawm tus adapter thiab ntxig nws rau hauv daim npav SD daim npav ntawm sab hauv qab ntawm Raspberry Pi. Tom qab ntawd ntxig lub hwj huam hloov mus rau hauv lub micro USB chaw nres nkoj thiab ua kom lub zog Raspberry Pi.

Kauj ruam 4: Teeb WiFi Txuas

Teeb WiFi Kev Sib Txuas
Teeb WiFi Kev Sib Txuas

Thaum Raspberry Pi tau ua tiav booting teeb tsa koj li kev sib txuas wifi ntawm Raspberry PI los ntawm qhib lub davhlau ya nyob twg qhov rai thiab kho cov ntaub ntawv wpa_supplicant.conf los ntawm kev siv cov lus txib hauv qab no:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Hloov lub tebchaws mus rau koj ob tsab ntawv lub tebchaws.

Ntxiv koj Wifi nkag mus taw tes SSID thiab tus password rau hauv qab ntawm cov ntawv:

network = {ssid = "Koj Wifi SSID" psk = "yourWifiPassword"}

Ib yam uas yuav tsum nco ntsoov: Lub keyboard keyboard teeb tsa yog siv GB teeb tsa. Rau peb cov nyob hauv Asmeskas nws tso qee tus cim tshwj xeeb hauv ntau qhov chaw, feem ntau yog @ thiab cov cim raug hloov pauv.

Txuag cov ntawv thiab tawm nano.

Nqa WIfi kev sib txuas los ntawm kev ntaus ntawv:

yog

lossis los ntawm kev rov pib dua Raspberry PI nrog:

sudo rov pib dua

Kauj Ruam 5: Kho Lwm Cov Kev Xaiv Nrog Raspi-teeb tsa

Kho lwm yam kev xaiv Nrog Raspi-teeb tsa
Kho lwm yam kev xaiv Nrog Raspi-teeb tsa
Kho lwm yam kev xaiv Nrog Raspi-teeb tsa
Kho lwm yam kev xaiv Nrog Raspi-teeb tsa
Kho lwm yam kev xaiv Nrog Raspi-teeb tsa
Kho lwm yam kev xaiv Nrog Raspi-teeb tsa
Kho lwm yam kev xaiv Nrog Raspi-teeb tsa
Kho lwm yam kev xaiv Nrog Raspi-teeb tsa

Thaum koj Raspberry Pi tau ua tiav txuas nrog koj Wifi koj yuav tsum pom lub cim Wifi hauv cov ntawv qhia zaub mov nyob rau sab xis saum toj ntawm lub vijtsam rau Raspberry Pi.

Tam sim no koj tuaj yeem teeb tsa lwm txoj hauv kev rau koj Pi. Los ntawm hom qhov rai qhov ntev:

sudo raspi-teeb tsa

Qhov no yuav coj mus rau raspi-teeb tsa interface tso cai rau koj teeb tsa lwm txoj hauv kev koj li Raspberry PI. Koj tsis tas yuav ua qhov no tab sis muaj ob peb yam uas koj yuav tsum tau ua:

  1. Hloov tus password tsis raug. Tsis txhob tso cov cuab yeej ntawm koj lub network tsis yooj yim los ntawm kev tso tus lej zais ntawm koj li RPi rau pi thiab cov neeg siv hauv paus.
  2. Teeb koj qhov chaw teeb tsa. Qhov no yuav muab koj cov keyboard teeb tsa raug, teeb tsa lub sijhawm thiab qhov chaw rau txhim kho lwm cov software los ntawm qhov chaw nyob ze tshaj plaws. Yog tias koj tau txais cov lus ceeb toom PERL tsis txaus ntseeg txog thaj chaw tsis tuaj yeem teeb tsa koj tuaj yeem daws nws los ntawm kev siv cov lus qhia no.
  3. Nthuav cov ntaub ntawv kaw lus kom siv tag nrho SD daim npav. Qhov no yuav ua rau koj nkag mus rau tag nrho qhov chaw cia ntawm daim npav HD.

Xav tias dawb los saib ntawm lwm txoj kev xaiv uas muaj rau koj los ntawm qhov interface no. Koj tuaj yeem ua lwm yam xws li overclocking koj lub CPU, teeb tsa ssh thiab ftp kev sib txuas, thiab hloov koj li chaw teeb tsa kom khau raj rau kab hais kom ua lossis lub desktop.

Kauj Ruam 6: teeb tsa Network Choj Los Ntawm Wifi rau Ethernet

Kho lub Network Choj Los Ntawm Wifi rau Ethernet
Kho lub Network Choj Los Ntawm Wifi rau Ethernet
Kho lub Network Choj Los Ntawm Wifi rau Ethernet
Kho lub Network Choj Los Ntawm Wifi rau Ethernet
Kho lub Network Choj Los Ntawm Wifi rau Ethernet
Kho lub Network Choj Los Ntawm Wifi rau Ethernet
Kho lub Network Choj Los Ntawm Wifi rau Ethernet
Kho lub Network Choj Los Ntawm Wifi rau Ethernet

Txhawm rau ua qhov no peb yuav siv dnsmasq los teeb tsa RPi los ua DHCP server thiab teeb tsa qee qhov kev cai DNS teeb tsa. Qhov no yuav tso cai rau lub cuab yeej txuas nrog RPi los ntawm ethernet kom tau txais tus IP chaw nyob los ntawm RPi thiab tseem rau RPi kom dhau DNS cov lus nug.

Peb tseem yuav teeb tsa qee qhov iptables teeb tsa los ua NAT ntawm Ethernet adapter thiab Wifi txuas.

Ua ntej, nruab dnsmasq

sudo apt-tau nruab dnsmasq

Teeb koj lub ethernet adapter rau tus IP zoo li qub

Qhov no yuav ua lub qhov rooj rau lub cuab yeej uas koj xav txuas rau RPi ethernet chaw nres nkoj. Feem ntau Wifi routers siv qhov hu ua Private Network thiab teeb tsa IP ntau yam rau ib yam zoo li:

192.168.1.1

Txog ethernet adapter ntawm koj RPI koj yuav xav teeb tsa qhov chaw nyob uas yuav tsis cuam tshuam nrog routers muaj peev xwm muab chaw nyob, yog li peb yuav ua rau nce subnet ntawm PRi kom yog:

192.168.2.1

Nrog rau qhov ntawd koj yuav tsum teeb tsa lub netmask rau:

255.255.255.0

Ib yam li DCHP teeb tsa los tshaj tawm IP chaw nyob muaj dab tsi:

network 192.168.2.0 tshaj tawm 192.168.2.255

Siv iptables los teeb tsa NAT teeb tsa los qhia kev sib txuas Wifi nrog lub ethernet chaw nres nkoj NAT sawv cev rau Network Chaw Txhais Lus. Qhov no tso cai ib tus IP chaw nyob rau tus neeg rau zaub mov raws li router ntawm lub network. Yog li hauv qhov no ethernet adapter ntawm RPi yuav ua tus router rau yam khoom twg koj txuas rau nws. Kev teeb tsa NAT yuav ua rau ethernet thov los ntawm Wifi txuas.

Muaj ntau cov lus txib kom khiav ntawm no:

sudo iptables -Fsudo iptables -t nat -Fsudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADEsudo iptables -A FORWARD -i wlan0 -o eth0 -m xeev --state RELATED, ESTABLISHED -j ACCEPTsudo iptables kuv eth0 -o wlan0 -j ACCEPT

Kho qhov teeb tsa dnsmasq

Thawj qhov uas yuav tsum tau ua yog qhib IP xa mus. Qhov no ua tiav los ntawm kev tso tus lej 1 hauv/proc/sys/net/ipv4/ip_forward file:

sudo nano/proc/sys/net/ipv4/ip_forward

Muab 1 rau ntawm kab thawj thiab tom qab ntawv tawm thiab txuag. Hint: koj kuj tseem yuav tau kho /etc/sysctl.conf thiab tsis ua raws kab no:

net.ipv4.ip_forward = 1

Tom ntej teeb ip routing:

sudo ip route del 0/0 dev eth0 &>/dev/nulla = `txoj kev | awk "/$ {wlan}/" '{print $ 5+1; exit}' 'sudo lawv ntxiv -net default gw 192.168.2.1 netmask 0.0.0.0 dev eth0 metric $ a

Qhov kawg ua yog kho koj cov ntaub ntawv /etc/dnsmasq.conf thiab suav nrog cov teeb tsa no;

interface = eth0bind-interfacesserver = 8.8.8.8domain-neededbogus-privdhcp-range = 192.168.2.2, 192.168.2.100, 12h

Tom qab ntawv khiav cov lus txib no kom pib koj cov kev pabcuam dnsmasq:

sudo systemctl pib dnsmasq

Tam sim no ntsaws CAT5 network cable rau hauv lub cuab yeej uas koj xav kom suav nrog hauv lub network thiab muab lwm qhov kawg ntawm kab txuas rau hauv ethernet chaw nres nkoj ntawm RPi thiab koj yuav tsum zoo mus! Thaum peb teeb tsa lub ethernet interface peb ua rau nws kub pluggable, yog li koj yuav tsum pom tus ethernet interface tuaj thaum koj ntsaws lub cuab yeej rau hauv RPi.

Kauj Ruam 7: Automate Txhua Cov Lus txib Nrog Tsab Ntawv

Automate Txhua Cov Lus txib nrog Tsab Ntawv
Automate Txhua Cov Lus txib nrog Tsab Ntawv
Automate Txhua Cov Lus txib nrog Tsab Ntawv
Automate Txhua Cov Lus txib nrog Tsab Ntawv
Automate Txhua Cov Lus txib nrog Tsab Ntawv
Automate Txhua Cov Lus txib nrog Tsab Ntawv
Automate Txhua Cov Lus txib nrog Tsab Ntawv
Automate Txhua Cov Lus txib nrog Tsab Ntawv

Nov yog ntau txoj haujlwm kom tau txais kev sib txuas network thiab ua haujlwm. Tej zaum koj yuav xav kom qhov no ua haujlwm tau txhua lub sijhawm koj RPi khau raj, yog li ua li ntawd peb yuav xav tau ib tsab ntawv los sau tag nrho cov lus txib no rau peb. Luckily Arpit Agarwal twb tau tsim tsab ntawv thiab muaj rau rub tawm ntawm no.

Tsis txhob txhawj xeeb txog kev sau tag nrho cov lus txib saum toj no thiab khiav cov lus txib no los ntawm koj cov npe hauv tsev kom rub cov ntawv sau:

raw.githubusercontent.com/arpitjindal97/raspbian-recipes/master/wifi-to-eth-route.sh

Txhawm rau kom tau txais cov ntawv no los khiav txhua lub sijhawm koj khau raj koj RPi koj yuav tsum ntxiv cov lus qhia rau koj qhov kev sib tham pib ua haujlwm pib:

nano /home/pi/.config/lxsession/LXDE-pi/autostart

thiab ntxiv qhov no rau hauv qab ntawm cov ntawv:

sudo bash /home/pi/wifi-to-eth-route.sh

Tom qab ntawd tsuas yog rov pib dua RPi thiab tsab ntawv ua txhua yam haujlwm rau koj. Koj tseem tuaj yeem ua qhov teeb tsa no txhua lub sijhawm koj xav tau los ntawm kev ua cov lus txib no los ntawm lub davhlau ya nyob twg:

sudo bash /home/pi/wifi-to-eth-route.sh

Pom zoo: