WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: eth0 to wlan0 Bridge  (Read 5745 times)

Offline yeme

  • Newbie
  • *
  • Posts: 21
eth0 to wlan0 Bridge
« on: November 13, 2015, 07:09:21 AM »
I am a complete newbie to PiCore but have been using RPi for a while with my IP cameras and an eth0 to wlan0 wireless bridge.  I have followed this thread from last June:

http://forum.tinycorelinux.net/index.php/topic,18494.msg113140.html#msg113140

and am unable to figure how to proceed to make this bridge (Paul_123 has been helpful with my questions prior to this posting).

With the RPi setup I use bridge-utils to create the bridge but do not know the equivalent for PiCore and that is my question, do you have any suggestions to get me started?  I see net-bridging*.tcz and have installed it but do not know the equivalent commands. I use these commands with the RPi bridge-utils to create the bridge.

sudo brctl addbr bridge0
sudo brctl addif bridge0  eth0
sudo brctl addif bridge0 wlan0

I am using RPI B or B+

Thanks,

John

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: eth0 to wlan0 Bridge
« Reply #1 on: November 13, 2015, 07:47:04 AM »
Will add bridge-utils to repo in next days.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline yeme

  • Newbie
  • *
  • Posts: 21
Re: eth0 to wlan0 Bridge
« Reply #2 on: November 13, 2015, 08:08:49 AM »
bMarkus,

Thank you so much!

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: eth0 to wlan0 Bridge
« Reply #3 on: November 13, 2015, 12:14:39 PM »
bridge-utils.tcz added to 7.x repos.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline yeme

  • Newbie
  • *
  • Posts: 21
Re: eth0 to wlan0 Bridge
« Reply #4 on: November 13, 2015, 02:27:30 PM »
Thanks bMarkus, 

I'll give it a go.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 402
Re: eth0 to wlan0 Bridge
« Reply #5 on: November 13, 2015, 03:35:14 PM »
hi yeme,

I will be following with interest.   :D

Please post your results.

regards
Greg

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: eth0 to wlan0 Bridge
« Reply #6 on: November 13, 2015, 07:25:12 PM »
I had this working just fine on a model B.   This was on a piCore 6.1 release.  I don't use my bridge much, I have not been able to find my sd card with this on it.

But I had made some improvements over what was on my previous post.  Biggest thing I changed was that if the bridge failed to come up and get a valid IP address, then I would bring the bridge back down and then set eth0 with a static address and start a dhcp server on eth0 so that you can connect to the bridge and check the configuration.


yeme, to answer your PM, yes the startup script goes in /opt/bootlocal.sh


Offline yeme

  • Newbie
  • *
  • Posts: 21
Re: eth0 to wlan0 Bridge
« Reply #7 on: November 14, 2015, 06:54:30 AM »
Yes, I just had the same problem.

I got the bridge working last night and connected my laptop and received an IP address. I could browse but it was much slower than the bridge I use with the  RPi setup (would a B+ or RPi 2 help with this due to more RAM?). I then restarted everything and the laptop showed it was connected (Win7) to the network but I could not reach any sites.  My next step is to set static IPs.

Of note:

I commented out this line in Paul_123's original thread from June as on the RPi I had seen mention of Dwest being problematic and my Br0 would not work until I made this change to the bootlocal.sh.

#wpa_supplicant -Dwext -iwlan0 -bbr0 -c/etc/wpa_supplicant.conf &

Paul_123, would you share detail on how you set your IPs upon Br0 failure if you can re-create or remember?


Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: eth0 to wlan0 Bridge
« Reply #8 on: November 14, 2015, 07:23:04 AM »
you cannot comment out the whole wpa_supplicant line.....that is what authenticates you with the downdstream AP

if the WEXT driver is causing you a problem with your wifi card, then change the -D command.    The other thing you need to look at is the configuration of your /etc/wpa_supplicant.conf .  You can get some clues as to how this should be setup by running the wifi.sh script as if you were doing a normal wifi client, then take a look at how that runs.

AS for speed, This will not be terribly fast due to the all of the traffic in and out going through the USB bus.  But should be as fast as a Raspbian configuration.   I doubt memory is an issue, but the quad core of the RPi 2, would probably help.

I had many hours in making the scripts, Since I don't use the bridge much, I doubt I will have fun in recreating the scripts.   But I will take a look for my SD card with the config.  I believe I left it at work.

Offline yeme

  • Newbie
  • *
  • Posts: 21
Re: eth0 to wlan0 Bridge
« Reply #9 on: November 14, 2015, 08:52:11 AM »
Ok, let me know.

John

Offline yeme

  • Newbie
  • *
  • Posts: 21
Re: eth0 to wlan0 Bridge
« Reply #10 on: November 15, 2015, 11:27:31 AM »
I have had some success in getting this going except with 2 problems for me:

1.  I cannot SSH via PuTTY into PiCore after the bridge is set and working
2.  The bridged connection always disconnects after about 30 minutes. 

When it is up, I can receive an IP for the connected client (or the client can have a static IP) and browse with performance similar to my RPi bridge I've been using.  I can also ping my LAN and web from my client (laptop) and browse at network level shared folders on my LAN.  I can also ping and browse network shares from my LAN to the connected client.

I also was able to have my connected IP camera work as it should for the 30 minute period the bridge was up.  I could not however connect to the camera's web server admin page via browser as would normal.

Here is my modified bootlocal.sh script adapting Paul_123's original post:

Details:

RPi B+
PiCore 7 alpha 8
Added bridge-utils.tcz (thanks to bMarkus)

Here is my modified bootlocal.sh script using Paul_123's original post:

Quote
#wlan0 up
/usr/local/bin/wifi.sh -a -w 2>&1 > /tmp/wifi.log
sleep 5s
ifconfig eth0 up
ifconfig wlan0 up

#setup br0
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 wlan0
sleep 10s
ifconfig br0 up

# wpa piece
#wpa_supplicant -Dwext -iwlan0 -bbr0 -c /etc/wpa_supplicant.conf & #(could not get this work for me)

#set br0 ip
sleep 5s
udhcpc -i br0


Upon startup when udhcpc is started I see:

getting lease (which it does  192.168.4.70)
deleting routers
route:.....no such process
adding dns 192.168.4.1  (my LAN gw/router's IP )

My ifconfig - this shows an IP assigned to the wlan0 and the Br0 whereas the ifconfig for the working bridge on the RPi only has an IP assigned to the Br0

Quote
br0       Link encap:Ethernet  HWaddr 74:DA:38:0D:27:5A
          inet addr:192.168.4.70  Bcast:192.168.4.255  Mask:255.255.255.0
          inet6 addr: fe80::76da:38ff:fe0d:275a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:408 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:97737 (95.4 KiB)  TX bytes:1332 (1.3 KiB)

eth0      Link encap:Ethernet  HWaddr B8:27:EB:DB:DF:72
          inet6 addr: fe80::ba27:ebff:fedb:df72/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:526 errors:0 dropped:0 overruns:0 frame:0
          TX packets:281 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:143673 (140.3 KiB)  TX bytes:99120 (96.7 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  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:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 74:DA:38:0D:27:5A
          inet addr:192.168.4.70  Bcast:192.168.4.255  Mask:255.255.255.0
          inet6 addr: fe80::76da:38ff:fe0d:275a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:281 errors:0 dropped:224 overruns:0 frame:0
          TX packets:460 errors:0 dropped:1 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:121301 (118.4 KiB)  TX bytes:156423 (152.7 KiB)

Finally my route info:

Quote
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         SpiR            0.0.0.0         UG    0      0        0 br0
default         SpiR            0.0.0.0         UG    0      0        0 wlan0
127.0.0.1       *               255.255.255.255 UH    0      0        0 lo
192.168.4.0     *               255.255.255.0   U     0      0        0 wlan0
192.168.4.0     *               255.255.255.0   U     0      0        0 br0

This table varies from the route table on the working Pi bridge. (SpiR is the router name)

I would be satisfied with this setup if the br0 stayed connected and remained that way.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: eth0 to wlan0 Bridge
« Reply #11 on: November 16, 2015, 03:44:15 AM »
You cannot use the built in wifi.sh script.  You must need to bring up the bridge first.   You need to figure out how to use wpa_supplicant directly.

You will need a working wpa_supplicant.conf.   Which should be as simple as this

Code: [Select]
network={
    ssid="MYSSID"
    psk="passphrase"
}

You can use wpa_passphrase to generate this too.

I found my SD card with the bridge setup.  I modified the original wifi.sh script to do bridging.
If you use this,

bootlocal.sh looks like
Code: [Select]
#!/bin/sh

# Start serial terminal
/usr/sbin/startserialtty &

# Set CPU frequency governor to ondemand (default is performance)
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Load modules
/sbin/modprobe i2c-dev

# Start openssh daemon
/usr/local/etc/init.d/openssh start

# ------ Put other system startup commands below this line

/home/tc/bridgewifi.sh -a

I have attached the script..............  I have not re-tested this, but it was working under piCore 6.1

Offline yeme

  • Newbie
  • *
  • Posts: 21
Re: eth0 to wlan0 Bridge
« Reply #12 on: November 16, 2015, 05:00:16 AM »
Paul_123,

I will make the changes and let you know.

Thanks again for your attention to this for me!

Offline yeme

  • Newbie
  • *
  • Posts: 21
Re: eth0 to wlan0 Bridge
« Reply #13 on: November 16, 2015, 11:25:37 AM »
It works!  I can now SSH via PuTTY also.

I placed your new script in /opt because I couldn't get it to persist in /home/tc - any problems with this location?


Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: eth0 to wlan0 Bridge
« Reply #14 on: November 16, 2015, 12:34:26 PM »
It should persist in the /home/tc as long as you backup after putting the file there.    But nothing wrong in /opt

Check the contents of /opt/.filetool.lst for the directories and files that get backed up