0

There are a lot of tutorials how to share network connection with your usb wifi adapter and I tried lots of them but it is still not working. Can you please help me with my problem. Here is my network described:

I have eth0 which is connected to the internet. It is configured for wpa_supplicant 802.1X. It works as it should.

My wifi usb adapter is wlan0 and I had it in managed mode it supports access point mode and I assigned static ip to it. I installed hostapd and run with proper config. It sets up and I am able to connect to the ap, but can't access the internet.

In my iptables I did nat-ing between eth0 and br0. But if I tried to ping some external IP with -I wlan0 it didn't work.

Can you describe what should I do, step by step. I really need to set this up, quick as possible.

Many thanks.

2
  • 1
    Of course it does not work: you are trying to send a ping through the access point, it should go the other way. If your wifi is in managed mode, it surely will not work as an access point. What exactly are you trying to achieve? Set up a wifi network on your pc, so that people can connect via wifi to it, and from then through the ethernet cable reach the Internet? Jun 22, 2014 at 15:39
  • 1
    Can your wifi card support a hot spot? Issue the command sudo iw list, and see whether, under Supported Interface modes there is AP. If there is, you can do it, otherwise no way Josè. Jun 22, 2014 at 15:42

2 Answers 2

1

Setting up a hotspot requires several steps, provided your card can do it (to check, see my comment above). The follwoing commands apply to Debian and derivatives, they can easily be adapted to other distros.

  sudo apt-get install haveged isc-dhcp-server hostapd
  sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
  sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Edit the file /etc/default/hostapd and replace #DAEMON_CONF="" with

  DAEMON_CONF="/etc/hostapd/hostapd.conf"

Edit the file /etc/hostapd/hostapd.conf and put this into it:

  ctrl_interface=/var/run/hostapd
 driver=nl80211
 interface=wlan0
 bridge=br0
 hw_mode=g
 ieee80211n=1
 channel=1
 ssid=MYWifi
 auth_algs=1
 ignore_broadcast_ssid=0
 wpa=3
 wpa_passphrase=My_Secret_Password
 wpa_key_mgmt=WPA-PSK
 wpa_pairwise=TKIP
 rsn_pairwise=CCMP

Replace channel number, ssid and wpa_passphrase with something suitable to you.

Edit the file /etc/default/isc-dhcp-server and replace the line INTERFACES="" with

  INTERFACES="br0"

Now edit /etc/dhcp/dhcp.conf and put only these lines into it:

   subnet 10.168.10.0 netmask 255.255.255.0 {
  range 10.168.10.10 10.168.10.200;
  option broadcast-address 10.168.10.255;
  option routers 10.168.10.1;
  default-lease-time 600;
  max-lease-time 7200;
  option domain-name "my-network";
  option domain-name-servers 208.67.222.222, 208.67.220.220;

}

Now:

  sudo service hostapd start
  sudo ip tuntap add tap0 mode tap
  sudo ip link set dev tap0 up
  sudo ip link set dev tap0 master br0
  sudo ip link set dev br0 down
  sudo ip addr add 10.168.10.1/24 dev br0
  sudo ip link set dev br0 up
  sudo service isc-dhcp-server start

That's it.

4
  • I am so graceful for this answer. I will try it right away.
    – gorgi93
    Jun 22, 2014 at 18:43
  • When I try to issue a sudo ip link set dev tap0 master br0 it says: Error: argument "br0" is wrong: Device does not exist So I tried my wlan interface, so I changed to br0 -> wlan0 and it says: RTNETLINK answers: Operation not supported
    – gorgi93
    Jun 23, 2014 at 0:30
  • 1
    @gGololicic The error message means br0 has not been created yet. Make sure you start hostapd before that command, and that the bridge is up, ip link set dev br0 up. Jun 23, 2014 at 3:58
  • 1
    @gGololicic On second thought: the error message suggests hostap did not start at all. You may also try, beyond what I suggested above, to start hostapd manually, sudo hostapd /etc/hostapd/hostapd.conf, and check its output. Jun 23, 2014 at 7:02
0

You don't need anything special: I set it up on 10.04 NetBook using the normal Network GUI:-

  • Bring up Network Connections (right-click panel icon and choose Edit Connections...).
  • On Wireless tab, click on Add button.
  • The box Editing Wireless connection n will appear (you can change the name to something more appropriate if you wish).
  • On its Wireless tab choose whatever SSID name you wish, then set Mode Ad-hoc and select Available to all users.
  • Under IPv4 Settings tab choose Method Shared to other computers.
  • Under IPv6 Settings I set Method to Ignore; if you use IPv6, you will need another setting (I don't, so I can't advise).
  • Finally set the appropriate Security and Key on the Wireless Security tab.

That's it: any device logging on to0 this wireless network will share this host's ethernet connection and the host will provide DHCP

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .