• fedora17 用hostapd搭建无线wifi


    搞了一天,才发现这么简单

    • 安装hostapd:

    sudo yum install hostapd

    • 用root权限编辑/etc/hostapd/hostaapd.conf:
     1 #对mac地址的认证方式,这里为了防止别人蹭网,我用了方式1,即只有accept_mac_file里面的MAC可以通过。
     2 macaddr_acl=1
     3 accept_mac_file=/usr/share/doc/hostapd-0.7.3/hostapd.accept
     4 deny_mac_file=/usr/share/doc/hostapd-0.7.3/hostapd.deny
     5 auth_algs=3
     6 ignore_broadcast_ssid=0
     7 
     8 #WPA部分
     9 
    10 wpa=2
    11 wpa_passphrase=(密码)
    12 wpa_key_mgmt=WPA-PSK
    13 wpa_pairwise=TKIP CCMP
    14 rsn_pairwise=TKIP CCMP
    15 driver=nl80211
    16 
    17 #选择无线网卡
    18 
    19 interface=wlan0
    20 
    21 #hw_mode:指定802.11协议,包括 a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g;
    22 hw_mode=g
    23 
    24 #信道
    25 channel=7
    26 ssid=xiaoma

     

    • 安装dhcp:

    sudo yum install dhcp

    • 用root权限编辑/etc/dhcp/dhcpd.conf:
    1 default-lease-time 600;
    2 max-lease-time 7200;
    3 subnet 10.10.10.0 netmask 255.255.255.0 {
    4 range 10.10.10.10 10.10.10.100;
    5 option routers 10.10.10.1;
    6 option domain-name-servers 8.8.8.8;
    7 option ip-forwarding off;
    8 option broadcast-address 10.10.10.255;
    9 }
    • 写一个脚本让各项工作自动化:
     1 #!/bin/bash
     2 
     3 #先杀死之前的hostapd
     4 sudo killall hostapd
     5 #启动hostapd
     6 sudo hostapd -B /etc/hostapd/hostapd.conf
     7 #设置网卡IP
     8 sudo ifconfig wlan0 10.10.10.1 netmask 255.255.255.0
     9 #sudo killall dnsmasq
    10 #sudo dnsmasq
    11 #启动dhcp
    12 sudo systemctl stop dhcpd.service
    13 sudo systemctl start dhcpd.service
    14 sudo systemctl enable dhcpd.servicr
    15 #设定包的转发
    16 sudo bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
    17 sudo iptables -F
    18 sudo iptables -t nat -A POSTROUTING -s 10.10.10.0/24 -o p2p1 -j MASQUERADE
    19 sudo iptables -A FORWARD -i wlan0 -j ACCEPT
    • 赋予它可执行权限:
      chmod 775 (文件名)

      OK,大功告成,以后只要sudo (文件名)执行就是了。

      另外,为了更方便(好吧你可以说我懒),在linux下安装ssh(神器阿~!),在手机上装ConnectBot,然后晚上电脑先不关,上床玩手机。睡觉的时候登陆ssh,shutdown之……

      科技改变生活阿~

     

  • 相关阅读:
    [Javascript] Broadcaster + Operator + Listener pattern -- 10. Define a Function to Set Common Behaviors in Operators
    [Java Spring] Aspect
    [Javascript] Broadcaster + Operator + Listener pattern -- 24. Design choice, ifElse or merge
    [Javascript] Broadcaster + Operator + Listener pattern -- 23. ifElse operator
    [Git] Revert to a old commit
    [Tools] Dendron
    [Java Spring] Spring Expression Language
    [Java Spring] @Profile
    [Java Spring] @Value & override properties by environment variables
    [Java Spring] Implementing Spring Security
  • 原文地址:https://www.cnblogs.com/02xiaoma/p/2977512.html
Copyright © 2020-2023  润新知