# Bridging Wireless/LAN and ADSL Modem ??[SOLVED]

## ebike

Hi All,

I am setting up a router. I have the following:

a) A ADSL modem at 10.1.1.1 on eth1

b) A Wireless AP at 192.168.1.3 on eth0

c) The LAN on 192.168.0.3 on eth2

I have iptables set up so that everyone on the wired and wireless networks can share the net, that works ok.

What I am missing is th be able to access the wired LAN from the wireless network.

I believe you can set up a bridge for that, I have tried but I am missing something as I cannot get it to

work. Is there a HOWTO available to do this? I havn't found a good one.

Also, is it possible to not use a bridge, and to put the wireless and wired LAN's on the same sub-net?

Also tried this but not working.

----------

## egberts

An alternative method to this would be to route them together...so that you would have a NAT in a NAT, where the LAN sits between the ISP and your Wireless.  This arrangement works fine as long as you don't need to have a server on your wireless "laptop."

Or, if bridging is your cup of tea, this is best done under 2.6, but there are limited support under 2.4

  # emerge net-misc/bridge-utils

  # emerge net-firewall/ebtables

  # make menuconfig

     enabled bridging

     enabled bridge-filter

  # ifconfig eth0 down

  # ifconfig eth1 down

  # ifconfig eth0 0.0.0.0 up

  # ifconfig eth1 0.0.0.0 up

  # brctl addbr br0

  # brctl addif br0 eth0

  # brctl addif br0 eth1

  # ifconfig br0 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255

  # ifconfig br0 up

  # <add your default gateway>

And presto.... a single point of IP address shared over two interfaces.  Well, almost there, because that is where I am now...

And follow the FAQs... for I'm tweaking the BROUTER at the moment...

To revert it back to normal state, I do this....

  # ifconfig br0 down

  # brctl delif br0 eth0

  # brctl delif br0 eth1

  # brctl delbr br0

  # /etc/init.d/net.eth0 restart

  # /etc/init.d/net.eth1 restart

----------

## UberLord

baselayout-1.11.10-r2 has excellent bridging support  :Smile: 

----------

## ronmon

Yeah, the new way to set up bridging is really easy. I just replaced a ~3 year old Gentoo router box with a "new" Duron 1000 rig. I used to do it like egberts suggested with an init script that I made myself. Now, I just add two lines to /etc/conf.d/bridge:

```

bridge="br0"

bridge_br0_devices="eth1 wlan0"

```

Then, put a br0 entry in /etc/conf.d/net and copy or link net.br0 in /etc/init.d and use rc-update to start it at boot. You still need bridge-utils and kernel support, of course.

I still use a few lines in /etc/conf.d/local.start to do some iwconfig and iwpriv stuff, but that's  because I have a DWL-520 with hostap_pci running in master mode. Since you have an external AP you won't even need to do that.

Router's system information

----------

## egberts

Excellent tip on the use of /etc/conf.d/net settings.  Thanks.  I need that!

----------

## ebike

Hi All,

I have finally got it going with a bridge. The key was emerging the masked version of bridge-utils, the standard version

would not create the bridge correctly with the masked version of baselayout.

An excerp from my /etc/conf/net is:

```

# The ADSL Modem Interface

iface_eth1="dhcp"

# WLAN setup

modules_eth0=( "iwconfig" )

mode_eth0="Master"

essid_eth0="Mythtv"

channel_eth0="2"

key_Mythtv="0130dontbenosy8889999aa"

#Bridge stuff

config_eth0=( "null" )

config_eth2=( "null" )

# To add ports to bridge br0

bridge_br0=( "eth0" "eth2" )

# Configure the interface as well

config_br0=( "null" ) # This is needed so that dhcp is not started!

config_br0=( "192.168.0.3" )           # Obviously, you may wish to change

```

I have a standard firewall between the ASDL modem (eth1:10.1.1.1)and the bridge (br0:192.168.0.3) with MASQERADING and forwarding etc.

I also have dnsmasq serving dns and dhcp to my LAN and WLAN.

I can now browse the net on the LAN and WLAN, and MOST importantly can watch MythTV wirelessly on my

laptop. ... and all my clients have DNS and IP's served ... yippee:P

----------

## UberLord

Ah - you read Strollers guide  :Smile: 

I recently made a change to networking for dependancy - basically ripped a lot of stuff out from net.lo, bridge and bonding and now rely on the main init script dependancy stuff. This makes us more lean and mean! However, you have to add some extra stuff to your config.

```

depend_br0() {

   need net.eth0 net.eth1

}
```

This is important - br0 effectively depends on eth0 and eth2 in your case. eth0 is wireless, so it needs to be started first.

----------

## ebike

Thanks UberLord,

A question, which config file do I add that depend stuff to?

----------

## UberLord

/etc/conf.d/net

----------

## andrewf

i have a problem using +- the same setup as ebike.

(eth0: wired lan + eth2: AP in master mode = br0 ; eth1: internet)

the bridge works fine, and both wifi clients & wired clients can access my router + the internet.

the problem is, the wifi clients cannot contact the wired clients.

(even pinging doesnt work)

I'm using shorewall to config iptables.

Do I need to use some kind of masquerading between the wireless lan and the wired lan?

----------

## UberLord

No idea. If no-one else responds, try making a new thread.

----------

## R!tman

Same problem as andrewf. Did you get it to work? Did you make another post?

My /etc/conf.d/net

```
modules=( "iproute2" )

#LAN

config_eth0=( "0.0.0.0" )

#WAN

config_eth1=( "dhcp" )

#WIFI

preup() {

   if [ "${IFACE}" == "ath0" ]; then

      /sbin/wlanconfig ath0 destroy > /dev/null

      /sbin/wlanconfig ath0 create wlandev wifi0 wlanmode ap > /dev/null

      return $?

   fi

   if mii-tool ${IFACE} 2> /dev/null | grep -q 'no link'; then

      ewarn "No link on ${IFACE}, aborting configuration"

      return 1

   fi

   return 0

}

predown() {

   if [ "${IFACE}" == "ath0" ]; then

      killall wpa_supplicant

      /sbin/wlanconfig ath0 destroy

   fi

   return 0

} 

config_ath0=( "0.0.0.0" )

essid_ath0="babylon5"

mode_ath0="master"

channel_ath0="5"

#BRIDGE

depend_br0() {

   need net.eth0 net.ath0

}

bridge_br0=( "ath0" "eth0" )

config_br0=( "192.168.0.1/24" )
```

BTW, I am using hostapd for wpa encryption of wireless traffic. I start it after all the net stuff.

Edit: Nevermind, I solved it with this script.

----------

