Use wireless network card sharing WiFi (AP) in Ubuntu)

Source: Internet
Author: User

Method 1:

I have never successfully enabled WiFi hotspots available for Android In ubuntu.

However, I recently used Ubuntu to install kubuntu-desktop. When I used kubuntu-desktop, I found that I used its own network manager, which is one more mode than Ubuntu's default one: the Network Manager provided by Ubuntu only has the architecture and ad-hoc mode, while the network manager of kubuntu-desktop has an Access Poin mode, and you can choose to create wireless (shared ), ubuntu can only choose to create a new wifi.

But if I don't want to use kubuntu-desktop But Ubuntu, how can I enable WiFi hotspots available for Android in this way?

The answer is: Go to the Ubuntu Software Center, enter the search network, and select KDE-nm-connection-editor for installation.

Open the software-create-Wireless (shared), and select access point in mode to enable it.

Method 2:

Android does not support ad-hoc wifi. this article describes how to implement a soft AP in Ubuntu. (your wireless network card must support AP, and the computer is connected to the Internet through a local router instead of a broadband connection .)
Use the hostapd tool, dnsmasq. My environment is ubuntu12.10; mobile Android 2.3.4; Nic w311mi. The wired network uses a static IP address. (the following code will remove comments when actually used)
1. First, install the software:

sudo apt-get install hostapd dnsmasq


2. Configure hostapd:

Sudo gedit/etc/hostapd. confinterface = wlan0driver = nl80211ssid = oldfeel # The SSID can be changed to your preferred name hw_mode = gchannel = 11dtim_period = duration = Signature = 0auth_algs = duration = 0wpa = duration = 12345678 # Set your password, do not leave a space after the best password wpa_key_mgmt = WPA-PSKwpa_pairwise = tkiprsn_pairwise = CCMP


3. Configure DNS:

Sudo gedit/etc/dnsmasq. confinterface = wlan0bind-interfaces # This is only listening to wlan0, it will not detect all cards except T-interface = lodhcp-range = 192.168.10.100, 192.168.10.199, 6 h # Set the DHCP address range, that is, the lease time is 6 hours DHCP-option = 3, 192.168.10.1 # configure the gateway DHCP-option = 6 for the mobile phone, 8.8.8.8 # configure DNS for the mobile phone, please change it to the Internet DNS address


4. Edit the startup script:

Sudo gedit/usr/bin/myap #! /Bin/sh # Add routing rules iptables-fiptables-xiptables-T nat-fiptables-T nat-xiptables-T Nat-A postrouting-s 192.168.10.0/24-O eth0- j masqueradeiptables-a forward-s 192.168.10.0/24-O eth0-J acceptiptables-a forward-D 192.168.10.0/24-M conntrack -- ctstate established, related-I eth0-J accept # dnsmasq and named under normal circumstances, the named of BIND accounts for 53 ports, # dnsmasq cannot start, so I used killall named to kill named and then start dnsmasq. Killall hostapdifconfig wlan0 192.168.10.1 # "-B" is run in the background, followed by hostapd. conf must be named path. hostapd-B/etc/hostapd. conf/etc/init. d/dnsmasq restart # After dnsmasq is started, the computer will suddenly fail to access the network. # Because dnsmasq has changed/etc/resolv. conf. You can add a line in/etc/resolv. conf # nameserver x. x # To the DNS server address, and modify it according to your own situation. Echo "nameserver 8.8.8.8">/etc/resolv. conf


5. Modify/usr/bin/myap permissions:

sudo  chmod -R 777 /usr/bin/myap


6. Make sure that the forwarding function is enabled.

sudo suecho "net.ipv4.ip_forward=1" >> /etc/sysctl.confecho 1 >/proc/sys/net/ipv4/ip_forwardexit


7. When you want to share WiFi, ensure that your computer can access the Internet and then run

sudo myap


8. If the wired connection is not hosted after the restart, modify NetworkManager. conf as follows (then restart ):

sudo gedit /etc/NetworkManager/NetworkManager.conf[main]plugins=ifupdown,keyfiledns=dnsmasqno-auto-default=B4:B5:2F:CB:9E:5C,[ifupdown]managed=true


9. After the phone connection is successful, you can use the UC browser to open http: // 192.168.10.1/to connect to the server on your computer .. (The mini version of openg browser cannot be opened... it has been depressing for a long time ..)


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.