Make a bridge Ethernet to WIFI

If all what your looking for is just to simply share your Internet connection you don't necessarily need a bridge for that and it is easier to do so by following some other how to on the Internet like the following instead: http://ubuntuhandbook.org/index.php/2014/09/3-ways-create-wifi-hotspot-ubuntu/

I my self needed a way to connect to an Ethernet network wirelessly.

First you will need to install some packages:

sudo apt-get install iw hostapd rfkill bridge-utils

Now make sure your wireless device supports the access point mode by running the following command:

iw list

And look where it says “Supported interface modes” and “AP” should be listed, otherwise your card will not work to make a bridge.

Edit the following file:

gksudo gedit /etc/network/interfaces

Adding the following lines:

auto br0
iface br0 inet dhcp
bridge-ports eth0 wlan0 <------- This might be different in your case. Use ifconfig to find out.

Create the following new file with this command:

gksudo gedit /etc/hostapd/hostapd.conf

Make its content like follows:

ssid=name_of_wifi
wpa_passphrase=password_wifi
interface=wlan0 <-------yours might be diferent
bridge=br0
auth_algs=3
channel=7
driver=nl80211
hw_mode=g
logger_stdout=-1
logger_stdout_level=2
max_num_sta=5
rsn_pairwise=CCMP
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP

Now edit the following file with the following command:

gksudo gedit /etc/default/hostapd

Where it says #DAEMON_CONF="" change it to DAEMON_CONF="/etc/hostapd/hostapd.conf"

Next run the following two commands before starting hospad:

sudo service network-manager stop
sudo rfkill unblock wlan

Bring up br0 running the following command:

sudo ifup br0

Run hostapd with the following:

sudo /etc/init.d/hostapd restart

THE END. You should see your “name_of_wifi” being distribute on the air, and using your “password_wifi” you'll be able to connect to the network.

After you are done using the bridge you can revert the process typing the following commands:

sudo /etc/init.d/hostapd stop
sudo ifdown br0
sudo service network-manager start

Also, you should delete the lines added to /etc/network/interfaces.

Anyway, I hope this can help someone out there since it was a little difficult for me the first time. If some one can suggest how to make the process without editing /etc/network/interfaces it will be nice. I tried to use brctl but I didn't know how to specify DHCP for br0, and it complained when trying to bridge the wlan.

Anyhow, thanks for reading me.

Revisions

12/26/2017 - 18:24
arielenter