Transfer ethernet DHCP into Wifi Access Point, Raspberry Pi

This tutorial will work if your internet cable already has DHCP. This cable connection will be transferred into wifi connection. So all client who will connect to wifi will use DHCP what your ethernet cable provides.

To do it so:

Update system
sudo apt-get update && sudo apt-get upgrade -y
Install pre-requsites
sudo aptitude install hostapd hostap-utils iw bridge-utils -y
Make sure your wifi can act as an access point
iw list | awk "/Supported interface modes/{f=1} /software interface modes/{f=0;print} f"
This will report somethin like
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * monitor
                 * mesh point
                 * P2P-client
                 * P2P-GO
Make sure the AP mode is listed ;)

Set Host Access Point Daemon configuration file to "/etc/hostapd/hostapd.conf"
sudo sed -i "s/^DAEMON_CONF=$/DAEMON_CONF=\/etc\/hostapd\/hostapd.conf/" /etc/init.d/hostapd
Open access point configuration file
sudo nano /etc/hostapd/hostapd.conf
Paste this content
ctrl_interface=/var/run/hostapd
macaddr_acl=0 auth_algs=1
driver=nl80211
interface=wlan0
bridge=br0
hw_mode=g
ieee80211n=1
channel=7
ssid=pi
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit wireless name, password and chanel to suit your needs

Now open network configuration and make sure the bridge settings is there
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

auto br0
iface br0 inet static
address 192.168.0.113
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
bridge-ports eth0 wlan0
Reboot you pi and check for wifi network.

Trobleshooting:
IP adress of bridge network (br0) are diferent from ethernet (eth0):
pi@raspberrypi ~ $ ifconfig
br0       Link encap:Ethernet  HWaddr b8:27:eb:8c:75:50
          inet addr:192.168.0.113  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:fe8c:7550/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7877 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3491 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:959834 (937.3 KiB)  TX bytes:587858 (574.0 KiB)

eth0      Link encap:Ethernet  HWaddr b8:27:eb:8c:75:50
          inet addr:192.168.0.111  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8416 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3493 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1132541 (1.0 MiB)  TX bytes:617090 (602.6 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr c0:4a:00:2b:00:4e
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

No comments: