您的位置:首页 > 运维架构 > Linux

linux下分享信号个android手机

2013-08-16 00:58 344 查看
1.首先你的电脑在win7下可以分享信号给android手机用

2.

sudo apt-get install hostapd dnsmasq

3.安装完成后在终端输入:

sudo service hostapd stop

sudo service dnsmasq stop

sudo update-rc.d hostapd disable

sudo update-rc.d dnsmasq disable

4.你需要配置文件

sudo gedit /etc/dnsmasq.conf如果是KDE的话就是sudo gedit /etc/dnsmasq.conf

# Bind to only one interface

bind-interfaces

# Choose interface for binding

interface=wlan0

# Specify range of IP addresses for DHCP leasses

dhcp-range=192.168.150.2,192.168.150.10

5.然后是hostpad配置文件

sudo gedit /etc/hostapd.conf

# Define interface

interface=wlan0

# Select driver

driver=nl80211

# Set access point name

ssid=myhotspot

# Set access point harware mode to 802.11g

hw_mode=g

# Set WIFI channel (can be easily changed)

channel=6

# Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)

wpa=2

wpa_passphrase=mypassword

这里的mypassword可以自己定义

6.然后创建快捷启动文件随便在哪里创建start.sh

输入:

#!/bin/bash

# Start

# Configure IP address for WLAN

sudo ifconfig wlan0 192.168.150.1

# Start DHCP/DNS server

sudo service dnsmasq restart

# Enable routing

sudo sysctl net.ipv4.ip_forward=1

# Enable NAT

sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

# Run access point daemon

sudo hostapd /etc/hostapd.conf

# Stop

# Disable NAT

sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE

# Disable routing

sudo sysctl net.ipv4.ip_forward=0

# Disable DHCP/DNS server

sudo service dnsmasq stop

sudo service hostapd stop

然后保存。用root权限运行start.sh

运行结果大概是:

* Restarting DNS forwarder and DHCP server dnsmasq [ OK ]

/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf

net.ipv4.ip_forward = 1

Configuration file: /etc/hostapd.conf

Failed to update rate sets in kernel module

Using interface wlan0 with hwaddr 74:de:2b:43:0b:9e and ssid 'myhotspot'

wlan0: STA 10:68:3f:3d:3c:04 IEEE 802.11: authenticated

wlan0: STA 10:68:3f:3d:3c:04 IEEE 802.11: associated (aid 1)

wlan0: AP-STA-CONNECTED 10:68:3f:3d:3c:04

wlan0: STA 10:68:3f:3d:3c:04 RADIUS: starting accounting session 520D0582-00000000

wlan0: STA 10:68:3f:3d:3c:04 WPA: pairwise key handshake completed (RSN)

wlan0: STA 10:68:3f:3d:3c:04 WPA: group key handshake completed (RSN)

我的运行环境:deepin 12.12.1 64位 + nexus 4 测试成功

原文地址:http://forum.xda-developers.com/showthread.php?t=2009381
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: