Open a wireless hotspot on a computer in Ubuntu system

Source: Internet
Author: User
Tags network function

Create hotspots by using the system's own network function

Please note: You must have a wireless card that you can use to create an AP hotspot. If you don't know how to confirm it, enter IW list in the terminal (Terminal).

If you don't have IW installed, you can use the sudo apt-get install IW to install it under Ubuntu.

After you type the IW list, look at the supported interface mode, and you should see the AP in an entry similar to the following:

Supported interface modes:

* IBSS

* Managed

* AP

* Ap/vlan

* Monitor

* Mesh Point

Let's take a look at it step by step:

1. Disconnect WiFi connection. Use a wired network to access your notebook.

2, in the top bar panel click on the Network icon-> Edit connections (edit connection)-> in the pop-up window click Add (Add) button.

3. Choose Wi-Fi in the Drop-down menu.

4, Next:

A, enter a link name such as: Hotspot 1

b, enter an SSID for example: Hotspot 1

C, Selection mode: infrastructure (infrastructure)

D, Device MAC address: Select your wireless device in the Pull-down menu

5, enter the Wi-Fi Security tab, select WPA & WPA2 Personal and enter the password.

6, enter the IPV4 Settings tab, in the method (methods) Drop-down menu, select Shared to other computers (share to another computer).

7, enter the IPv6 tab, in Method (methods) set to ignore ignore (only if you do not use the IPV6) 8, click the Save button to save the configuration.

9, open the terminal from the Menu/dash.

10, modify the connection you just created using network settings.

Using the Gedit Editor:

The code is as follows:

Gksu Gedit/etc/networkmanager/system-connections/hotspot

Replace the name Hotspot with the connection name you made in step 4th.

A, change the mode=infrastructure to Mode=ap and save the file.

b, once you've saved the file, you should be able to see the AP you just built on the Wifi menu. (If not, please turn off/Open the Wifi option in the top bar once)

11. You can connect your equipment to WiFi now. Has passed the 5.0 Millet 4 test of Android. (Download 1GB files to test speed and stability)

Create hotspots with HOSTAPD

1: Installation hotspot generation tool, HOSTAPD

The code is as follows:

sudo apt-get install HOSTAPD

2: Install the DHCP,DHCP server can be used for dynamic allocation of IP, can also be combined with TFTP server for network installation server, for the installation of PXE-enabled clients.

The code is as follows:

sudo apt-get install Dhcp3-server

3: Create a new hostapd.conf file, this file is very important, contains the encryption way we generate hotspots and the access password of the hotspot.

The code is as follows:

sudo nano/etc/hostapd.conf

The contents are as follows:

The code is as follows:

Interface=wlan0

< p>driver=nl80211

< P>ssid=xxxxxx #xxxx是你用手机访问时, see the name of the wireless network

< p>hw_mode=g

< p>channel=10

< p>macaddr_acl=0

< p>auth_algs=3

< p>wpa=2

< p>wpa_passphrase=xxxxxx #xxxx是你用手机访问时, you need to enter the password. Set a password yourself

< P>WPA_KEY_MGMT=WPA-PSK

< p>wpa_pairwise=tkipccmp

< p>rsn_pairwise=tkipccmp

4: Configure DHCP (This step is very important, before is not such a step, so mobile phone even hot, has been the process of obtaining IP address)

The code is as follows:

sudo nano/etc/dhcp/dhcpd.conf

At the end of the file, add the following:

The code is as follows:

Subnet 192.168.0.0 netmask 255.255.255.0

< p>{

< P>range 192.168.0.2 192.168.0.10;

< p>option routers 192.168.0.1;

< p>option domain-name-servers 8.8.8.8; #这个地方8.8.8.8 fill in the IP of the DNS server, Hubei can fill this out: 202.114.0.242

< P;}

5: The final step, write a script, put in your home directory (or you think convenient location), easy to open hot

The code is as follows:

Nano ap.sh

The contents are as follows:

The code is as follows:

#!/bin/bash

#this is AP Create script

< P>sudo ifconfig wlan0 192.168.0.1 netmask 255.255.255.0

sudo dhcpd wlan0-pf/var/run/dhcp-server/dhcpd.pid

sudo bash-c "echo 1>/pro/sys/net/ipv4/ip_forward"

sudo iptables-t nat-a postrouting-o eth0-j Masquerade

sudo hostapd/etc/hostapd.conf &

ap.sh scripts are saved, modifications become executable permissions:

The code is as follows:

sudo chmod 776 ap.sh

Once the above work is done, you can enjoy the results, in the directory where the ap.sh script is located, enter the command:

The code is as follows:

sudo./ap.sh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.