Hostapd works but....

Hostapd works but....

Postby mackowiakp » Mar 27th, '15, 16:20

I plug USB nano WiFi dongle because WiFi port buidin my laptop does not support AT/Master mode.

I just created script to run hostapd in bridge mode on it:

Code: Select all
#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
brctl addbr br0
brctl addif br0 eth0
ip link set up dev br0
hostapd /etc/hostapd/hostapd.conf


Now my smartphone and tablet has commection to the rest of network, including corporate DHCP server. hostapd works like a charm.
But the laptop does not communicate with any network peer and Internet.

Below outputs from bridge status, netstat -rn and ifconfig/iwconfig.

Code: Select all
[root@piotr-l ~]# brctl show br0
bridge name     bridge id               STP enabled     interfaces
br0             8000.001e6825d575       no              eth0
                                                        wlan1
[root@piotr-l ~]# ifconfig
br0       Link encap:Ethernet  HWaddr 00:1E:68:25:D5:75 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:123 errors:0 dropped:8 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:10992 (10.7 KiB)  TX bytes:0 (0.0 b)

eth0      Link encap:Ethernet  HWaddr 00:1E:68:25:D5:75 
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4097 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3982 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3166761 (3.0 MiB)  TX bytes:552943 (539.9 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:90 errors:0 dropped:0 overruns:0 frame:0
          TX packets:90 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:22916 (22.3 KiB)  TX bytes:22916 (22.3 KiB)

wlan0     Link encap:Ethernet  HWaddr 00:1F:3C:02:0F:C0 
          UP BROADCAST 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)

wlan1     Link encap:Ethernet  HWaddr 7C:DD:90:5D:41:69 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:184 errors:0 dropped:0 overruns:0 frame:0
          TX packets:178 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:30011 (29.3 KiB)  TX bytes:111579 (108.9 KiB)

[root@piotr-l ~]# iwconfig
eth0      no wireless extensions.

wlan0     IEEE 802.11abg  ESSID:off/any 
          Mode:Managed  Access Point: Not-Associated   Tx-Power=15 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
         
br0       no wireless extensions.

lo        no wireless extensions.

wlan1     IEEE 802.11bgn  Mode:Master  Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
         
[root@piotr-l ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0


Whats wrong with hostapd startup script that it block whole laptop communication?
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland

Re: Hostapd works but....

Postby mackowiakp » Mar 30th, '15, 11:04

Small update - but VERY strange.
Look to my hostapd initialisation script:

Code: Select all
#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
brctl addbr br0
brctl addif br0 eth0
ip link set up dev br0
hostapd /etc/hostapd/hostapd.conf


My computer lost connection to net just after command:

Code: Select all
brctl addif br0 eth0


That means before hostapd initialisation but during configuration bridge. What is wrong?
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland

Re: Hostapd works but....

Postby doktor5000 » Mar 30th, '15, 20:29

Did you assign an IP adress and a default gateway to the bridge? Once you add an adapter to the bridge, you can't use the adapter itself anymore IIRC.
Also from what I've read, hostapd should create the bridge for you.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18052
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Hostapd works but....

Postby mackowiakp » Mar 30th, '15, 21:11

Hmmm. Yes. Bridge adds wlan0 interface to predefined bridge. But bridge should obtain IP and gateway from corporate DHCP server
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland

Re: Hostapd works but....

Postby doktor5000 » Mar 30th, '15, 22:32

You should probably take a look at viewtopic.php?f=25&t=7013 or viewtopic.php?f=8&t=5370 (you already had a similar issue in the latter one)

From the output you've shown in the first post it clearly shows that the bridge does not have any IP adress assigned, and the default route goes via eth0, which will not work.
If you want to obtain an adress via DHCP, a simple dhclient br0 should work if your bridge is setup correctly.
One simple example is e.g. shown at http://superuser.com/a/709886/365864
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18052
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Hostapd works but....

Postby mackowiakp » Apr 2nd, '15, 16:24

Finally I got it working but in routing mode. My hostapd looks like this:

Code: Select all
#!/bin/bash
PATH="/usr/local/sbin:/usr/sbin:/usr/local/bin:/usr/bin"
echo 1 > /proc/sys/net/ipv4/ip_forward
ifconfig wlan1 192.168.109.1 netmask 255.255.255.0
hostapd -B /etc/hostapd/hostapd.conf >/dev/null
#service dhcpd restart
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
zenity --timeout=3 --info --text "Inicjalizacja APN" &


Works, but without DHCP running on hostapd. So I set static IP address for smartphone and tablet.

If I start DHCP on my laptop, after 3-4 min tablet is still connected to hostapd but lost communication with outside world.

my dhcpd.conf looks like this:

Code: Select all
bash-4.2$ cat /etc/dhcpd.conf
ddns-update-style none;
option ntp-servers 212.87.14.44;
option ntp-servers 80.50.231.226;
subnet 192.168.109.0 netmask 255.255.255.0 {
        # default gateway
        #option routers 192.168.109.1;
        option domain-name "ddns.net";
        option broadcast-address 192.168.109.255;
        option domain-name-servers 8.8.8.8, 8.8.4.4;
        option time-offset 3600; # CET
        range dynamic-bootp 192.168.109.100 192.168.109.110;
        default-lease-time 21600;
        max-lease-time 43200;
}


So what the problem it could be?
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland


Return to Networking

Who is online

Users browsing this forum: No registered users and 1 guest

cron