debain用udhcpd做htcp服务器
安装必备程序
apt-get install udhcpd
udhcpd主要为连接到WiFi的设备自动分配IP地址的,当然你也可以换用你所熟悉的软件。
配置udhcpd,编辑/etc/udhcpd.conf,主要内容如下:
start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices. end 192.168.42.20 interface wlan0 # The device uDHCP listens on. remaining yes opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use. opt subnet 255.255.255.0 opt router 192.168.42.1 # The Pi's IP address on wlan0 which we will set up shortly. opt lease 864000 # 10 day DHCP lease time in seconds
接下来编辑/etc/default/udhcpd并且将下面这行注释掉,以使DHCP Server正常工作:
#DHCPD_ENABLED="no"
配置无线网卡
通过下面的命令给无线网卡设置一个IP地址:
ifconfig wlan0 192.168.42.1
当然为了下次启动仍然有效,我们需要配置/etc/network/interfaces文件:
vim /etc/network/interfaces
注释掉所有的关于无线网卡的部分,最后应该变成下面所示:
auto wlan1 iface wlan1 inet static address 192.168.42.1 netmask 255.255.255.0
启用服务
/etc/init.d/udhcpd start
本文出自 蓝鹰博客,转载时请注明出处及相应链接。
本文永久链接: http://www.lanyingblog.com/blog/2301.html