I want to establish a adhoc connection between my laptop running debian wheezy with my android nexus 7 tablet. What I have done is installed hostapd
in my laptop with this configuration.
interface=wlan0
driver=nl80211
ssid=myapppp
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=passpass
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Now I can see the access point listed in my android wifi settings. I gave static IP in my nexus 7 settings and gave connect and it got connected. The settings I gave in nexus 7 is
IP : 192.168.1.3
Gateway: 192.168.1.1
Network prefix length: 24
DNS: 8.8.8.8
Now how could I communicate with my laptop? I need to give IP to my laptop also? Which settings should I use?
My ifconfig
gives
**mon.wlan0 Link encap:UNSPEC HWaddr D0-DF-9A-EC-E6-09-3A-30-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)**
wlan0 Link encap:Ethernet HWaddr d0:df:9a:ec:e6:09
inet addr:10.0.3.12 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::d2df:9aff:feec:e609/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:95004 errors:0 dropped:0 overruns:0 frame:0
TX packets:78421 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:57369956 (54.7 MiB) TX bytes:10218977 (9.7 MiB)
答案1
You are apparently trying to do simultaneously two things which may be outright incompatible, or may be possible only after some work.
Your wlan0 card has a private IP assigned to it, which indicates you are using it to connect to a wifi network. At the same time, you have hostapd on it, which puts the Virtual Interface (vif) mon-wlan0 (on your physical device phy0) in station mode. Is it correct?
What would you like to do? You have two options:
1) configure everything so that your phone has access to the pc, while neither the pc nor the phone have Internet access:
2) viceversa, configure your pc so that both the phone and the pc have Internet access thru the same wifi card.
The first thing is easy to arrange.
sudo service network-manager stop
sudo sysctl -w net.ipv4.ip_forward=1
sudo ifconfig wlan0 up 192.168.1.1
and you are good to go.
The second thing (i.e. with the same wifi card, connect to an existing wireless network and simultaneously provide a wifi ccess point to other components), may perhaps be arranged. Basically, it depends on the properties of your wifi card. If this is what you wish to accomplish, you will have to post the output of
sudo iw list
Cheers.
EDIT: on second thought, it is possible that your ifi card does not allow the use of hostapd in any case. So could you pls post the output of the last command?
答案2
You need to be on the same network, but you have two : 10.0.3.x and 192.168.1.x.
Change one of them to agree with the other.
答案3
It seems you have not defined the ipaddress on Nexus correctly. Use Ipaddress like 10.0.3.14 or something else in 10.0.3.0 range, with gateway 10.0.3.12.
Ideally you should use a dhcp server to allocate Ip address to the clients though. Correct way to do this setup will be,
- Configure /etc/network/interfaces to define ip address settings for wlan0
- Configuring a dhcp server like (udhcpd or isc-dhcp-server) to allocate IP adddress to the devices which connects.
Also, assuming you will want to share internet connection of your laptop with the devices which are connecting, you should also enable packet forwarding. To enable packet forwarding uncomment the following line on /etc/sysctl.conf
# Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.ip_forward=1
and allow traffic though iptables
$ sudo iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
Complete instructions can be found here