美文网首页WiFi安全杂谈
Ubuntu下使用Hostapd搭建热点

Ubuntu下使用Hostapd搭建热点

作者: qingxp9 | 来源:发表于2015-11-07 15:05 被阅读2059次

    环境:Ubuntu
    通过eth0连接外网,通过wlan0建立热点

    1.安装isc-dhcp-server

    su
    apt-get install isc-dhcp-server
    

    2.配置DHCP

    vim /etc/default/isc-dhcp-server
    

    INTERFACES="wlan0"

     vim /etc/dhcp/dhcpd.conf
    

    option domain-name-servers 8.8.8.8, 114.114.114.114;
    default-lease-time 600;
    max-lease-time 7200;

    subnet 10.5.5.0 netmask 255.255.255.0 {
    range 10.5.5.2 10.5.5.250;
    option routers 10.5.5.1;
    option broadcast-address 10.5.5.255;
    }

    ifconfig wlan0 10.5.5.1/24
    service isc-dhcp-server restart
    

    打开数据包转发,通过iptables将无线网卡的流量转发到本机联网的端口eth0(如果你用无线上网改为wlan0):

    echo "1" > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    

    4.通过hostapd建热点

    git clone https://github.com/OpenSecurityResearch/hostapd-wpe
    wget http://hostap.epitest.fi/releases/hostapd-2.2.tar.gz
    tar -zxf hostapd-2.2.tar.gz
    cd hostapd-2.2
    patch -p1 < ../hostapd-wpe/hostapd-wpe.patch
    cd hostapd
    make
    

    新建配置文件

    vim 1.conf
    

    interface=wlan0
    driver=nl80211
    ssid=test
    channel=6
    hw_mode=g
    auth_algs=1
    wpa=3
    wpa_passphrase=12345678
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP
    rsn_pairwise=CCMP

    ./hostapd-wpe 1.conf
    

    掏出设备尝试连接test的无线,密码12345678,测试是否能成功上网。
    如果遇到以下错误:

    Configuration file: hostapd.conf
    nl80211: Could not configure driver mode
    nl80211 driver initialization failed.
    hostapd_free_hapd_data: Interface wlan0 wasn't started

    请执行,并重新运行hostapd

    nmcli nm wifi off
    rfkill unblock wlan

    参考:
    http://roylez.herokuapp.com/2011/08/11/hostapd.html?utm_source=tuicool&utm_medium=referral

    相关文章

      网友评论

        本文标题:Ubuntu下使用Hostapd搭建热点

        本文链接:https://www.haomeiwen.com/subject/lbmchttx.html