ืืฉ ืืืืช ืขืฆืืื ืฉื ืืืืข ืืืื ืืจื ื ืขื ืืฆืืจืช ื ืงืืืืช ืืืฉื ื-Wi-Fi ืืืืืกืกืืช ืขื ืืืฉื Raspberry ืขื ืืื ืืืื. ืืืื, ืื ืืืืจ ืืืฉืชืืฉ ืืืขืจืืช ืืืคืขืื Raspbian ืืงืืจืืช ืฉื Raspberry.
ืืืืืชื ืืกืื ืฉื ืืขืจืืืช ืืืืกืกืืช RPM, ืื ืืืืืชื ืืขืืืจ ืืื ืื ืก ืืงืื ืืื ืืื ืื ืกืืช ืืช CentOS ืืืืืื ืฉืื ืขืืื.
ืืืืืจ ืืกืคืง ืืืจืืืช ืืืื ืช ื ืชื Wi-Fi 5GHz/AC ื-Raspberry Pi 3 Model B+ ืืืืืกืก ืขื ืืขืจืืช ืืืคืขืื CentOS. ืืืื ืืื ืืจืืงืื ืกืื ืืจืืืื ืื ืืขื ืืืืจืื, ืืืืื ืืก - ืฆืืืจ ืืืืืืจ ืฆืืื Wi-Fi ื ืืกืฃ ืืคืื, ืืืืคืฉืจ ืื ืืคืขืื ืื ืืื ืืช ืืืกืคืจ ืืฆืืื (2,4+5GHz).
(ืฉืืืื ืฉื ืชืืื ืืช ืืืื ืืช ืืืืคื ืืืคืฉื)
ืืื ื ืฆืืื ืืื ืฉืืื ืืืืจืืืืช ืงืืกืืืืช ืื ืืคืขืื. ืื ื ืกืืื ืืงืกืืืื 100 Mbps ืื-Raspberry ืฉืื ืืืืืืจ, ืืื ืืืกื ืืช ืืืืืจืืช ืฉื ืกืคืง ืืืื ืืจื ื ืฉืื. ืืื ืืชื ืฆืจืื AC ืื ืื ืืืื, ืื ืืชืืืืจืื ืืชื ืืืื ืืืฉืื ืืฆื ืืืื ืืคืืื ืขื N? ืื ืฉืืืชื ืืช ืขืฆืืื ืืช ืืฉืืื ืืื, ืืื ืืื ืืช ืืื ืืงื ืืช ื ืชื ืืืืชื ืขื ืฉืืื ื ืื ืื ืืช ืืืฆืื ืืืช.
0. ืื ืชืฆืืจื
- ืืืขืฉื, "ืืืฆืจ ืืคืื" ืขืฆืื ืืื ืืงืืืืจ: Pi 3 Model B+ (ืืื ืืืฉืื ืืช ืืืืืจืืืืช ืืืขืจืืฆืื ืื ืืฉืงืื ืฉื 5GHz);
- microSD ืืื >= 4GB;
- ืชืื ืช ืขืืืื ืขื ืืื ืืงืก ืืงืืจื/ืืืชื microSD;
- ืืืื ืืช ืฉื ืืืืื ืืืืช ืืกืคืืงืืช ืืืื ืืงืก, ืืืืืจ ืืืืขื ืืื ืื ืืืืื;
- ืงืืฉืืจืืืช ืจืฉืช ืงืืืืช (eth0) ืืื Raspberry ื-Linux, ืืคืขืืช ืฉืจืช DHCP ืืจืฉืช ืืืงืืืืช ืืืืฉื ืืืื ืืจื ื ืืฉื ื ืืืืฉืืจืื.
ืืขืจื ืงืื ื ืขื ืื ืงืืื ืืืืจืื ื. "ืื ืืืืข ืงืืื, ืืืืฆื ืื..." ืืื ืืขืฉืืช ื ืชื Wi-Fi ืืืืขืืจ ืฆืืื ืืืฉื ืืืื ืืจื ื? ื ืฉืืืจ ืืช ืืชืจืืื ืืืฉืขืฉืข ืืื ืืืืฅ ืืชืืื ืืืืืจ ืืคืฉืื ื ื ืื ืฉื-Raspberry ืืืืืจ ืืจืฉืช ืืืงืืืืช ืืืืฆืขืืช ืืื ืืืฉ ืื ืืืฉื ืืืื ืืจื ื. ืืืงืจื ืื, ืื ื ืฆืืจื ืืืืืืืื ื ืืกืคืช ืืื ืืคืืืืืจ ืืื ืืืืืืจ ืืช ื"ืคืื".
1. ืืชืงื ืืช CentOS
ืืืื ืืชืืืช ืืืืจ ืื, ืืืจืกื ืืจืฆื ืฉื CentOS ืืืืฉืืจ ืืื 32 ืกืืืืืช. ืืืคืฉืื ืืืื ืืจื ื ื ืชืงืืชื ืืืขืืช ืืคืืื ืืืืฆืืขืื ืฉื ืืขืจืืืช ืืคืขืื ืืืื ืืืจืืืืงืืืจืช ARM ืฉื 64 ืกืืืืืช ืืืคืืชืื ื-20%. ืื ื ืืฉืืืจ ืืช ืืจืืข ืืื ืืื ืชืืืื.
ืืืื ืืงืก, ืืืจื ืืช ืืชืืื ื ืืืื ืืืืืช ืขื ืืงืจื ื "-ืคืื ืคืื-"ืืืชืื ืืช ืื ื-microSD:
# xzcat CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1810-sda.raw.xz |
dd of=/dev/mmcblk0 bs=4M
# sync
ืืคื ื ืฉืืชืืืืื ืืืฉืชืืฉ ืืชืืื ื, ื ืกืืจ ืืื ื ืืช ืืืืฆืช ื-SWAP, ื ืจืืื ืืช ืืฉืืจืฉ ืืื ืื ืคื ืืืืื ืื ืคืืจ ื-SELinux. ืืืืืืจืืชื ืคืฉืื: ืฆืืจ ืขืืชืง ืฉื ืืฉืืจืฉ ืืืื ืืงืก, ืืืง ืืช ืื ืืืืืฆืืช ืื-microSD ืืืื ืืจืืฉืื ื (/boot), ืฆืืจ ืฉืืจืฉ ืืืฉ ืืืืืจ ืืช ืชืืื ื ืืืขืืชืง.
ืืืืื ืืคืขืืืืช ื ืืจืฉืืช (ืคืื ืืกืืฃ ืืืืจ)
# 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
ืืืืจ ืคืจืืงืช ืืชืืื ืฉื ืืืืฆืช ืืฉืืจืฉ, ืืืืข ืืืื ืืืฆืข ืื ืืื ืฉืื ืืืื.
ืืฉืืช ืืช SELinux ื /mnt/etc/selinux/config:
SELINUX=disabled
ืขึฒืจึดืืึธื /mnt/etc/fstab, ืืฉืืืจืื ืื ืจืง ืฉื ื ืขืจืืื ืขื ืืืืืฆืืช: ืืชืืื (/boot, ืืื ืฉืื ืืืื) ื-root (ืื ื ืืฉื ืื ืืช ืขืจื UUID, ืืืชื ื ืืชื ืืืืืช ืขื ืืื ืืืืื ืืคืื ืฉื ืืคืงืืื blkid ืืืื ืืงืก):
UUID=6a1a0694-8196-4724-a58d-edde1f189b31 / ext4 defaults,noatime 0 0
UUID=6938-F4F2 /boot vfat defaults,noatime 0 0
ืืืกืืฃ, ืื ื ืืฉื ืื ืืช ืคืจืืืจื ืืืชืืื ืฉื ืืืืื: ืื ื ืืฆืืื ืื ืืืงืื ืืืฉ ืขืืืจ ืืืืฆืช ืืฉืืจืฉ, ืืฉืืืชืื ืืช ืืคืื ืฉื ืืืืข ืืืชืืจ ืืืืื ื(ืืืคืฆืืื ืื) ืืืกืจืื ืขื ืืืืื ืืืงืฆืืช ืืชืืืืช IPv6 ืืืืฉืงื ืจืฉืช:
# cd
# umount /mnt
# mount /dev/mmcblk0p1 /mnt
ืื ื ืืชืืื /mnt/cmdline.txt ืืฆืืจื ืืืื (ืฉืืจื ืืืช ืืื ืืงืคืื):
root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait quiet ipv6.disable_ipv6=1
ืืืฆืข:
# cd
# umount /mnt
# sync
ืื ื ืืกืืจืื ืืืืฉ ืืช ื-microSD ื"ืคืื", ืืคืขืืืื ืืืชื ืืืงืืืื ืืืื ืืืฉื ืืจืฉืช ืืืืฆืขืืช ssh (root/centos).
2. ืืืืจืช CentOS
ืฉืืืฉ ืืชื ืืขืืช ืืจืืฉืื ืืช ืืืืชื ืืขืืจืขืจืืช: ืคืกื, yum-i ืขืืืื, ืืชืืื ืืืืฉ.
ืื ืื ื ืืืืงืื ืืช ื ืืืื ืืจืฉืช ืืจืฉืช:
# yum install systemd-networkd
# systemctl enable systemd-networkd
# systemctl disable NetworkManager
# chkconfig network off
ืฆืืจ ืงืืืฅ (ืืื ืขื ืกืคืจืืืช) /etc/systemd/network/eth0.network:
[Match]
Name=eth0
[Network]
DHCP=ipv4
ืื ื ืืืชืืืื ืืช ื"ืคืื" ืืฉืื ืืงืืืื ืืืฉื ืืจืฉืช ืืืื ืืืืฆืขืืช ssh (ืืืชืื ืฉืืชืืืช ื-IP ืชืฉืชื ื). ืฉืืื ืื ืืื ืืฉืชืืฉืื / Etc / resolv.conf, ืฉื ืืฆืจ ืงืืื ืืื ืขื ืืื ืื ืื ืืจืฉืช. ืืื, ืืืงืจื ืฉื ืืขืืืช ืืคืชืจืื, ืขืจืื ืืช ืชืืื ื. ืืืฉืชืืฉ ื ืคืชืจื ืขื ืืื ืืืขืจืืช ืื ืื ื ืื.
ืื ื ืืกืืจืื ืืช ื"ืืืืชืจ", ืืชืงื ืื ืืืืืฆืื ืืช ืืืขืื ื ืฉื ืืขืจืืช ืืืคืขืื:
# 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
ืื ืฆืจืื cron ืืื ืฉืืื ื ืืขืื ืืช ืืืืื ื
# mkdir /var/log/journal
# systemd-tmpfiles --create --prefix /var/log/journal
# systemctl restart systemd-journald
# vi /etc/systemd/journald.conf
ืืฉืืช ืืช ืืฉืืืืฉ ื-IPv6 ืขื ืืื ืฉืืจืืชืื ืืกืืกืืื (ืื ื ืืจืฉ)/ etc / ssh / sshd_config:
AddressFamily inet
/etc/sysconfig/chronyd:
OPTIONS="-4"
ืืจืืืื ืืืืช ืฉื ืืืื ืขื ื"ืคืื" ืืื ืืืจ ืืฉืื. ืืืืืื ืฉืืืืฅ ืืงืืคืกื ืืื ืืืืืช ืืืืจื ืืฉืืืจ ืืช ืืืฆื ืื ืืืื ืฉื ืืฉืขืื ืขื ืืชืืื ืืืืฉ, ืืฉ ืฆืืจื ืืกื ืืจืื. ืืืื ืืื ืืืืืจ ืืืื ืืฉืืื ืื ืืจืื ืื - ืืืจ ืืืชืงื ืืืชืืื ืืืืืืืืช. ืืชื ืืืื ืืฉื ืืช ืฉืจืชื NTP ืืฉืจืชื ืืงืจืืืื ืืืืชืจ.
/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
ืืื ืืืืืืจ ืืช ืืืืจ ืืืื ืื ื ืฉืชืืฉ ืืจืืง. ืืืืืื ืฉืืืืจื ืฉืื ื ืืื ืืืฆืืจ ื ืชื Wi-Fi ืืคืืขื ืืชืืจืื ืฉื 5GHz, ื ืชืืื ื ืืืคืชืขืืช ืืจืืฉ ืจืืืืืืจ:
# ืืื ืืืืข crda
ืชืงืฆืืจ: ืืืื ืชืืืืืช ืืชืงื ืืช ืขืืืจ ืจืฉืช ืืืืืืืช 802.11
ืืขืืฆืื ืืืจืืฉืข ืืื, ืืืืืกืก ืื ืืื ืขื ืืืืจ ืืืื, "ืืืกืจ" ืขื ืฉืืืืฉ (ืืจืืกืื) ืืชืืจืื 5GHz ืืขืจืืฆืื ืขื ืืกืคืจืื "ืืืืืื". ืืืืืื ืืื ืืืืืืจ ืืืืจ ืืื ืืืื ืืืฉืชืืฉ ืืฉืืืช ืฉื ืืืฉืืช/ืขืจืื, ืืืืืจ ืืืงืื:
# timedatectl set-timezone Europe/Moscow
ืื ื ืืืืฆืื:
# timedatectl set-timezone Etc/GMT-3
ืืืืืฅ' ืืืืจืื ืืชืกืจืืงืช ืืืขืจืืช:
# 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. ืชืืกืคืืช CentOS
ืื ืื ืฉื ืืืจ ืืขืื ืืืื ืืืืืฉื ืืืืจืืืช ืืืืืช ืืืชืงื ืช "ืื ืื" CentOS ืขื Raspberry Pi. ืืชื ืืืืจ ืืกืืคื ืฉื ืืืจ ืืงืื ืืืฉื (ืืืืฉ) ืฉืืืชืื ืชืื ืคืืืช ื-10 ืฉื ืืืช, ืืฉืชืืฉ ืืคืืืช ื-15 ืืื-ืืืื ืฉื ืืืืจืื RAM ื-1.5 ื'ืืื-ืืืื ืฉื microSD (ืืืขืฉื ืคืืืช ื-1 ื'ืืื-ืืืื ืืืื ืืชืืื /ืืชืืื ืื ืฉืื, ืืื ืืืื ื ืืื ืื ืื).
ืืื ืืืชืงืื ืชืืื ืช ื ืงืืืช ืืืฉื Wi-Fi ืืืขืจืืช ืื, ืชืฆืืจื ืืืจืืื ืืขื ืืช ืืืืืืืช ืฉื ืืคืฆืช CentOS ืืกืื ืืจืืืช. ืงืืื ืื, ืืืื ื ืฉืืจื ืืช ืื ืื ืืืชืงื (ืงืืฉืื) ืฉื ืืชืื ื-Wi-Fi ืืืืื ื. ืืืฃ ืืืืช ืฉื ืืคืจืืืงื ืืชืื:
Wifi ื-Raspberry 3B ื-3B+
ืงืืืฆื ืืงืืฉืื Raspberry PI 3B/3B+ ืืื ื ืืืจืฉืื ืืืืืช ืืืคืฆืื ืขื ืืื CentOS Project. ืืชื ืืืื ืืืฉืชืืฉ ืืืืืจืื ืืืืื ืืื ืืืืื ืืช ืืืขืื, ืืงืื ืืช ืืงืืฉืื ืืืืืืืจ ืืช ื-wifi.
ืื ืฉืืกืืจ ืืคืจืืืงื CentOS ืืื ื ืืกืืจ ืื ื ืืฉืืืืฉ ืืืฉื. ืื ื ืืืืืคืื ืืช ืงืืฉืืช ื-Wi-Fi ืืืคืฆื ื-CentOS ืืื ืืืงืืืื ืืืคืชืื ืืจืืืงืื (ืืืชื ืืชืืื ืืื ืืจืืื ืฉื ืืืื...). ืื, ืืืืืื, ืืืคืฉืจ ืื ืืืฉืชืืฉ ื-AC ืืืฆื ื ืงืืืช ืืืฉื.
ืฉืืจืื ืงืืฉืื ืฉื Wi-Fiืืื ืืช ืืื ืืืืฉืืจ ืืืจืกืช ืืงืืฉืื ืื ืืืืืช:
# 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
ืื ื ืจืืืื ืฉืืจืกืช ืืงืืฉืื ืืื 7.45.18 ืืชืืจืื 01.03.2015/XNUMX/XNUMX, ืืืืืจืื ืืช ืงืืืฆืช ืืืกืคืจืื ืืืื: 43455 (brcmfmac43455-sdio.bin).
# 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
ืืฉ ืืืขืชืืง ืืช ืงืืืฆื ืืงืืฉืื ืฉื ืืชืื ื-Wi-Fi ืืืืืืืฃ ืืืชื ื"ืคืื" ืืกืคืจืืื /usr/lib/firmware/brcm/
ืื ื ืืืชืืืื ืืช ืื ืชื ืืขืชืืื ืืืืืืืื ืืกืืคืืง:
# 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
ืืจืกื: 7.45.154 ืืืื 27.02.2018/XNUMX/XNUMX.
ืืืืืื 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. ืชืฆืืจืช ืจืฉืช ืืืชืืจืื ืืคื ืื ื
ืืคื ืฉืืกืืื ื ืืขืื, ื"ืคืื" ืืืืืจ ืืืืฆืขืืช "ืืื" ืืจืฉืช ืืืงืืืืช. ื ื ืื ืฉืืกืคืง ืืกืคืง ืืืฉื ืืืื ืืจื ื ืืืืืง ืืืืชื ืืืคื: ืืืชืืืช ืืจืฉืช ืืฆืืืืจืืช ืืื ืคืงืช ืืืืคื ืืื ืื ืขื ืืื ืฉืจืช ื-DHCP (ืืืื ืขื ืืจืืืช MAC). ืืืงืจื ืื, ืืืืจ ืืืืืจื ืืกืืคืืช ืฉื ืืคืื, ืืชื ืจืง ืฆืจืื "ืืืืจ" ืืช ืืืื ืฉื ืืกืคืง ืืืื ืืกืืืืช. ืืจืฉืื ืืืืฆืขืืช systemd-networkd - ืื ืืฉื ืฉื ืืืืจ ื ืคืจื ืืืื ื ื ืืื ืืื.
ืืืฉืง ื-Wi-Fi ืฉื Raspberry ืืื ืจืฉืช ืืงืืืืช, ืืืชืื ื-Ethernet ืืืืื ื (eth0) ืืื ืืืฆืื ื. ืืืื ื ืกืคืจ ืืช ืืจืฉืช ืืืงืืืืช ืืืืคื ืกืืื, ืืืืืื: 192.168.0.0/24. ืืชืืืช ืคืื: 192.168.0.1. ืฉืจืช DHCP ืืคืขื ืืจืฉืช ืืืืฆืื ืืช (ืืื ืืจื ื).
ืืืืก ืืงืืื (ืกืืืื ืืืจืืช)ืื ืืจื ืคืืืจืื ื ืืจืืื ืชืืื ืืช ืืฉืื system ืืื ืืืื. ืึถื system ืืฉืืงื ืชืืื ืืืช ืืืจืืช ืื ืื ืืืจ, ืขื ืฉืื, ืืื ืืืกืคืืง ืืืชืืืฉืฉ ืืืืช ืืฉืจืืงื ืฉื ืืฉืืคื, ืืืขืืืช ืื ืืคืืืช ืืืชืืื ืืืื ืืคืืื ืืืชืืื ืืช ืืกืืื ืืืืฉืืืื ืฉืืื.
ืืื ืืจืฆืื ืืช, ืืืงืืื ืืืืจืกืืืืช ืฉื ืชืืืืืื ืฉืืืฉืงื ืืชืืืืช ืืขืจืืช ืืืคืขืื systemd ืืื ืกืื ืฉื "ืืฉืจ ืืืืจ" ืขืืืจ ืืืืื LSB ืจืฆืืคืื ืืชืืงืื. ืืืจืื ืืืื, ืืฉืืช ืกืืจ ื"ืืืืก ืืืงืืื" ืืื ืืชืืจืจ ืืคืฉืืื, ืื ืื ืื ืชืืื ืืจืืจื.
ืื ื ืืืฆืจืื ืฉื ื ืืืฉืงื ืืฉืจ ืืืจืืืืืืื ืขื ืฉืืืช ืงืืืขืื: lan ะธ ืึดืึตืจ. "ื ืืืจ" ืืช ืืชืื ื-Wi-Fi ืืจืืฉืื, ืืืช ื-eth0 "ืคืื" ืืฉื ื.
/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=ืื ืืืื ืืช ืืฆืืจื ืืจืื ืืงืจื ื ืืืืฆืขืืช sysctl ืืื ืืืคืฉืจ ื ืืชืื.
ืืชืืืช MACA= ืืืื ื ืืื ืืช ืืืขืจืืช ืื ืฉื ื ืืืืืช ืืฆืืจื.
ืจืืฉืืช ืื ื "ืืืืจืื" ืืช eth0. ืื ื ืืืืจืื ืืช "ืืขืืืช ืืืืืืืช" ืืืฉืชืืฉืื ืจืง ืืืชืืืช ื-MAC ืฉื ืืืฉืง ืื, ืฉื ืืชื ืืืืืช, ืืืฉื, ืื:
# cat /sys/class/net/eth0/address
ืื ืื ื ืืืฆืจืื /etc/systemd/network/eth.network:
[Match]
MACAddress=b8:27:eb:xx:xx:xx
[Network]
Bridge=wan
ืื ื ืืืืงืื ืืช ืงืืืฅ ืืชืฆืืจื ืืงืืื eth0, ืืืชืืืื ืืช ืืคืื ืืืงืืืื ืืืื ืืืฉื ืืจืฉืช (ืกืืืจ ืืื ืื ืฉืืชืืืช ื-IP ืชืฉืชื ื):
# rm -fv /etc/systemd/network/eth0.network
# reboot
5.DNSMASQ
ืืืื ืช ื ืงืืืืช ืืืฉื ื-Wi-Fi, ืฉืื ืืืจ ืื ืื ืฆื ืืื ืืชืืง ืฉื ืื ืกืืกืง + hostapd ืขืืืื ืื ืืืื ื ืืช ืื. ืืืขืชื.
ืื ืืืฉืื ืฉืื ืื...
ื ืชืืื ืขื dnsmasq:
# yum install dnsmasq
ืชืื ืืช / 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
ืืขืจืื ืืืชื ืืคื ืืขืืื.
ืืื ืืืืืกืื /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
ื"ืงืกื" ืืื ืืืื ืืคืจืืืจ bind-dynamic, ืฉืืืืจ ืืืืื dnsmasq ืืืืืช ืขื ืฉืืื ืืืคืืข ืืืขืจืืช interface=lan, ืืื ืืืชืขืืฃ ืืืชืงืฃ ืฉื ืืืืืืช ืืื ืืืืจ ืืืชืืื.
# systemctl enable dnsmasq
# systemctl start dnsmasq; journalctl -f
6. HOSTAPD
ืืืืกืืฃ, ืชืฆืืจืืช ืืงืกื ืฉื hostapd. ืืื ืื ืกืคืง ืฉืืืฉืื ืงืืจื ืืช ืืืืืจ ืืื ืืืืคืืฉ ืืืจ ืืงืืืื ืืืงืจืื ืืืื ืืืืืง.
ืืคื ื ืืชืงื ืช hostapd, ืขืืื ืืืชืืืจ ืขื "ืืขืืืช ืืืืืืืช". ืืชืื ื-Wi-Fi ืืืืื ื wlan0 ืืืื ืืฉื ืืช ืืช ืฉืื ืืงืืืช ื-wlan1 ืืขืช ืืืืืจ ืฆืืื USB Wi-Fi ื ืืกืฃ. ืืื, ื ืชืงื ืืช ืฉืืืช ืืืืฉืงืื ืืฆืืจื ืืืื: ื ืืฆืื ืฉืืืช ืืืืืืืื ืืืชืืืื (ืืืืืืืื) ืื ืงืฉืจ ืืืชื ืืืชืืืืช MAC.
ืขืืืจ ืืชืื ื-Wi-Fi ืืืืื ื, ืฉืืื ืขืืืื wlan0:
# cat /sys/class/net/wlan0/address
b8:27:eb:xx:xx:xx
ืื ืื ื ืืืฆืจืื /etc/systemd/network/wl0.link:
[Match]
MACAddress=b8:27:eb:xx:xx:xx
[Link]
Name=wl0
ืืขืช ื ืืื ืืืืืื ืืื Wl0 - ืืื Wi-Fi ืืืื ื. ืื ื ืืืชืืืื ืืช ืืคืื ืืื ืืืืื ืืืช.
ืืืชืงืื:
# yum install hostapd wireless-tools
ืงืืืฅ ืชืฆืืจื /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
ืืื ืืฉืืื ืืจืืข
# hostapd /etc/hostapd/hostapd.conf
hostapd ืืชืืื ืืืฆื ืืื ืืจืืงืืืื, ืืืฉืืจ ืืช ืืฆืื ืืงืื ืกืืื. ืื ืืื ืฉืืืืืช, ืืงืืืืช ืืชืืืืื ืืืฆื AC ืืืืื ืืืชืืืจ ืื ืงืืืช ืืืืฉื. ืืื ืืขืฆืืจ ืืช hostapd - Ctrl-C.
ืื ืื ืฉื ืืชืจ ืืื ืืืคืขืื ืืช hostapd ืืืชืืื ืืืขืจืืช. ืื ืืชื ืขืืฉื ืืช ืืืืจ ืืกืื ืืจืื (systemctl enable hostapd), ืื ืืืืจ ืืืชืืื ืืื ืืชื ืืืื ืืงืื ืฉื "ืืชืืืื ืืื" ืขื ืืืืื ื "ืืืฉืง wl0 ืื ื ืืฆื". ืืชืืฆืื ื"ืชืืื ืืืืื ืืงืืื", hostapd ืคืขื ืืืจ ืืืชืจ ืืื ืฉืืงืจื ื ืืฆื ืืช ืืืชืื ืืืืืืื.
ืืืื ืืจื ื ืืื ืืชืจืืคืืช: ืืคืกืง ืืื ืืืืืฅ ืืคื ื ืืคืขืืช ืืืืื (ืืกืคืจ ืืงืืช), ืืขื ืืืื ืืืจ ืฉืขืืงื ืืืจ ืืืคืขืช ืืืืฉืง ืืืคืขืื (ืืืืฉ) ืืช ื-hostpad. ืืคืชืจืื ืืช ืืขืฉืืื ืืืื, ืืื ื ืืจื ืืืืขืจืื. ืื ื ืงืืจืืื ืืืืืื ืืขืืจื system ืขื ื"ืืืจืืช" ืื"ืืฉืืืืช" ืื"ืชืืืช" ืฉืื.
ืืขืชืง ืืช ืงืืืฅ ืฉืืจืืช ืืืคืฆื ืื /etc/systemd/system/hostapd.service:
# cp -fv /usr/lib/systemd/system/hostapd.service /etc/systemd/system
ืืฆืืฆื ืืช ืชืืื ื ืืฆืืจื ืืืื:
[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
ืืงืกื ืฉื ืงืืืฅ ืืฉืืจืืช ืืืขืืืื ืืืื ืืงืฉืืจื ืืืื ืืืช ืฉื hostapd ืืืขื ืืืืฉ - ืืืฉืง wl0. ืืืฉืจ ืืืืฉืง ืืืคืืข, ืืืืื ืืชืืื; ืืืฉืจ ืืื ื ืขืื, ืืื ื ืขืฆืจ. ืืื ืื ืืืื ืืจื ื - ืืื ืืืชืื ืืช ืืืขืจืืช. ืืื ืืงื ืื ืชืืื ืฉืืืืฉืืช ืืืืืื ืืขืช ืืืืืจ ืืชืื Wi-Fi USB ืืคืื.
ืขืืฉืื ืืชื ืืืื:
# systemctl enable hostapd
# reboot
7. IPTABLES
"ืื???" ยฉ ืื, ืื! ืืฃ ืืื system. ืืื ืงืืืืื ืืช ืืืฉื ืืืช (ืืฆืืจื firewalld), ืฉืืกืืคื ืฉื ืืืจ ืขืืฉืื ืืช ืืืชื ืืืืจ.
ืืืื ื ืฉืชืืฉ ืืืฉื ืืืืื iptables, ืฉืฉืืจืืชืื, ืืืืจ ืืคืขืืชื, ืืืขื ื ืืช ืืืื ืืจืฉืช ืืชืื ืืงืจื ื ืืืกืืจื ืืฉืงื ืืืื ืืืืฉืืจ ืชืืฉื ืืืื ืืฆืจืื ืืฉืืืื. systemd ืืฉ ืืืื ืื IPMasquerade=, ืืื ืขืืืื ื ืคืงืื ืืช ืชืจืืื ืืืชืืืืช (NAT) ืืืืืช ืืืฉ ืืืื iptables.
ืืืชืงืื:
# yum install iptables-services
# systemctl enable iptables ip6tables
ืื ื ืืขืืืฃ ืืืืกื ืืช ืชืฆืืจืช iptables ืืกืงืจืืคื (ืืืืื):
#!/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
ืื ื ืืืฆืขืื ืืช ืืกืงืจืืคื ืืขืื ืืืืืืื ืืช ืืืืืืช ืืืฆืืจ ืืืืืจื SSH ืงืืืืื ืืืฉืื ืขื ื-Raspberry. ืื ื ืืื, ืืฆืจื ื ื ืชื Wi-Fi, ืฉืืืฉื ืืืื "ืืจื ืืืื ืืจื ื" ืืกืืจื ืืืจืืจืช ืืืื - ืขืืฉืื ืจืง "ืืืืืืจ". ืื ืื ื ืืืืจืื ืืช ืืื ืืืชืจื ื ืฉื ืืกืคืง ืืืชืืืืื ืืืืืฉ!
8. ืืื ืืก: +2,4GHz
ืืืฉืจ ืืจืืืชื ืืช ืื ืชื Raspberry ืืจืืฉืื ืืืืฆืขืืช ืืฉืจืืื ืืืชืืืจ ืืขืื, ืืืืืชื ืืกืคืจ ืืืื'ืืื ืืืืชื, ืฉืืฉื ืืืืืืช ืขืืฆืื ื-Wi-Fi ืฉืืื, ืื ืืืื ืืจืืืช ืืช ื"ืคืื" ืืื. ืืืืจื ืืืืฉ ืฉื ืื ืชื ืืขืืืื ื-802.11b/g/n ืืืืชื ืื ืกืคืืจืืืืืช, ืืืืืื ืฉืืืืืจืืช ืืืงืกืืืืืช "ืืืืืืจ" ืืืงืจื ืื ืื ืขืืชื ืขื 40 Mbit, ืืกืคืง ืืืื ืืจื ื ืืืืื ืขืืื ืืฆืืข ืื 100 (ืืืืฆืขืืช ืืื).
ืืืขืฉื, ืคืชืจืื ืืืขืื ืืืจ ืืืืฆื: ืืืฉืง Wi-Fi ืฉื ื ืืคืืขื ืืชืืจ ืฉื 2,4 ืืืื-ืืจืฅ, ืื ืงืืืช ืืืฉื ืฉื ืืื. ืืืืื ืกืืื ืงื ืืชื ืื ืืช ืืจืืฉืื ื, ืืื ืืช "ืฉืจืืงืช" ื-USB Wi-Fi ืืฉื ืืื ืฉื ืชืงืืชื ืื. ืืืืืจ ืืชืืืกืจ ืืฉืืืืช ืขื ืขืจืืช ืืฉืืืื, ืชืืืืืช ืืืจืขืื ื ARM Linux ืืืืคืฉืจืืช ืืขืืื ืืืฆื AP (ืืื ืืื ืืจืืฉืื ืฉืืชืืื).
ืื ื ืืืืืจืื ืืช "ืืืฉืจืืงืืช" ืืื ืืืืื ืขื ืืชืื ื-Wi-Fi ืืืืื ื.
ืจืืฉืืช, ืืืื ื ืฉื ื ืืช ืฉืื ื 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
ืื ื ื ืคืงืื ืืช ื ืืืื ืืืฉืง ื-Wi-Fi ืืืืฉ ืืืื hostapd ืืืื ื ืคืจื, ืืฉืจ ืืชืืื ืืืืขืฆืจ ืืืชืื ืื ืืืืืช ืฉื "ืฉืจืืงื" ืืืืืจืช ืืืืื ืืืขืจืืช: wl1.
ืงืืืฅ ืชืฆืืจื /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]
ืืชืืื ืฉื ืงืืืฅ ืื ืชืืื ืืฉืืจืืช ืืืื ืฉื ืืชืื ื-USB Wi-Fi, ืื ืฉืืขืชืง/ืืืืง ืื ืืื ืขืืื ืืืืืฉื.
ืืขืชืง ืืช ืงืืืฅ ืฉืืจืืช ืืืคืฆื ืื /etc/systemd/system/hostapd2.service:
# cp -fv /usr/lib/systemd/system/hostapd.service /etc/systemd/system/hostapd2.service
ืืฆืืฆื ืืช ืชืืื ื ืืฆืืจื ืืืื:
[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
ืื ืื ืฉื ืืชืจ ืืื ืืืคืฉืจ ืืืคืข ืืืฉ ืฉื hostapd:
# systemctl enable hostapd2
ืื ืืื! ืืฉืื ืืช ื"ืืฉืจืืงืืช" ืืืช ื"ืคืื" ืขืฆืื, ืชืกืชืื ืขื ืืจืฉืชืืช ืืืืืืืืืช ืกืืืื.
ืืืืกืืฃ, ืื ื ืจืืฆื ืืืืืืจ ืืืชื ืืืื ืืืืืืช ืฉื ืืชืื ื-USB Wi-Fi ืืืกืคืงืช ืืืฉืื ืฉื ืืคืื. "ืืฉืจืืงืืช ืืื" ืืืืืจืช ืืืืื ืืคืขืืื ืืืจืื ื"ืืงืคืืช ืคืื" ืขืงื ืืขืืืช ืืฉืืืืืช ืงืฆืจืืช ืืืื.
ืืงืืจ: www.habr.com