How to get bridge internet connection to wlan0 from eth0?

2

1

I have hostapd and dnsmasq installed for distributing my wireless network with a WiFi dongle, and everything is working well. I am also able to connect an ethernet cable and get DHCP, plus internet access, from a router.

Is there a way to bridge the internet connection from eth0 to my dynamically configured wlan0? So it becomes possible to connect with wifi and surf the net, like a router.

I am running Ubuntu, on a beaglebone black.

user3142264

Posted 2013-12-28T17:13:12.503

Reputation: 29

Answers

3

In Debian and relatives, before starting hostapd, you need to do the following:

  sudo service network-manager stop
  sudo ifconfig eth0 down 
  sudo ifconfig eth0 0.0.0.0 promisc up
  sudo brctl addbr br0
  sudo brctl addif br0 eth0
  sudo dhclient br0 

Then, add the following line to /etc/hostapd/hostapd.conf:

  bridge=br0

hostapd will add itself to the bridge, you just need to tell it to do so and the name of the bridge.

Now you can start hostapd, without DHCP nor dnsmasq, of course. This is because by bridging wifi and ethernet, your wifi clients will be able to ask your router directly for an IP address, so there is no need of the whole shebang of DHCP/dnsmasq on the wireless interface.

If you need info for a systemd distro, just say so.

MariusMatutiae

Posted 2013-12-28T17:13:12.503

Reputation: 41 321

Where to put this to get everything working on boot? – Dirk Gorissen – 2016-03-22T15:13:32.380

0

If the IP addresses for the wireless clients are in the same range as the dynamic address of the PC with the ethernet card, perhaps simply enabling IP forwarding could be all you need:

echo 1 > /proc/sys/net/ipv4/ip_forward

If the IP range of the wireless clients should be shielded somehow, you'll need to configure NAT. You can find some more detailed information here

brm

Posted 2013-12-28T17:13:12.503

Reputation: 436