我有一个树莓派3B与树莓派操作系统精简版,我想使用的Pi作为无线局域网热点和服务器与eth0上的静态IP (169.254.1.100)。
因此,我安装了dnsmasq和hostapd,并编辑了以下文件:
我编辑了/etc/dnsmasq.conf:
# DHCP-Server aktiv für WLAN-Interface
interface=wlan0
# DHCP-Server nicht aktiv für bestehendes Netzwerk
no-dhcp-interface=eth0
# IPv4-Adressbereich und Lease-Time
dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,24h
# DNS
dhcp-option=option:dns-server,192.168.1.1我添加到/etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.1.1/24我编辑了/etc/hostapd/hostapd.conf:
interface=wlan0
ssid=PI_WLAN
channel=1
hw_mode=g
ieee80211n=1
ieee80211d=1
country_code=AT
wmm_enabled=1
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=somePassword我使用以下命令启动WLAN
> sudo hostapd -dd /etc/hostapd/hostapd.conf只有当eth0不是静态的时,才创建无线局域网,但是当IP是静态的时,DHCP无法启动,并且无线局域网不工作。
即使为WLAN0禁用了动态主机配置协议,如何为eth0启用动态主机配置?
致以亲切的问候,沃尔夫冈
发布于 2021-03-03 16:53:36
我不是很清楚,但是..我的pi有一个wlan热点和一个以太网接口上的静态ip地址。这是你想要的吗?在本例中,我只需编辑/etc/dhcpcd.conf,添加:
interface eth0
static ip_address=192.168.0.4/24
static routers=192.168.0.254
static domain_name_servers=192.168.0.254 8.8.8.8
interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant然后我安装了hostapd,这是我的hostapd.conf
country_code=IT
interface=wlan0
ssid=myssd
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP我的dnsmasq.conf是这样的(但老实说,我不记得碰过它,也许这不是必须的,也可能是自动完成的……)
interface=wlan0 # Listening interface
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
# Pool of IP addresses served via DHCP
domain=wlan # Local wireless DNS domain
address=/gw.wlan/192.168.4.1
# Alias for this router我有一个定义了ssid的wlan热点,它为我分配了一个动态IP地址,而raspberry则位于另一个具有静态ip的LAN上。
发布于 2021-03-05 15:07:59
谢谢你的回答,但我无法使用dhcpcd.conf配置静态IP,即使我使用文件?中的预定义值之前我使用/etc/network/interface文件定义了静态IP:
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto eth0
iface eth0 inet static
address 169.254.1.100
netmask 255.255.255.0
gateway 169.254.1.1静态IP是用dhcpcd.conf定义的,还是用接口文件定义的,有区别吗?dhcpcd.conf看起来是怎样拥有同样的行为的呢?
致以亲切的问候,沃尔夫冈
https://stackoverflow.com/questions/66420346
复制相似问题