Help bridging eth0 and wlan0

Ask questions about Arch Linux ARM. Please search before making a new topic.

Help bridging eth0 and wlan0

Postby BinaryJay » Mon Mar 07, 2011 7:27 pm

I'm trying to set up an access point, I got hostapd working fine and I'm able to connect to it but only as far as getting connected to the plug itself.

I have tried all sorts of stuff in setting up rc.conf and conf.d/bridges but everything I've tried thus far results in a completely inoperable network where I can no longer even access the plug via eth0.

Any advice, or even better, working rc.conf and bridges files?

THANKS!
BinaryJay
 
Posts: 87
Joined: Mon Dec 06, 2010 10:27 pm

Re: Help bridging eth0 and wlan0

Postby pepedog » Mon Mar 07, 2011 8:35 pm

I have never done bridge, but set up dnsmasq to allocate an ip address, and do dns, along with shorewall to do the work of config of iptables
http://Arch Linux ARM.com/forum/viewtopic.php?f=6&t=247&p=1967#p1967
There is an exaple in that topic of also having a second nic
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Help bridging eth0 and wlan0

Postby pepedog » Mon Mar 07, 2011 9:12 pm

I'll post it here as well

rc.conf
eth0="dhcp"
wlan0="wlan0 192.168.4.1 netmask 255.255.255.0 broadcast 192.168.4.255"
INTERFACES=(eth0 wlan0)

and these shorewall files altered to this
masq
eth0 192.168.4.0/24

interfaces
net eth0 detect routefilter,blacklist,tcpflags,nosmurfs
loc wlan0 detect dhcp

policy
loc net ACCEPT
loc fw ACCEPT
loc loc ACCEPT
loc all ACCEPT
fw loc ACCEPT
fw net ACCEPT
all all DROP info

zones
net ipv4
loc ipv4
fw firewall

dnsmasq.conf file like this
dhcp-authoritative
dhcp-option=40,plubox
dhcp-option=42,0.0.0.0
dhcp-option=vendor:MSFT,2,1i
dhcp-range=wlan0,192.168.4.150,192.168.4.249,255.255.255.0,12h
domain=Arch Linux ARM install.lan
enable-tftp
interface=wlan0
tftp-root=/var/ftpd

Also I forgot
/etc/conf.d/iptables
IPTABLES_FORWARD=1 # enable IP forwarding?
which is quite important
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Help bridging eth0 and wlan0

Postby BinaryJay » Mon Mar 07, 2011 10:16 pm

Thanks. It's hard to distill what I need from that post since at this point I'm not actually trying to do any routing etc.

I'm getting really frustrated because when I try to manually create a bridge like

brctl addbr br0 --> OK
brctl addif br0 eth0 --> Lose connection to the plug...eth0 dead.

I'm sure I'm being stupid about this somehow... does adding eth0 to the bridge inherently make it unavailable to outside connections? In which case, I suppose, I cannot use the plug as an AP bridged to the rest of the network and still ssh into it via eth0? I think I'm in over my head on this one.
BinaryJay
 
Posts: 87
Joined: Mon Dec 06, 2010 10:27 pm

Re: Help bridging eth0 and wlan0

Postby pepedog » Mon Mar 07, 2011 10:59 pm

pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Help bridging eth0 and wlan0

Postby BinaryJay » Tue Mar 08, 2011 6:28 am

I've got a script "working" that seems to start the device up, bridge it successfully, and i was able to connect to the AP for a short time with my phone... but then it all goes wrong, all by itself, after some short time (and leaves no log traces...)

After the script is started my connection to eth0 is lost when the bridge is built - and then I can reconnect at the bridges assigned IP afterwards OK (at least for a while).

After a short amount of time, it just dies... the bridge dies, and drops off the device list on my router altogether and AP will no longer communicate with the connected device. No idea what's going on, but I suppose I should chalk it up to incomplete drivers again - at least for host mode on this chipset.

In any case, here is what my script is doing in case anybody has any suggestions. I am starting out with the plug setting eth0 to a static IP and all other interfaces down.

$this->bbcode_second_pass_code('', '

#!/bin/bash

ifconfig eth0 0.0.0.0 #remove IP from eth0
ifconfig eth0 down #ensure the interface starts down

ifconfig wlan0 0.0.0.0 #remove IP from wlan0
ifconfig wlan0 down #ensure the interface starts down

brctl addbr br0 #create br0 node
brctl addif br0 eth0 #add eth0 to bridge br0
brctl setfd br0 0

#start up hostapd
hostapd -d /etc/hostapd/hostapd.conf > /var/log/hostapd.log &

#give hostapd some time to initialize and add wlan0 to the bridge (setting bridge=br0 in hostapd.conf)
sleep 5

#ip for bridge
ifconfig br0 192.168.1.15 netmask 255.255.255.0

#bring up interfaces
ifconfig eth0 up
ifconfig br0 up

route add default gw 192.168.1.1 # gateway
')
BinaryJay
 
Posts: 87
Joined: Mon Dec 06, 2010 10:27 pm

Re: Help bridging eth0 and wlan0

Postby pepedog » Tue Mar 08, 2011 2:03 pm

$this->bbcode_second_pass_quote('', 'A') bridge is a way to connect two Ethernet segments together in a protocol independent way.
Packets are forwarded based on Ethernet address, rather than IP address (like a router).
Since forwarding is done at Layer 2, all protocols can go transparently through a bridge

So there no ip addresses.
Maybe you want dhcrelay?
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Help bridging eth0 and wlan0

Postby technosf » Tue Mar 08, 2011 6:46 pm

If you are behind a firewall or nat, try turning on IP forwarding in the kernel - it's simpler than dealing with a iproute if security is not a concern.

Here's some information to get you started:

http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html#FORWARDING

Have fun!
[size=85] MochaBin 5G || NSA325 [/size]
technosf
 
Posts: 147
Joined: Sat Jan 08, 2011 10:54 pm

Re: Help bridging eth0 and wlan0

Postby pepedog » Tue Mar 08, 2011 8:08 pm

I just tried dhcrelay
dhcrelay -wlan0 192.168.1.1
I see on the server requests for an ip address, but refused as wlan0 is set to another subnet, so I can see it will work
I covered ipforward by entry in the /etc/conf.d/iptables entry, masq setting in iptables may still be required, not sure
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Help bridging eth0 and wlan0

Postby BinaryJay » Tue Mar 08, 2011 9:33 pm

Tried dhcrelay, and again maybe I'm misunderstanding it but when I told it to listen on wlan0 and forward to the IP of eth0, it didn't seem to work out and then eventually while watching traffic in iptraf I lost all connectivity. I'll keep experimenting... these experiments are destroying my filesystem though with all of these dirty reboots.
BinaryJay
 
Posts: 87
Joined: Mon Dec 06, 2010 10:27 pm

Next

Return to User Questions

Who is online

Users browsing this forum: No registered users and 16 guests