+- RPi -------+
+---+ 10.10.0.2 | +- Laptop ----+
| | WLAN AP +-))) (((-+ WLAN Client |
| | Bridge | | 10.10.0.5 |
| +-------------+ +-------------+
+- Router ----+ |
| Firewall | | +- PC#2 ------+
(Internet)---WAN-+ DHCP server +-LAN-+---+ 10.10.0.3 |
| 10.10.0.1 | | +-------------+
+-------------+ |
| +- PC#1 ------+
+---+ 10.10.0.4 |
+-------------+Cài các gói phụ thuộc
sudo apt install -y hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapdCấu hình bridge interface
Tạo file /etc/systemd/network/bridge-br0.netdev và thêm nội dung sau để tạo br0 interface:
[NetDev]
Name=br0
Kind=bridge
Tạo file /etc/systemd/network/br0-member-eth0.network và thêm nội dung sau để gán eth0 vào br0:
[Match]
Name=eth0
[Network]
Bridge=br0
Bật service systemd-networkd tự động chạy khi khởi động máy:
sudo systemctl enable systemd-networkdCấu hình IP cho bridge
Dùng dhcpcd để tự động lấy ip cho bridge interface nhưng không cấp riêng cho wlan0 và eth0.
Thêm nội dung sau vào file /etc/dhcpcd.conf:
denyinterfaces wlan0 eth0
interface br0Gỡ khóa wireless device
sudo rfkill unblock wlanCấu hình AP
Mở file /etc/hostapd/hostapd.conf và sửa như sau:
country_code=US
interface=wlan0
bridge=br0
ssid=YOUR_SSID
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=YOUR_PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Đổi YOUR_SSID và YOUR_PASSWORD sang giá trị bạn mong muốn.
Khởi động lại máy
sudo rebootTham khảo
- https://web.archive.org/web/20221210043642/https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-bridged-wireless-access-point
Bình luận