MOBILE ROUTER / ACCESS POINT / MEDIA SERVER
by Kimanzi254 in Circuits > Raspberry Pi
568 Views, 3 Favorites, 0 Comments
MOBILE ROUTER / ACCESS POINT / MEDIA SERVER
At the moment the world is experiencing a global chip shortage in which the demand for integrated circuit supersedes the supply. Many electronics companies especially those in the computing world such as smartphones have found themselves having to bump up prices of their phones because of this or having to use older chips on new phones. Electronics hobbyist such as myself have not been spared with prices of microcomputers such as Raspberry Pi soaring every now and then, and even being out of stock. As a result, many of us have found ourselves having to dust off those old raspberry pis. The raspberry pi 1, raspberry pi 2 and raspberry pi zero do not have wireless connection capabilities that most of us are looking for. So this is why I decided publish this instructable. In order to make the Pi to have wireless internet capabilities there is need to have some hardware and software installed, which will be described. I also thought of turning the raspberry pi to a media server so that I can stream media from a flash disk or external hard drive wirelessly. This would actually make sharing of files easier.
N/B : I did this documentation a while ago, there might be a few changes but the process stays the same. Enjoy!
Aims /Objectives
· I intend to make it a mobile server so that you can stream movies and videos, view those adorable pictures and listen to your favorite media.
· I intend to turn the raspberry pi to a router to avoid those frustrating moments when you want to have access to Wi-Fi but you only have wired internet (Ethernet cable connection).
What Do You Needed?
· Raspberry pi model B
· WIFI Adapter (TP-LINK), any type would work
· Memory card (8GB) with adapter
· Ethernet cable
· Keyboard (USB wired)
· Mouse (USB wired)
· HDMI cable
· Monitor with HDMI port
· Phone charging adapter (USB, Output- 5V, 750mAh)
Preparation
The OS was installed onto the memory card: The noobs file was downloaded and its contents extracted onto a folder. The contents on the folder were copied to a freshly formatted SD card.
SDFormatter software was used to format the SD card
· The Pi was booted and configured : The username was changed to “pi” and password set as “raspberry”
· Set up and test the Ethernet and Wi-Fi connection
· Connect with a USB console cable (optional)
When done the Pi was booting Raspbian, the USB console cable was connected and logged into the Pi via the command line interface. We then ran the following command to access the SSH option
sudo raspi-config
The raspberry configuration menu popped up and we selected advanced options and enabled SSH. We also expanded the memory to avoid running out of space while performing the various kernel upgrades and updates.
Sharing Wi-Fi Internet connection with Raspberry Pi through LAN/Ethernet (Headless Mode)
On windows I downloaded an SSH client called PuTTY.
When I booted the pi to the command line instead of desktop, the IP address was shown in the last few messages before the login prompt, though I encountered problems trying to connect via SSH. I found an awesome tutorial showing me how to use the raspberry in a headless mode. The Network and Sharing Centre was opened and I navigated to Change Adapter Settings. I opened the properties of the Wi-Fi network I intended to share and selected the Allow other network users to connect through this computer’s Internet connection checkbox. Next the Ethernet adapter properties was selected and the IPV4 option double clicked, the IP address was 192.168.137.1. The raspberry pi was powered and one end of the Ethernet cable connected to its Ethernet port. On the Ethernet connection status message was Identifying then eventually Unidentified network. The command prompt was opened and the following command entered.
The pi IP address was revealed. I opened the PuTTY application and typed raspberrypi.mshome.net (raspberry pi IP could also work). A login prompt popped and I successfully logged in.
To test if the internet was successfully shared the following command was entered
ping www.google.com
The connection was successful. The Wi-Fi Adapter was set on the pi after running the command sudo shutdown now and it was made sure that the pi was off to prevent power surge in case on plugged the Wi-Fi Adapter before it was off.
Installation of TP-Link WN723N v.3 on Raspberry Pi
The TP-Link TL-WN723N doesn't work right out of the box so drivers had to be installed onto the Raspberry Pi for it to work.
First I ran the following command to find the kernel version
uname -a
The kernel version was 4.1.19+ #858 (for my case)
Next was to search for the drivers that could work on the TP-Link when inserted on the pi. The following commands were ran
wget https://dl.dropboxusercontent.com/u/80256631/8188...
tar -zxvf 8188eu-20160305.tar.gz
sudo install -p -m 644 8188eu.ko /lib/modules/4.1.19+/kernel/drivers/net/wireless
sudo insmod /lib/modules/4.1.19+/kernel/drivers/net/wireless/8188eu.ko
sudo depmod –a
After installation we rebooted the pi with
sudo reboot
Installation of Software
Next up I installed the software onto the Pi that would act as the 'hostap' (host access point). For this task I needed internet access for this step I made sure that the Ethernet cable was connected both to the pi and computer. The computer was set up to share the internet to the pi via the cable by selecting the Wifi to share then clicking properties
The following lines were run on the PuTTY application
sudo apt-get update
sudo apt-get install hostapd isc-dhcp-server
Set Up DHCP Server
Next I did an edit on /etc/dhcp/dhcpd.conf, a file that sets up the DHCP server (which allows wifi connections to automatically get IP addresses, DNS, etc.)
In order to edit the file I ran the following command
sudo nano /etc/dhcp/dhcpd.conf
I looked for the lines that say
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
and change them to add a # in the beginning so they read as
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
I also for the lines that said the following
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
and removed the # so it said
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
pictures of the two edits above I scrolled to the bottom and added the following lines
subnet 10.10.0.0 netmask 255.255.255.0 {
range 10.10.0.25 10.10.0.50;
option routers 10.10.0.1;
option domain-name-servers 8.8.4.4;
interface wlan0
}
The file was saved by typing in Control-X then Y then return
Then the following command was run
sudo nano /etc/default/isc-dhcp-server
and scrolled down to INTERFACES="" and updated it to say INTERFACES="wlan0"
The file was saved and closed.
Set Up Wlan0 for Static IP
Next I needed to set up the wlan0 connection to be static and incoming. The following command was run
sudo nano/etc/network/interfaces to edit the file
The line that read “iface wlan0 inet manual” was changed to
iface wlan0 inet static
address 10.10.0.1
netmask 255.255.255.0
The file was saved (Control-X Y ).
A static IP address was assigned to the WiFi adapter by running
sudo ifconfig wlan0 10.10.0.1
Installation of Hostapd & Configuring the Access Point
First I downloaded hostapd with the following command
sudo apt-get install hostapd
Next was to configure the access point details. I did set up the password-protected network so that only those with the password would be able to connect to it. A new file was then created by running
sudo nano /etc/hostapd/hostapd.conf
The following lines were pasted
interface=wlan0
driver=nl80211
ssid=GROUP_3
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
The file was saved. I ran the following line to find the configuration file
sudo nano /etc/default/hostapd
The following line was edited #DAEMON_CONF="" to say DAEMON_CONF="/etc/hostapd/hostapd.conf"
The file was then saved.
Configuring Network Address Translation
Next was to set up the Network Address Translation which would allow multiple people to connect to the WiFi and have all data ‘tunneled’ through the single Ethernet IP. The following was ran
sudo nano /etc/sysctl.conf
The following line was added at the bottom after scrolling down
net.ipv4.ip_forward=1
The following file was saved. This caused the IP forwarding to start on boot up. The following line was ran to activate it immediately.
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
The following commands were ran to create a network translation between the Ethernet port eth0 and the WiFi port wlan0.
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
The following line was ran
sudo nano /etc/network/interfaces
and the following added at the very end
up iptables-restore < /etc/iptables.ipv4.nat
A reboot command was entered
sudo reboot
Testing Access Point
The dhcp server was restarted
sudo service isc-dhcp-server restart
To test the access point host the following command was ran
sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
The SSID was visible on computer wifi connections. I tried connecting to GROUP_3 by typing the password – Raspberry.
Next was to set it up as a 'daemon' - a program that will start when the Pi boots. The following commands were ran
sudo service hostapd start
sudo service isc-dhcp-server start
The status of the host AP server and DHCP server were checked by running the following commands
sudo service hostapd status
sudo service isc-dhcp-server status
Next was to try and connect to the Wi-Fi connection (Group_3) with the password as “Raspberry”
A reboot command was entered and the connection tested again.
Mini-DLNA Set Up
Next was to install the media server software. The following command was used to do this
sudo apt – get install minidlna
Before I started the media server I mounted the hard disk (which contained videos, pictures and music) on start-up. The following command was entered
sudo fdisk -I
I needed to access the media, to do this the following command was used
sudo mk dir /media/HardDrive
This command makes a folder called HDD in the media directory. Once the folder was made, it needed to have read and write permissions, this was possible by the following command
sudo chmond 777 /media/ HardDrive
Next was to edit the fstab file, the following command was used
First I ran the following command
sudo blkid
The following information was displayed
UUID="04FE-51E9" TYPE="vfat” The file to be configured was opened with the following command
sudo nano /etc/fstab
I scrolled to the bottom and added the following
UUID=04FE-51E9 /media/HardDrive vfat defaults 0 0
I rebooted the pi with the following command
sudo reboot
The minidlna configuration file was needed to be edited using the command
sudo nano /etc/minidlna . config
Once the file was open I edited the part that looked like this
# * “A” for audio (eg. media_dir=A,/var/lib/minidlna/music)
# * “P” for pictures (eg. media_dir=P,/var/lib/minidlna/pictures)
# * “V” for videos (eg. media_dir=V,/var/lib/minidlna/videos)
To this
media_dir=A,/media/HardDrive/Music
media_dir=P,/media/HardDrive/Pictures
media_dir=V,/media/HardDrive/Movies
media_dir=/media/HardDrive
The following was edited by removing “#” from # friendly_name=
# Name that the DLNA server presents to clients
# friendly_name= Group_3
After configuring MiniDLNA, it was refreshed by running the following command
sudo service minidlna restart
sudo service minidlna force-reload
On the network section of the computer I was able to see our minidlna server. When I viewed on the web I could see the media I had.
In order to test if all was working I ran a shutdown command and detached the Ethernet cable from both the raspberry pi and computer/laptop. I switched on the raspberry pi and connected to the Wi-Fi network (Group_3) and clicked on network section below the local disk and luckily the minidlna server was present (Group_3). To test the minidlna I opened the VLC player and clicked on the Universal Plug ‘n’ Play (UPnP) which detected the minidlna server and I could view our media.
GET YOURSELF SOME POPCORNS YOU DESERVE IT!!