# Wireless access point with Atheros card/bridging (SOLVED)

## Akaihiryuu

I finally got around to putting a wireless card in my Gentoo server, roommate that owns the D-link access point is moving out, and I'd rather consolidate wireless into my server rather than having a separate piece of hardware.  The wireless part is working fine as far as I can tell.  So far I just have it set up using WEP (not going for anything more complex like MAC filtering that requires hostapd until I get everything working as is)...I can see the AP from my laptop, I can connect to it (even with WEP), getting around 50-60% signal strength (not bad considering it's through several walls and downstairs with a metal rack in the way).  Now the problem...before the wireless was added, I had eth0 and eth1...eth0 for the LAN, eth1 for the internet (internet access for all the computers using a NAT masquerade rule).  I have all the standard services on the LAN like DHCP, NTP, NFS, Samba, etc.  I need to bridge the wireless (ath0) with the LAN (eth0) so that the wired and wireless computers will be on the same segment.  So far last night I tried configuring the bridge in /etc/conf.d/net (bridging eth0 and ath0), setting eth0 and ath0 to ( "null" ) so that they don't get set IP addresses, and setting the IP address that was formerly on eth0 on br0 (192.168.0.1).  I have virtually no experience with bridging/ebtables...and the problem I kept running into was (since I'm doing this remotely via ssh from another computer on the LAN) losing access to the server when I tried to bring the bridge up.  /etc/init.d/net.eth0 stop && /etc/init.d/net.ath0 stop && /etc/init.d/net.br0 start (I have a depend() option in /etc/conf.d/net to make br0 require eth0 and ath0).  For some reason net.br0 start seems to freeze indefinitely after bringing up eth0...but if I change it, start eth0 and ath0 first, then start br0, the bridge seems to come up ok.  I have to be at the actual console to do this, I haven't been able to get access over the bridge from another computer.  Eth0 and ath0 have no IP addresses, br0 has 192.168.0.1, the routing table looks ok as far as I can tell...but I get no access at all, can't ping across the bridge.  I'm certain this is a problem with the way the bridge is set up and not with the wireless...if I can get eth0 working on the bridge I'm sure ath0 will as well.  I'm sure I'm probably doing something wrong (I'm fairly experienced with networking and routing, I've just never dealt with bridging before until now), but I haven't really been able to find a good walkthrough on this.  The best I've found is ttp://gentoo-wiki.com/HOWTO_Building_a_Wireless_Access_Point but it only briefly touches on bridging.  I know I'm going to have to go through my configs for other services and make sure to replace instances of eth0 with br0, but I want to start by being able to ping across the bridge and be able to do this remotely.  Hooking up an old monitor and keyboard to the server and having to enter commands that way sucks and I'd like to finish getting everything working from another computer.  Does anyone have any experience with this?Last edited by Akaihiryuu on Thu Jul 12, 2007 3:46 pm; edited 1 time in total

----------

## Paris Heng

Halo, I am doing this project right now also. So, now still in research stage. Will you using RADIUS Server in this case?

----------

## Akaihiryuu

I'm not planning on it yet...right now I just want to get it working with WEP.  I'm probably going to move to more advanced stuff like WPA and MAC filtering once I get the base setup working with WEP as well as the standalone access point did...but my main concern right now is getting it working.  WEP is as easy to get it working with as open.  Once it works I'll start playing around with hostapd and decide what I want to do.

----------

## Paris Heng

To build an access point for laptop --> Just install madwifi-ng, madwifi-ng-tools, and hostapd, and then follow the instructions on the madwifi site.

In my country, it is hard to get the Wifi card with Prism Chipset, so Atheros is the alternative.

----------

## Akaihiryuu

Oh yeah, madwifi works fine.  The wireless is working fine, and it *would* work fine as an access point right now if I didn't have eth0 to worry about.  It's the bridging that's giving me problems...if I were to put the IP address on ath0 and just route ath0 to eth1, I would be able to get internet access on my wireless computers...but I want to bridge it with eth0 to make the wired and wireless a single network segment.

----------

## RoundsToZero

How do you ssh in the first place if the bridge is not up?  Have you tried with all firewalls off?  Did your machine originally have static IP or was it through DHCP?  If it was through DHCP, you now need to configure the bridge to use DHCP.  How is your workstation machine connected to the server?  How does your workstation get its IP address?  You should not need to stop net.eth0 and net.ath0 since they should not be running, net.br0 will configure them and bring them up.  You say that eth0 is configured to null but then how do you connect to the machine from your workstation?  I'm not sure if you know what's going on so that's all I'll say for now.

One last thing is that the bridge should be considered its own network device.  Devices such as eth0 and ath0 should never have their own configuration, i.e., should never have their own IP addresses.  They are only a part of the bridge and not started by init.  You bring up net.br0 at boot with a static IP which is the simplest case as the bridge device will have an IP right away.  Then I think there is something of a delay, 30 seconds maybe, while the bridge learns the network topology before it starts forwarding packets.  So be patient.

Also, paragraphs.

----------

## Akaihiryuu

Right...when I had the bridge up, eth0/ath0 had no network addresses, and the bridge had the address (192.168.0.1).  What I was doing over SSH was setting up the bridge (editing config files and such).  I changed eth0 and ath0 to null (no IP addresses) and set up the bridge (all in conf.d/net).  When I issued the command to restart the interfaces and bring the bridge up, I lost network access.  I had to physically go to the server to test more.  The bridge was up (192.168.0.1), everything looked good, but I couldn't ping any of the other wired computers.  The only way to get access back was to bring the bridge and interfaces back down, change the configuration back to put the IP address on eth0, and bring eth0 back up without the bridge (this restored my access, though once it didn't work, even after changing the config it wouldn't put the IP address on eth0).  Basically, I've never gotten SSH access (or any network access) while the bridge was up, I haven't gotten it to work.  Hopefully that's a little more clear.  I only *started* out from an SSH session (changing config files).  All of the remainder of the testing was done from the server console after I lost network access.

----------

## RoundsToZero

OK well you shouldn't have been surprised when you lost connectivity, since your first step was to shut down eth0.  How do the other wired computers get their IP addresses?  Are they on the 192.168.0.0/24 subnet?  If so, what DHCP servers do they use?  How do your server and workstation connect to the Internet?  Basically, what's the physical layout of your network, from your real (external) IP address down to your workstation and server?

----------

## Akaihiryuu

Yes, I'm aware that bringing down eth0 would've cause me to lose network access.  But I did all the commands (including bringing up the bridge) together.../etc/init.d/net.eth0 restart && /etc/init.d/net.ath0 restart && /etc/init.d/net.br0 start.  Network access should've been restored at this point, but it wasn't.  When I went down to the server the bridge was up with the proper IP (192.168.0.1) but couldn't ping any of the wired computers.  I'm just using a simple 192.168.0.0/24 setup (server is .1, other computers are .2 and higher).  Here's the layout of my network before the wireless:

Server -> eth0 (192.168.0.1) -> Linksys 8-port switch -> wired computers

Server -> eth0 -> Linksys 8-port switch -> D-link access point (192.168.0.2) -> wireless computers

Server -> eth1 (internet IP) -> cable modem

iptables masquerade rules to allow internet access on wired computers

dhcpd to provide LAN addresses to wired, wireless computers and access point

(this setup works fine)

And after the wireless:

Server -> eth0 -> br0 (192.168.0.1) -> Linksys 8-port switch -> wired computers

Server -> ath0 -> br0 (192.168.0.1) -> wireless computers

Server -> eth1 (internet IP) -> cable modem

iptables masquerade rules to allow internet access from br0 to eth1

and once again dhcpd to provide IP addresses

(this setup is where I'm running into problems)

----------

## Akaihiryuu

I'm reading a howto on another site that says that all cards (wired and wireless) must be put into promiscuous mode for bridging to work properly.  Do the Gentoo scripts do this automatically or is this something I have to set in conf.d/net?

----------

## RoundsToZero

Yeah they do, but you can check with ifconfig of eth0 or ath0 and see if the flag for it is on.

Are your iptables rules updated to refer to br0 instead of eth0?

On the local side, what's the routing table on the server?

Have you waited 30 seconds before trying to use the bridge?  brctl has an option to control this waiting period; brctl options can be specified in /etc/conf.d/net so it's all nice and integrated.  See net.example.

Edit: Also dhcpd will have to reconfigured to serve on br0 instead of eth0, so that new wireless clients get IPs as well.

----------

## Akaihiryuu

I actually have never referred to eth0 in any of my iptables rules.  I try to avoid specifying interfaces in them (except for lo)...the only time I HAVE to is for my masquerade rule, in which I have to specify a -o interface (which is eth1 and unaffected by the bridge).  Unfortunately I can't access my routing table right now because I'm at work and have no way to SSH (very restrictive proxy).  I had to disable all of the bridge configuration in net (actually just commented out) and restored my regular eth0/eth1 configuration so that it would work while I was at work today (my roommates depend on that server for internet access).  I'll post some more detailed information from the routing tables when I get home.  I am going to also doublecheck the iptables rules, as I have a fairly restrictive INPUT chain (default is DROP).  Assuming I have to edit the rules to allow bridge traffic in, would I have to do something like iptables -A INPUT -i br0 -j ACCEPT?  The DHCP thing just occurred to me too...I do have to edit it to serve on br0.  Serving on eth0 won't work anymore if eth0 is on a bridge.

----------

## Akaihiryuu

I was just thinking...would it work if I kept the IP address on eth0 (192.168.0.1) and just set ath0 and br0 to "null" (no IP).  That should theoretically just bridge eth0 and ath0 right?

----------

## RoundsToZero

Bridge does not work that way.

http://linux-net.osdl.org/index.php/Bridge

----------

## Akaihiryuu

Ok...I don't know what I did different that time, but it's working now.  The only thing I could've possibly done differently was I made sure I brought down all network interfaces except eth1 (which isn't on the bridge) before bringing the bridge up.  I still was not able to ping anything, so I turned off bridge filtering in /proc/sys/net/bridge (the 4 entries in there, they're listed in the access point howto), and then I was able to reach the other computers on my network.  Wireless was still not able to obtain an IP...but it turned out all I had to do was restart dhcpd.  Dhcpd wasn't aware of br0, because br0 didn't exist when dhcpd was originally started.  After that, it's all working...wired and wireless.

----------

## Paris Heng

Now i am able to connect to the internet using my madwifi driver and Atheroes chipset.

(1) Now i in the state of building the access point using Hostapd.

What i need somemore?

(2) Since you are solved the bridging problems. Do i need Bridging? I need to Bridging the wired & wireless segments, so the mobile user can connect to me (Laptop with access point functionality), then i need to bridge to the LAN segment using my Ethernet card, eth0. How to do so?

(3) And the wpa_supplicant necessary for me to installed?

----------

## Akaihiryuu

The weird thing...thus far I haven't even *needed* hostapd.  Since I'm just using WEP and not doing MAC filtering or anything like that...although I will eventually.  Right now I'm just happy to have it working, I'll fiddle with hostapd later.

----------

## WhiteHat237

How can /etc/init.d/net.br0 be forced to start after /etc/init.d/hostapd?

I have tried editing /etc/init.d/hostapd and adding:

```
after net.br0
```

to the depend section with no luck

I have also tried editing /etc/init.d/net.br0 and and adding: 

```
before hostapd

```

Again with no luck.

I need net.br0 to come up first because in hostapd.conf I have 

```
bridge=br0 

```

line uncommented, and hostapd expects to see the interface up before it will start.

If I manually restart hostapd with /etc/init.d/hostapd restart, then everything works, and hostapd starts correctly.

All thats needed is to sort out the init script startup order.

----------

