LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-28-2015, 11:27 PM   #1
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Rep: Reputation: 8
hostapd works but lost connection to network


I pluged 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:
#!/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:
    [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?
 
Old 03-29-2015, 01:58 AM   #2
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Quote:
I pluged USB nano WiFi dongle because WiFi port buidin my laptop does not support AT/Master mode.
Code:
brctl addif br0 eth0
^ That's your ethernet adapter
Code:
 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)
^ That's your wireless dongle (I'd guess, since wlan0 is probably your onboard device).

Neither of your wireless devices seem connected, however your ethernet adapter (eth0)
Code:
 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)
Cold-Bangin' away.

Might yank that wire out and try again.

Hope that helps.

Last edited by dijetlo; 03-29-2015 at 02:02 AM.
 
Old 03-29-2015, 04:03 AM   #3
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
I dont understand. My wired interface (eth0) is not connected to network?
 
Old 03-29-2015, 07:14 AM   #4
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
I'm the one who probably doesn't understand.
Quote:
I pluged USB nano WiFi dongle because WiFi port buidin my laptop does not support AT/Master mode.
So you'd like that to connect to your network?
OK, follow along with me here


You can name these things anything you want, however the letters are supposed to identify the media they use:

eth = ethernet
wlan = wireless lan

so unless you've done something interesting with the adapter names, this is your ethernet adapter (wired)

Quote:
eth0 Link encap:Ethernet HWaddr 00:1E:68:255: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)
Running well (slang: 'Cold bangin')

This is your loopback
Quote:
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
Here's you internal wireless adapter (probably):

Quote:
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
Seems blank (unconfiugured)
Your wireless dongle (probably):
Quote:
wlan1 Link encap:Ethernet HWaddr 7CD: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)
Barely twitching, it's not handling much traffic at all.
If you look, it hasn't polled an IP, so what it's doing is asking the other instances on the segment "what the hell is going on?" over UDP

You bridged the ethernet adapter, not the wireless adapter when you started. I might take the ethernet cable (the wire) out of the machine (don't actually yank it) and try to bring the wireless adapters up, then I'd go back and fix that bridge.

Last edited by dijetlo; 03-29-2015 at 07:17 AM.
 
Old 03-29-2015, 08:17 AM   #5
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Maybe (or for sure) I do not correctly explain my problem.
My laptop has (as any) wired port eth0 and WiFi port (wlan0). WiFi does not support Master/AP mode. So it is impossible to run hostapd on it. In "normal state" my laptop is plugged to docking station and Ethernet cable is connected to that dock. And of course - works without problems.
WiFi coverage in my room is extremely poor (practically ZERO and newer will be better - dont ask me why ;-) ) but I want/must connect my smarthone and tablet to corporate network (including corporate DHCP service etc).
Because of that, I bought nano USB WiFi adapter RT5370 chipset based which fully support AP/Master mode and plugged it to USB port in docking station.
Next issue is that corporate DHCP server has MAC/IP restriction so both smartphone and tablet must obtain IP from corporate server. And - because of crazy net administrator - that addresses are changed daily (dont ask mi why....)
So I want to bridge traffic between wlan1 (plugged nano USB WiFi adapter) and eth0 to the rest of network.
The script from the first post activate hostapd on it and my smartphone and tablet works properly and obtain IP (and several additional parameters) from corporate DHCP server.
But laptop itself does not have any communication with the rest of network. Why? I dont understand. Bridge - works, but laptop lost communication. Look at the bridge state after running the script:

Code:
root@piotr-l ~]# brctl show br0
    bridge name     bridge id               STP enabled     interfaces
    br0             8000.001e6825d575       no              eth0
                                                            wlan1
So both eth0 and wlan1 are in the same bridge. wlan1 is automatically added to the bridge because of definition in hostapd.conf file.

Is it now more clear? If no I will post any info necessary to resolve that problem.

Last edited by mackowiakp; 03-29-2015 at 08:22 AM.
 
Old 03-29-2015, 12:11 PM   #6
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
No, I now not only follow your process, but think it's a pretty cool solution. Question though
Quote:
The script from the first post activate hostapd on it and my smartphone and tablet works properly and obtain IP (and several additional parameters) from corporate DHCP server.
If they rely on the laptop for connectivity to the network DHCP server, and the laptop itself has no connectivity to the DHCP server...
Quote:
But laptop itself does not have any communication with the rest of network. Why? I dont understand. Bridge - works, but laptop lost communication.
If the laptop cannot connect to your companies network, then it's not bridging into it. Check to make sure that your call phone and tablet aren't just polling a DHCP lease from your companies servers via the weak wireless connection you mentioned earlier.
Not only is the wired connection apparently not working, based on what you're showing me from ifconfig, the wlan1 wireless connection isn't either. If you would, try a "tcpdump -c 50 | grep <your corporate networks first couple of octets, i.e. 192.168) " and see if there are actually any tcp packets coming across either interface. Post back what you find and we'll take a look at this.
 
Old 03-29-2015, 01:38 PM   #7
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Talking

My laptop is located in separate segment of network because of matter of my work. "Big Brother" is watching me constantly ;-). And room is electro-magnetically isolated too. But I am not Snowden ;-)
At this moment I am at home but I can post You necessary infos.

First of all, to avoid potential connection to unwanted Access Point, WiFi build in port wlan0 is physically turn off by hardware switch located on the front of laptop. Bluetooth is turn off to by the same switch. So the only way to communicate with the rest of network is wired interface. wlan1 interface is not started at all after boot so no connection could be done over wlan1. But additional WiFi USB adapter is plugged at this moment to laptop USB port.
During boot, laptop obtains IP address from my home DHCP server via wired that is the only active interface at this moment. And it works properly.
Than I start my script, and smartphone connects to hoatapd Access Point (as it is shown on console). Smartphone obtain DHCP info from home server (I have restriction MAC/IP address at home too) server because the only connection to the rest of network could be done over wired laptop port eth0.
I check IP address of smartphone - is correct as table in my home server stands (I dont use router build in DHCP but use DHCP from Linux based home server called - media).
Than I start browsing Internet using smartphone. Works without problem. But laptop lost connectivity to outside world.

Below outputs from ifconfig and iwfonfig after running my script that is - after activation hostapd:

Code:
[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:45 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4316 (4.2 KiB)  TX bytes:0 (0.0 b)

eth0      Link encap:Ethernet  HWaddr 00:1E:68:25:D5:75  
          inet addr:192.168.0.51  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:539 errors:0 dropped:0 overruns:0 frame:0
          TX packets:510 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:324691 (317.0 KiB)  TX bytes:74698 (72.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:127 errors:0 dropped:0 overruns:0 frame:0
          TX packets:127 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:40311 (39.3 KiB)  TX bytes:40311 (39.3 KiB)

wlan1     Link encap:Ethernet  HWaddr 7C:DD:90:5D:41:69  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:3519 (3.4 KiB)

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

wlan0     IEEE 802.11abg  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=off   
          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
And output from tcpdump:

Code:
[root@piotr-l ~]# tcpdump -c50|grep 192.168.0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
20:09:14.473437 IP 192.168.0.2.17500 > 255.255.255.255.17500: UDP, length 147
20:09:14.473652 IP 192.168.0.2.17500 > 192.168.0.255.17500: UDP, length 147
20:09:32.213334 IP piotr-l.17500 > 192.168.0.255.17500: UDP, length 148
20:09:33.748096 IP media.17500 > 192.168.0.255.17500: UDP, length 147
50 packets captured
281 packets received by filter
220 packets dropped by kernel
[root@piotr-l ~]# tcpdump -c50|grep 192.168.0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
I have to mention once more, that wlan0 is physically disabled by hardware switch, smartphone connects to hostapd and obtain correct IP address from my home server and I can browse internet using smartphone but laptop - totally can not connect even to local network like ping to router, home server etc.

media is the name of my home server with DHCP server on it.
piotr-l is my laptop we are talking about
192.168.0.2 is my wife laptop.

Last edited by mackowiakp; 03-29-2015 at 01:40 PM.
 
Old 03-29-2015, 05:01 PM   #8
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Piotr, I'm stumped as you are on this one. I don't have a similar bridging arrangement I can reference and I'm not understanding at all how these appliances (phone/tablet) are poling DHCP leases through a gateway that doesn't reach the DHCP server. I'm not doubting a thing you're saying, I just don't understand it. Specifically, if you look at you adapter dump, you're passing nothing but UDP packets which wont route outside your network segment.

My best suggestion at this point is repost into the thread we started in so you pop up on unanswered threads list. The people who haunt this site who do this stuff for a living tend to watch that list, anything that goes over 24 hours, we take a look at it and see if we can be of help. It lets newer people sharpen their skills on easier questions.

I'll leave it alone this time and see if anybody else picks this one up. Meanwhile, I'm a putting couple servers in in my home environment today, Venerable Dells, but they have enough hyper-threads and sockets to virtually host complex networks, one of which I'm going to use to look at this problem. If I come up with something, I'll post back into this thread.

I wish I could be of more help to you but I gotta admit, I'm purely stumped on this one....
Sorry
 
Old 03-30-2015, 04:03 AM   #9
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Small update - but VERY strange.
Look to my hostapd initialisation script:

Code:
#!/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:
brctl addif br0 eth0
That means before hostapd initialisation but during configuration bridge. What is wrong?
 
Old 04-02-2015, 09:29 AM   #10
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Finally I got it working but in routing mode. My hostapd looks like this:

Code:
#!/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:
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
b43-fwcutter-no connection with WEP encrypted network while WPA network works blorpton Linux - Networking 6 01-25-2010 02:06 AM
Network connection lost bfrank Linux - Networking 3 08-30-2007 10:13 AM
Lost network connection... szofiel Linux - Networking 0 05-24-2006 09:00 PM
Lost network connection nonno2005 Linux - Networking 7 06-11-2005 06:13 AM
Lost network connection omarcb Linux - Hardware 1 02-12-2004 12:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration