If you have Linux desktop connected to the Internet (wire, LTE modem) and it has a wifi card which is managed by wpa_supplicant, you can easily setup this computer as WiFi access point. You even don't need hostapd - just wpa_supplicant and dhcp server software.

Follow these steps:

  1. wpa_supplicant should be compiled with ap USE flag:

    echo 'net-wireless/wpa_supplicant ap' | sudo tee -a /etc/portage/package.use
    
  2. Configure wpa_supplicant.conf as follows (mode=2 is Access Point mode, for more see documentation):

    network={
        ssid="AP-NAME"
        mode=2
        key_mgmt=WPA-PSK
        psk="password"
        frequency=2437
    }
    

    You can choose right frequncy according to the table on wikipedia.

  3. Install and setup DHCP server. I'm using net-misc/dhcp with server USE flag:

    echo 'net-misc/dhcp server' | sudo tee -a /etc/portage/package.use
    
  4. Configure /etc/dhcp/dhcpd.conf

    subnet 192.168.6.0 netmask 255.255.255.0 {
      range 192.168.6.20 192.168.6.30;
      option domain-name-servers 8.8.8.8;
      option routers 192.168.6.1;
      option broadcast-address 192.168.6.255;
      default-lease-time 600;
      max-lease-time 7200;
    }
    
  5. Start wifi interface, controlled by wpa_supplicant and DHCP server:

    sudo /etc/init.d/net.wifi start
    sudo ifconfig wifi 192.168.6.1/24
    sudo mkdir /var/run/dhcp
    sudo touch /var/lib/dhcp/dhcpcd.leases
    sudo /usr/sbin/dhcpd -f -user dhcp -group dhcp wifi
    
  6. Setup forwarding. Suppose 192.168.4.2 wired to the Internet

    sudo sysctl -w net.ipv4.ip_forward=1
    sudo iptables -t nat -A POSTROUTING --source 192.168.6.0/24 -j SNAT --to 192.168.4.2
    

That's all! Now you can connect to your Access Point. All these


Comments

comments powered by Disqus