Raspberry Pi + CentOS = Wi-Fi Hotspot (kapa router ea raspberry e nang le katiba e khubelu)

Ho na le tlhaiso-leseling e ngata Marang-rang mabapi le ho theha libaka tsa phihlello tsa Wi-Fi ho latela Raspberry single-board PC. E le molao, sena se bolela ho sebelisa mokhoa oa ho sebetsa oa Raspbian oa Raspberry.

Kaha ke molateli oa litsamaiso tse thehiloeng ho RPM, ha ke khone ho feta mohlolo ona o monyane mme ka se leke CentOS ea ka e ratoang ho eona.

Sengoloa se fana ka litaelo tsa ho etsa router ea 5GHz/AC Wi-Fi ho tsoa ho Raspberry Pi 3 Model B+ e ipapisitseng le sistimi ea ts'ebetso ea CentOS. Ho tla ba le maqheka a 'maloa a tloaelehileng empa a sa tsejoe hakaalo,' me e le bonase - setšoantšo sa ho hokahanya lisebelisoa tse eketsehileng tsa Wi-Fi ho Raspberry, e lumellang hore ka nako e le 'ngoe e sebetse ka mekhoa e mengata (2,4 + 5GHz).

Raspberry Pi + CentOS = Wi-Fi Hotspot (kapa router ea raspberry e nang le katiba e khubelu)
(motsoako oa litšoantšo tse fumanehang mahala)

A re hlokomele hang-hang hore maqhubu a mang a bokahohle a ke ke a sebetsa. Ke petetsa boholo ba 100 Mbps ho tsoa ho Raspberry ea ka moeeng, 'me sena se koahela lebelo la mofani oa ka oa Marang-rang. Ke hobane'ng ha u hloka AC e botsoa, ​​​​haeba ka khopolo u ka fumana halofo ea gigabit esita le ho N? Haeba u kile ua ipotsa potso ena, joale u ee lebenkeleng ho reka router ea sebele e nang le li-antenna tse robeli tse ka ntle.

0. Seo o tla se hloka

  • Haele hantle, "sehlahisoa sa raspberry" ka boeona ke sa maemo: Pi 3 Model B + (ho fihlela lebelo le liteishene tse lakatsehang tsa 5GHz);
  • MicroSD e ntle> = 4GB;
  • Sebaka sa mosebetsi se nang le Linux le sebali sa microSD / mongoli;
  • Ho fumaneha ha litsebo tse lekaneng Linux, sehlooho ke sa Geek e koetlisitsoeng;
  • Khokahano ea marang-rang (eth0) lipakeng tsa Raspberry le Linux, e sebelisang seva ea DHCP marang-rang a lehae le phihlello ea Marang-rang ho tsoa lisebelisoa tseo ka bobeli.

Tlhaloso e nyane ntlheng ea ho qetela. "Ke efe e tlileng pele, lehe kapa ..." mokhoa oa ho etsa router ea Wi-Fi ha ho se na lisebelisoa tsa ho kena Inthaneteng? Ha re tloheleng boikoetliso bona bo monate ka ntle ho sebaka sa sengoloa mme re nke feela hore Raspberry e hokahane le marang-rang a lehae ka mohala mme e na le phihlello ea Marang-rang. Tabeng ena, re ke ke ra hloka TV e eketsehileng le manipulator ho theha "raspberry".

1. Kenya CentOS

Leqephe la lehae la morero

Nakong ea ho ngola sengoloa sena, mofuta o sebetsang oa CentOS sesebelisoa ke 32-bit. Kae-kae Websaeteng ea Lefatše ka Bophara ke ile ka fumana maikutlo a hore ts'ebetso ea li-OS tse joalo meahong ea 64-bit ARM e fokotsehile ka hoo e ka bang 20%. Ke tla tloha motsotsong ona ntle le maikutlo.

Ho Linux, khoasolla setšoantšo se fokolang ka kernel "- RaspberryPI-"'me u e ngolle ho microSD:

# xzcat CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1810-sda.raw.xz | 
  dd of=/dev/mmcblk0 bs=4M
# sync

Pele re qala ho sebelisa setšoantšo, re tla tlosa karohano ea SWAP ho eona, re atolose motso ho bophahamo bohle bo fumanehang mme re tlose SELinux. Algorithm e bonolo: etsa kopi ea motso ho Linux, hlakola likarolo tsohle ho microSD ntle le ea pele (/ boot), theha motso o mocha 'me u khutlisetse litaba tsa eona ho tsoa kopi.

Mohlala oa liketso tse hlokahalang (sephetho se matla sa console)

# mount /dev/mmcblk0p3 /mnt
# cd /mnt
# tar cfz ~/pi.tgz . --no-selinux
# cd
# umount /mnt

# parted /dev/mmcblk0

(parted) unit s
(parted) print free
Model: SD SC16G (sd/mmc)
Disk /dev/mmcblk0: 31116288s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start     End        Size       Type     File system     Flags
        63s       2047s      1985s               Free Space
 1      2048s     1370111s   1368064s   primary  fat32           boot, lba
 2      1370112s  2369535s   999424s    primary  linux-swap(v1)
 3      2369536s  5298175s   2928640s   primary  ext4
        5298176s  31116287s  25818112s           Free Space

(parted) rm 3
(parted) rm 2

(parted) print free
Model: SD SC16G (sd/mmc)
Disk /dev/mmcblk0: 31116288s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start     End        Size       Type     File system  Flags
        63s       2047s      1985s               Free Space
 1      2048s     1370111s   1368064s   primary  fat32        boot, lba
        1370112s  31116287s  29746176s           Free Space

(parted) mkpart
Partition type?  primary/extended? primary
File system type?  [ext2]? ext4
Start? 1370112s
End? 31116287s

(parted) set
Partition number? 2
Flag to Invert? lba
New state?  on/[off]? off

(parted) print free
Model: SD SC16G (sd/mmc)
Disk /dev/mmcblk0: 31116288s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start     End        Size       Type     File system  Flags
        63s       2047s      1985s               Free Space
 1      2048s     1370111s   1368064s   primary  fat32        boot, lba
 2      1370112s  31116287s  29746176s  primary  ext4

(parted) quit

# mkfs.ext4 /dev/mmcblk0p2 
mke2fs 1.44.6 (5-Mar-2019)
/dev/mmcblk0p2 contains a swap file system labelled '_swap'
Proceed anyway? (y,N) y
Discarding device blocks: done                            
Creating filesystem with 3718272 4k blocks and 930240 inodes
Filesystem UUID: 6a1a0694-8196-4724-a58d-edde1f189b31
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done   

# mount /dev/mmcblk0p2 /mnt
# tar xfz ~/pi.tgz -C /mnt --no-selinux

Kamora ho manolla dikahare tsa karohano ya motso, ke nako ya ho etsa diphetoho ho yona.

Tlosa SELinux ho /mnt/etc/selinux/config:

SELINUX=disabled

Ho lokisa /mnt/etc/fstab, e siea ho eona likenyeletso tse peli feela mabapi le likaroloana: boot (/ boot, ha ho liphetoho) le motso (re fetola boleng ba UUID, bo ka fumanoang ka ho ithuta tlhahiso ea taelo ea blkid ho Linux):

UUID=6a1a0694-8196-4724-a58d-edde1f189b31  /     ext4    defaults,noatime 0 0
UUID=6938-F4F2                             /boot vfat    defaults,noatime 0 0

Qetellong, re fetola liparamente tsa kernel boot: re hlakisa sebaka se secha bakeng sa karohano ea motso, tima tlhahiso ea tlhaiso-leseling ea debugging mme (ka boikhethelo) thibela kernel ho fana ka liaterese tsa IPv6 ho marang-rang a marang-rang:

# cd
# umount /mnt
# mount /dev/mmcblk0p1 /mnt

Litaba ke tsena /mnt/cmdline.txt ho ea ka mokhoa o latelang (mola o le mong ntle le li-hyphens):

root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait quiet ipv6.disable_ipv6=1

E entsoe:

# cd
# umount /mnt
# sync

Re hlophisa microSD hape ho "raspberry", re e qale ebe re fumana marang-rang ho eona ka ssh (motso / centos).

2. Ho theha CentOS

Metsamao e meraro ea pele e sa sisinyeheng: passwd, Yum -a bocha, logon.

Re fana ka tsamaiso ea marang-rang marangrang:

# yum install systemd-networkd
# systemctl enable systemd-networkd
# systemctl disable NetworkManager
# chkconfig network off

Etsa faele (hammoho le li-directory) /etc/systemd/network/eth0.network:

[Match]
Name=eth0

[Network]
DHCP=ipv4

Re qala "raspberry" hape re fumana marang-rang ho eona ka ssh (aterese ea IP e ka fetoha). Ela hloko se sebelisoang /etc/resolv.conf, e entsoeng pejana ke Network Manager. Ka hona, ha ho na le mathata a ho rarolla, fetola litaba tsa eona. Sebelisa systemd-e rarollotsoe re ke ke ra.

Re tlosa "tse sa hlokahaleng", ho lokisa le ho potlakisa ho kenya OS:

# systemctl set-default multi-user.target
# yum remove GeoIP Network* aic* alsa* cloud-utils-growpart 
  cronie* dhc* firewal* initscripts iwl* kexec* logrotate 
  postfix rsyslog selinux-pol* teamd wpa_supplicant

Ea hlokang cron le ya sa sileng se ahetsweng li-timers tsa systemd, e ka tiisa se sieo. / var / log- 'me u shebe boqhetseke. Haeba o hloka nalane ea log (ka ho sa feleng, tlhahisoleseling e bolokoa feela ho tloha ha sistimi e qala):

# mkdir /var/log/journal
# systemd-tmpfiles --create --prefix /var/log/journal
# systemctl restart systemd-journald
# vi /etc/systemd/journald.conf

Tlosa ts'ebeliso ea IPv6 ke lits'ebeletso tsa mantlha (haeba ho hlokahala)/ joalo / ssh / sshd_config:

AddressFamily inet

/etc/sysconfig/chronyd:

OPTIONS="-4"

Ho amana ha nako ho "raspberry" ke ntho ea bohlokoa. Kaha ka ntle ho lebokose ha ho na bokhoni ba hardware ba ho boloka boemo ba hona joale ba oache ha e qala bocha, hoa hlokahala ho lumellana. Daemon e ntle haholo le e potlakileng bakeng sa sena ke chrony - e se e kentsoe mme e qala ka bo eona. O ka fetola li-server tsa NTP ho tse haufi.

/etc/chrony.conf:

server 0.ru.pool.ntp.org iburst
server 1.ru.pool.ntp.org iburst
server 2.ru.pool.ntp.org iburst
server 3.ru.pool.ntp.org iburst

Ho beha sebaka sa nako seo re tla se sebelisa leqheka. Kaha sepheo sa rona ke ho theha router ea Wi-Fi e sebetsang ka maqhubu a 5GHz, re tla itokisetsa lintho tse makatsang esale pele. molaoli:

# yum info crda
Kakaretso: Daemon ea taolo ea taolo bakeng sa marang-rang a se nang mohala a 802.11

Moralo ona o mobe, hape o ipapisitse le sebaka sa nako, "e thibela" tšebeliso (Russia) ea maqhubu a 5GHz le likanale tse nang le linomoro tse "phahameng". Leqheka ke ho beha sebaka sa nako ntle le ho sebelisa mabitso a lik'honthinente / litoropo, ke hore, sebakeng sa:

# timedatectl set-timezone Europe/Moscow

Re tobetsa:

# timedatectl set-timezone Etc/GMT-3

'Me lintlha tsa ho qetela tsa moriri oa sistimi:

# hostnamectl set-hostname router

/root/.bash_profile:

. . .

# User specific environment and startup programs

export PROMPT_COMMAND="vcgencmd measure_temp"
export LANG=en_US.UTF-8
export PATH=$PATH:$HOME/bin

3. Lisebelisoa tsa CentOS

Ntho e 'ngoe le e' ngoe e boletsoeng ka holimo e ka nkoa e le litaelo tse feletseng tsa ho kenya "vanilla" CentOS ho Raspberry Pi. U lokela ho qetella u e-na le PC e (re) boots ka nako e ka tlase ho metsotsoana ea 10, e sebelisang ka tlase ho 15 Megabytes ea RAM le 1.5 Gigabytes ea microSD (ha e le hantle e ka tlaase ho 1 Gigabyte ka lebaka la ho sa phethahala / boot, empa ha re bue 'nete).

Ho kenya software ea sebaka sa phihlello ea Wi-Fi tsamaisong ena, o tla hloka ho holisa hanyane bokhoni ba kabo e tloaelehileng ea CentOS. Pele ho tsohle, a re ntlafatse mokhanni (firmware) ea adaptara ea Wi-Fi e hahiloeng. Leqephe la lehae la morero le re:

Wifi ho Raspberry 3B le 3B+

Lifaele tsa firmware tsa Raspberry PI 3B/3B+ ha lia lumelloa ho ajoa ke CentOS Project. U ka sebelisa lihlooho tse latelang ho utloisisa taba, fumana firmware le ho theha wifi.

Se thibetsoeng bakeng sa morero oa CentOS ha se thibetsoe bakeng sa rona bakeng sa tšebeliso ea botho. Re nka sebaka sa kabo ea firmware ea Wi-Fi ho CentOS le e tsamaellanang le eona ho tsoa ho bahlahisi ba Broadcom (tse tšoanang li-binary blobs tse hloiloeng ...). Sena, haholo-holo, se tla u lumella ho sebelisa AC ka mokhoa oa ho fihlella.

Ntlafatso ea firmware ea Wi-FiFumana mofuta oa sesebelisoa le mofuta oa hajoale oa firmware:

# journalctl | grep $(basename $(readlink /sys/class/net/wlan0/device/driver))
Jan 01 04:00:03 router kernel: brcmfmac: F1 signature read @0x18000000=0x15264345
Jan 01 04:00:03 router kernel: brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43455-sdio.bin for chip 0x004345(17221) rev 0x000006
Jan 01 04:00:03 router kernel: usbcore: registered new interface driver brcmfmac
Jan 01 04:00:03 router kernel: brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Mar  1 2015 07:29:38 version 7.45.18 (r538002) FWID 01-6a2c8ad4
Jan 01 04:00:03 router kernel: brcmfmac: brcmf_c_preinit_dcmds: CLM version = API: 12.2 Data: 7.14.8 Compiler: 1.24.9 ClmImport: 1.24.9 Creation: 2014-09-02 03:05:33 Inc Data: 7.17.1 Inc Compiler: 1.26.11 Inc ClmImport: 1.26.11 Creation: 2015-03-01 07:22:34 

Rea bona hore mofuta oa firmware ke 7.45.18 oa 01.03.2015/XNUMX/XNUMX, 'me u hopole linomoro tse latelang: 43455 (brcmfmac43455-sdio.bin).

Khoasolla setšoantšo sa hona joale sa Raspbian. Batho ba botsoa ba ka ngola setšoantšo ho microSD mme ba nka lifaele ka firmware ho tloha moo. Kapa o ka kenya karohano ea motso oa setšoantšo ho Linux mme o kopitsa seo o se hlokang ho tloha moo:

# wget https://downloads.raspberrypi.org/raspbian_lite_latest
# unzip -p raspbian_lite_latest > raspbian.img
# fdisk -l raspbian.img
Disk raspbian.img: 2 GiB, 2197815296 bytes, 4292608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x17869b7d

Device        Boot  Start     End Sectors  Size Id Type
raspbian.img1        8192  532480  524289  256M  c W95 FAT32 (LBA)
raspbian.img2      540672 4292607 3751936  1.8G 83 Linux

# mount -t ext4 -o loop,offset=$((540672 * 512)) raspbian.img /mnt
# cp -fv /mnt/lib/firmware/brcm/*43455* ...
'/mnt/lib/firmware/brcm/brcmfmac43455-sdio.bin' -> ...
'/mnt/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob' -> ...
'/mnt/lib/firmware/brcm/brcmfmac43455-sdio.txt' -> ...
# umount /mnt

Lifaele tsa firmware tsa Wi-Fi tse hlahisoang li tlameha ho kopitsoa le ho nkeloa sebaka ke "raspberry" bukeng /usr/lib/firmware/brcm/

Re qala router ea kamoso mme re bososela ka khotsofalo:

# journalctl | grep $(basename $(readlink /sys/class/net/wlan0/device/driver))
Jan 01 04:00:03 router kernel: brcmfmac: F1 signature read @0x18000000=0x15264345
Jan 01 04:00:03 router kernel: brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43455-sdio.bin for chip 0x004345(17221) rev 0x000006
Jan 01 04:00:03 router kernel: usbcore: registered new interface driver brcmfmac
Jan 01 04:00:03 router kernel: brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Feb 27 2018 03:15:32 version 7.45.154 (r684107 CY) FWID 01-4fbe0b04
Jan 01 04:00:03 router kernel: brcmfmac: brcmf_c_preinit_dcmds: CLM version = API: 12.2 Data: 9.10.105 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2018-03-09 18:56:28 

Phetolelo: 7.45.154 ea 27.02.2018/XNUMX/XNUMX.

'Me ehlile EPEL:

# cat > /etc/yum.repos.d/epel.repo << EOF
[epel]
name=Epel rebuild for armhfp
baseurl=https://armv7.dev.centos.org/repodir/epel-pass-1/
enabled=1
gpgcheck=0
EOF

# yum clean all
# rm -rfv /var/cache/yum
# yum update

4. Tokiso ea marang-rang le mathata a tlang

Joalokaha re lumellane ka holimo, "raspberry" e kopantsoe ka "terata" ho marang-rang a sebaka seo. Ha re nke hore mofani o fana ka phihlello ea Marang-rang ka mokhoa o ts'oanang: aterese ea marang-rang ea sechaba e fanoa ka matla ke seva sa DHCP (mohlomong ka MAC e tlamang). Tabeng ena, ka mor'a setupo sa ho qetela sa raspberry, u hloka feela ho "plug" thapo ea mofani ho eona 'me u qetile. Ho sebelisa tumello systemd-networkd - sehlooho sa sengoloa se arohaneng mme ha se buuoe mona.

Raspberry's Wi-Fi interface(s) ke marang-rang a lehae, 'me adaptara ea Ethernet (eth0) e hahelletsoeng kantle. Ha re baleng nomoro ea marang-rang ea lehae ka lipalo, mohlala: 192.168.0.0/24. Aterese ea Raspberry: 192.168.0.1. Seva ea DHCP e tla sebetsa marang-rang a kantle (Inthaneteng).

Bothata ba ho Kopana ka Lebitso и moqapi ea tummeng oa Guatemala - mathata a mabeli a letetseng mang kapa mang ea lokisang likhokahano tsa marang-rang le lits'ebeletso ho phano ea systemd.

Chaos e ts'oanang (lyrical digression)Lennart Pottering e iketselitse lenaneo la eona systemd Hantle haholo. Sena systemd e thakgola mananeo a mang ka potlako hoo ba sa fumaneng nako ya ho hlaphohelwa ke molamu wa mophaladi, ba kgoptjwang mme ba we qalong ba eso ka ba qala tsela ya bona ya tshitiso.

Empa ka botebo, ho tšoana ho matla ha lits'ebetso tse qalileng qalong ea systemd OS ke mofuta oa "borokho ba litonki" bakeng sa litsebi tsa tatellano tsa LSB. Ka lehlohonolo, ho tlisa taolo ho "moferefere ona o ts'oanang" ho bonahala ho le bonolo, le hoja ho se bonolo kamehla.

Re theha marang-rang a mabeli a borokho a nang le mabitso a sa feleng: lan и wan. Re tla "hokela" adapter (s) ea Wi-Fi ho ea pele, le eth0 "raspberry" ho ea bobeli.

/etc/systemd/network/lan.netdev:

[NetDev]
Name=lan
Kind=bridge

/etc/systemd/network/lan.network:

[Match]
Name=lan

[Network]
Address=192.168.0.1/24
IPForward=yes

/etc/systemd/network/wan.netdev:

[NetDev]
Name=wan
Kind=bridge
#MACAddress=xx:xx:xx:xx:xx:xx

/etc/systemd/network/wan.network:

[Match]
Name=wan

[Network]
DHCP=ipv4
IPForward=yes

IPForward=e e felisa tlhoko ea ho fana ka maikutlo ho kernel ka sysctl ho thusa ho tsamaisa.
Aterese ea MACA= Ha re fetole maikutlo mme re fetole ha ho hlokahala.

Pele re "hokela" eth0. Re hopola "bothata bo tšoanang" mme re sebelisa feela aterese ea MAC ea sebopeho sena, se ka fumanoang, ka mohlala, tjena:

# cat /sys/class/net/eth0/address 

Rea bopa /etc/systemd/network/eth.network:

[Match]
MACAddress=b8:27:eb:xx:xx:xx

[Network]
Bridge=wan

Re hlakola faele ea tlhophiso e fetileng eth0, re qalisa Raspberry hape 'me re fumane marang-rang ho eona (aterese ea IP e ka fetoha):

# rm -fv /etc/systemd/network/eth0.network
# reboot

5.DNSMASQ

Bakeng sa ho etsa libaka tsa phihlello tsa Wi-Fi, ha ho letho le fetang tse peli tse monate dnsmasq + hostapd ha ke so e utloisise. Ho ea ka 'na.

Haeba mang kapa mang a ka lebala, joale ...hostapd - ena ke ntho e laolang li-adapter tsa Wi-Fi (haholo-holo, e tla hlokomela ho li hokahanya le "virtual". lan "raspberries"), e lumella le ho ngolisa bareki ba se nang mohala.

dnsmasq - e lokisa marang-rang a bareki: e fana ka liaterese tsa IP, li-server tsa DNS, liheke tsa kamehla le lintho tse ling tse monate.

Ha re qale ka dnsmasq:

# yum install dnsmasq

Mohlala /etc/resolv.conf:

nameserver 1.1.1.1
nameserver 1.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 77.88.8.8
nameserver 77.88.8.1
domain router.local
search router.local

e hlophise kamoo o ratang kateng.

minimalistic /etc/dnsmasq.conf:

domain-needed
bogus-priv
interface=lan
bind-dynamic
expand-hosts
domain=#
dhcp-range=192.168.0.100,192.168.0.199,255.255.255.0,24h
conf-dir=/etc/dnsmasq.d

"Boselamose" mona bo ka har'a parameter tlama-matla, e bolellang dnsmasq daemon hore e eme ho fihlela e hlaha tsamaisong segokahanyi=lan, 'me u se ke ua tepella ka lebaka la bolutu bo ikhohomosang ka mor'a ho qala.

# systemctl enable dnsmasq
# systemctl start dnsmasq; journalctl -f

6. HOSTAPD

'Me qetellong, litlhophiso tsa boselamose tsa hostapd. Ha ke na khoao ea hore ho na le motho ea balang sengoloa sena ha a ntse a batlana hantle le mela ena ea bohlokoa.

Pele o kenya hostapd, o hloka ho hlola "bothata bo tšoanang". Adapter ea Wi-Fi e hahelletsoeng wlan0 e ka fetola lebitso la eona habonolo ho wlan1 ha e hokela lisebelisoa tse ling tsa USB Wi-Fi. Ka hona, re tla lokisa mabitso a li-interface ka tsela e latelang: re tla tla le mabitso a ikhethang bakeng sa li-adapter (tse se nang mohala) ebe re li tlama ho liaterese tsa MAC.

Bakeng sa adaptara ea Wi-Fi e hahelletsoeng, e ntseng e le wlan0:

# cat /sys/class/net/wlan0/address 
b8:27:eb:xx:xx:xx

Rea bopa /etc/systemd/network/wl0.link:

[Match]
MACAddress=b8:27:eb:xx:xx:xx

[Link]
Name=wl0

Jwale re tla ba le bonnete ba hore wl0 - Ena ke Wi-Fi e hahelletsoeng kahare. Re qala Raspberry ho etsa bonnete ba sena.

Kenya:

# yum install hostapd wireless-tools

Faele ea tlhophiso /etc/hostapd/hostapd.conf:

ssid=rpi
wpa_passphrase=1234567890

channel=36

country_code=US

interface=wl0
bridge=lan

driver=nl80211

auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

macaddr_acl=0

hw_mode=a
wmm_enabled=1

# N
ieee80211n=1
require_ht=1
ht_capab=[MAX-AMSDU-3839][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]

# AC
ieee80211ac=1
require_vht=1
ieee80211d=0
ieee80211h=0
vht_capab=[MAX-AMSDU-3839][SHORT-GI-80]
vht_oper_chwidth=1
vht_oper_centr_freq_seg0_idx=42

Ntle le ho lebala nakwana Komiti ea Naha ea Tšohanyetso, fetola liparamente tseo re li hlokang 'me u hlahlobe ka letsoho bakeng sa ts'ebetso:

# hostapd /etc/hostapd/hostapd.conf

hostapd e tla qala ka mokhoa oa ho sebelisana, ho phatlalatsa boemo ba eona ho console. Haeba ho se na liphoso, joale bareki ba tšehetsang mokhoa oa AC ba tla khona ho hokela sebakeng sa phihlello. Ho emisa hostapd - Ctrl-C.

Sohle se setseng ke ho nolofalletsa hostapd ho qala sistimi. Haeba u etsa ntho e tloaelehileng (systemctl thusa hostapd), joale ka mor'a hore u qale bocha u ka fumana modemona "ho phalla maling" ka ho hlahlojoa "interface wl0 ha e fumanehe". Ka lebaka la "moferefere o tšoanang," hostapd e ile ea qala kapele ho feta kernel e fumaneng adaptara e se nang mohala.

Marang-rang a tletse litlhare: ho tloha ka nako e qobelloang pele o qala daemon (metsotso e 'maloa), ho ea ho daemon e' ngoe e hlokomelang ponahalo ea sebopeho le (bocha) e qalisa hostpad. Litharollo li sebetsa haholo, empa li mpe haholo. Re kopa thuso ho e moholo systemd ka “dipheo” le “mesebetsi” le “ditshetleho”.

Kopitsa faele ea tšebeletso ea kabo ho /etc/systemd/system/hostapd.service:

# cp -fv /usr/lib/systemd/system/hostapd.service /etc/systemd/system

le ho fokotsa litaba tsa eona ka mokhoa o latelang:

[Unit]
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
After=sys-subsystem-net-devices-wl0.device
BindsTo=sys-subsystem-net-devices-wl0.device

[Service]
Type=forking
PIDFile=/run/hostapd.pid
ExecStart=/usr/sbin/hostapd /etc/hostapd/hostapd.conf -P /run/hostapd.pid -B

[Install]
WantedBy=sys-subsystem-net-devices-wl0.device

Boselamose ba faele e ntlafalitsoeng ea litšebeletso bo ho tlamahano e matla ea hostapd ho sepheo se secha - sebopeho sa wl0. Ha sebopeho se hlaha, daemon ea qala; ha e nyamela, ea emisa. 'Me sena sohle se inthaneteng - ntle le ho qala sistimi hape. Mokhoa ona o tla ba molemo haholo ha o hokela adaptara ea USB Wi-Fi ho Raspberry.

Joale u ka:

# systemctl enable hostapd
# reboot

7. IPTABLE

"Ke eng???" © E, ho joalo! Ha ho letho systemd. Ha ho na li-newfangled tse kopantsoeng (ka sebopeho mollo), tse qetellang li etsa ntho e tšoanang.

Ha re sebeliseng ea khale e ntle li-iptables, bao litšebeletso tsa bona, ka mor'a ho qala, li tla kenya melao ea marang-rang ka har'a kernel ebe e koala ka khutso ntle le ho lula e le moahi le ntle le ho ja mehloli. systemd e na le bokhabane IPMasquerade=, empa re ntse re tla beha phetolelo ea aterese (NAT) le firewall ho iptables.

Kenya:

# yum install iptables-services
# systemctl enable iptables ip6tables

Ke khetha ho boloka tlhophiso ea iptables joalo ka script (mohlala):

#!/bin/bash

#
# Disable IPv6
#
ip6tables --flush
ip6tables --delete-chain

ip6tables --policy INPUT   DROP
ip6tables --policy FORWARD DROP
ip6tables --policy OUTPUT  DROP

ip6tables-save > /etc/sysconfig/ip6tables
systemctl restart ip6tables

#
# Cleaning
#
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

#
# Loopback, lan
#
iptables -A INPUT -i lo  -j ACCEPT
iptables -A INPUT -i lan -j ACCEPT

#
# Ping, Established
#
iptables -A INPUT -p icmp  --icmp-type echo-request    -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#
# NAT
#
iptables -t nat -A POSTROUTING -o wan -j MASQUERADE

#
# Saving
#
iptables-save > /etc/sysconfig/iptables
systemctl restart iptables

Re sebelisa mongolo o ka holimo mme re lahleheloa ke bokhoni ba ho theha likhokahano tse ncha tsa SSH le Raspberry. Ho lokile, re entse router ea Wi-Fi, eo ho eona ho thibetsoeng "ka Marang-rang" ka mokhoa o ikhethileng - hona joale ke "moea" feela. Re hokela thapo ea Ethernet ea mofani ebe re qala ho palama maqhubu!

8. Bonase: +2,4GHz

Ha ke bokella router ea pele ea Raspberry ke sebelisa setšoantšo se hlalositsoeng ka holimo, ke ile ka fumana lisebelisoa tse 'maloa ka tlung ea ka tseo, ka lebaka la mefokolo ea moralo oa Wi-Fi, li ne li sa khone ho bona "raspberry" ho hang. Ho tsosolosa router hore e sebetse ka 802.11b / g / n e ne e se papali, kaha lebelo le phahameng "moea" tabeng ena ha lea ka la feta 40 Mbit, 'me mofani oa ka oa Inthanete eo ke mo ratang o mpha 100 (ka cable).

Ha e le hantle, tharollo ea bothata e se e qapiloe: sebopeho sa bobeli sa Wi-Fi se sebetsang ka makhetlo a 2,4 GHz, le sebaka sa bobeli sa ho fihlella. Ha ke le lebenkeleng le haufi ha kea ka ka reka ea pele, empa ke ile ka kopana le "mololi" oa bobeli oa USB Wi-Fi. Morekisi o ne a hlokofatsoa ke lipotso tse mabapi le chipset, ho lumellana le li-kernel tsa ARM Linux le monyetla oa ho sebetsa ka mokhoa oa AP (e ne e le eena oa pele oa ho qala).

Re lokisa "mololi" ka papiso le adaptara ea Wi-Fi e hahiloeng.

Taba ea pele, a re e reheng bocha wl1:

# cat /sys/class/net/wlan0/address 
b0:6e:bf:xx:xx:xx

/etc/systemd/network/wl1.link:

[Match]
MACAddress=b0:6e:bf:xx:xx:xx

[Link]
Name=wl1

Re tla beha bolaoli ba sebopeho se secha sa Wi-Fi ho daemon e arohaneng ea hostapd, e tla qala le ho emisa ho latela boteng ba "mololi" e hlalositsoeng ka thata tsamaisong: wl1.

Faele ea tlhophiso /etc/hostapd/hostapd2.conf:

ssid=rpi2
wpa_passphrase=1234567890

#channel=1
#channel=6
channel=11

interface=wl1
bridge=lan

driver=nl80211

auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

macaddr_acl=0

hw_mode=g
wmm_enabled=1

# N
ieee80211n=1
require_ht=1
ht_capab=[HT40][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]

Likahare tsa faele ena li ipapisitse le mofuta oa adaptara ea Wi-Fi ea USB, ka hona, kopi / peista ea banal e ka u hloleha.

Kopitsa faele ea tšebeletso ea kabo ho /etc/systemd/system/hostapd2.service:

# cp -fv /usr/lib/systemd/system/hostapd.service /etc/systemd/system/hostapd2.service

le ho fokotsa litaba tsa eona ka mokhoa o latelang:

[Unit]
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
After=sys-subsystem-net-devices-wl1.device
BindsTo=sys-subsystem-net-devices-wl1.device

[Service]
Type=forking
PIDFile=/run/hostapd2.pid
ExecStart=/usr/sbin/hostapd /etc/hostapd/hostapd2.conf -P /run/hostapd2.pid -B

[Install]
WantedBy=sys-subsystem-net-devices-wl1.device

Sohle se setseng ke ho nolofalletsa mohlala o mocha oa hostapd:

# systemctl enable hostapd2

Ke phetho! Hula "mololi" le "raspberry" ka boeona, sheba marang-rang a se nang mohala a u potolohileng.

'Me qetellong, ke batla ho u lemosa ka boleng ba adaptara ea Wi-Fi ea USB le phepelo ea matla ea Raspberry. "Mololi o chesang" o hokahantsoeng ka linako tse ling o ka baka "hatsetso ea raspberry" ka lebaka la mathata a nakoana a motlakase.

Source: www.habr.com

Eketsa ka tlhaloso