#
Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Monday, July 10, 2023

For this I am using the raspbx-10 which seems to be stable at the moment I do this. The Pi I use is my old model 3 B, but should definetly work on model 4. Aslo I use the current updated SCCP Manager which has a bug. Hopefully the bug will be fixed at the time you read this post but anyhow I will provide a simple work around I did myself to overcome it.

I am writing this post after trying numerous ways to do this using SIP and SCCP but looks like Cisco SIP images were full of bugs and this was the method which worked for me. Note that the phones I use here are very old but this method will do the trick for any Cisco phone model you have and this seems to be the easiest way.

Download the image from official site and fireup a an SD card and load it to the Raspberry Pi.

 Lab setup is simple, all the devices are in the same LAN. DCHP server is created in a router, TFTP is hosted by default in FreePBX server which again is inside my Pi. 
Once the RasPBX is installed, log in using the root username and password and set it up with a static IP.

sudo apt update && sudo apt upgrade -y
apt-get install git
cd /usr/src
git clone https://github.com/chan-sccp/chan-sccp chan-sccp
cd chan-sccp
./configure --enable-conference --enable-video 
make -j2 && make install

Now just use a web browser to access log in to FreePBX and do the initial configuration.
Just give a username and password, an email and a System ID name..
Then use the above given password to log in to the FreePBX Administration on next window.

Now go to Admin -> Asterisk Modules and under Excluded Modules add chan_skinny.so and under Manually Loaded Modules add chan_sccp.so and hit Apply Config..

Now hit a reboot in CLI..

Download the SCCP Manager from following link..

Under Admin -> Module Admin, use Upload Modules to upload the downloaded file.
Now click Manage local modules -> SCCP Manager, hit Install and Process, Confirm..

Here is the place you get the following error.









If you get this error, just go to the cli and hit the following command to edit the php file.
nano /var/www/html/admin/modules/sccp_manager/install.php
just comment the if clause and save it like below.

Now Process, Confirm it again it will be fine, just hit Return..
Now you can see new SCCP Connectivity Tab appear in the PBX.
Go to SCCP Connectivity -> Server Config and set SCCP Server Name to Asterisk.
Move to SCCP Device and Change the Digit Timeout to 2 which is more practical for lab.
Move to SCCP Time and check Yes to NTP Server Enabled and change the Time Zone to match yours..
Hit Submit and Apply Config..

Now download the images from Cisco official site. The phone model I am using is 7945G.
I used version Firmware version 9.4(2)SR4 which is kind of a latest. Make sure to download the .zip file not the cop.sgn file.




Now unzip the files and load them to /tftpboot directory using a SFTP client like FileZilla.
Following are the firmware files.









Now go back to SCCP Connectivity -> System Parameters and select Show All from drop down.
Search for 7945 and hit the Pencil mark in Actions. 

Copy the Load Image name from the actual file name and paste it (without .loads extension) and hit Apply.






Now go to Sccp Connectivity Tab -> Phones Manager. Click Add Extension.
In General Tab, I entered this phone Extension and Display Name both to be 1001 and hit Submit.




Again go to SCCP Manager -> SCCP Phone and click Add Device Phone.
Under Device Configuration, enter the MAC address of the phone and Type to match something like 7940 (7945 was not there). Also I changed the device label to be 1001. The label has nothing to do with the extension. 


















The Line is mapped at the Device Buttons tab..








Now Plug the phones to the switch and give the hard reset.
Hard reset is giving power pressing the # key until the line buttons blink and then push 123456789*0#

Then the phones will register..

Please note that the following is the DHCP configuration in my router.

Option 150 must be configured to identify the TFTP server..

Sunday, February 19, 2017

You can use any web server or even a PC if you can afford it for your web host. This is just how I did it with my Raspberry Pi..

Start with giving your server a static IP address from your private home network. I gave 192.168.1.254 to my Pi and connected it to my home router.

If your server is a Debian based like mine, you can enter the exact commands I enter from here, or you must find alternatives from online to do what I do here..

Enter following commands to install Apache and PHP modules..
sudo apt-get install apache2
sudo apt-get install php libapache2-mod-php -y

May be you need to restart the Apache server; Enter following command
sudo service apache2 restart

Now Enter your IP address on a webserver; It will point to the default landing page of Apache. 

Now navigate to the default hosting page directory by entering the following command..
cd /var/www/html

Now if you hit ls you can see the index.html page which is the default landing page of Apache.
You can delete this by entering the following command..
sudo rm -f index.html

Now you can replace contents of your website here. I am just creating a default simple page by entering the following commands..
sudo nano index.html

Now hit Ctrl+X, Y & Enter to save it.




If the static IP of the server is entered on the web browser, you can see the home page of your website now..

Now it is the time to create a DDNS account from a service provider. There are plenty of DDNS service providers out there. I created an account on no-ip.com


It is very simple to get a web address through your DDNS service provider online. Just use common IT sense..







You can see the IP address assigned to your web address. Now you need to install the Dynamic Update Client of your DDNS service provider on your server..

Enter the following commands to create a folder, download and unzip the Client..
sudo mkdir /home/pi/noip
cd /home/pi/noip
sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
sudo tar vzxf noip-duc-linux.tar.gz

Now hit ls to view the contents of the folder.




Now you can see the folder is noip-2.1.9-1
Enter following commands to compile the Client..
cd noip-2.1.9-1
sudo make
sudo make install



















By entering the following command you can run the Client;
sudo /usr/local/bin/noip2

Finally you need to set Port Forwarding on your home router.

How you do it depends on the type of your router. My home router is a TP-Link one. On it's administration page, there is an option named "NAT" and under that there is another option named "Virtual Server" to setup port forwarding. Following capture shows you all the configuration..

















Now everything is done. You can type the URL you got from your DDNS provider and enter it on your web browser to see whether your website is online or not..


Monday, January 9, 2017

I wanted to connect my lab equipment to an external dedicated DHCP server but the problem is my home ADSL router is too far to connect via a cable. So I decided to use my Pi to do DHCP work. It's simple but many online tutorials would not work if you are using newer R-Pi (Ex:- Model B-3). So I decided to take a note on it. There are many ways to do this & this is how I did it..

First of all, you should assign a static IP address to your Ethernet interface of Pi..
Best way is to use GUI..

Go to the network icon of the front right corner and edit settings.

Give your interface a static IP and a DNS server address. I want the DHCP service to run on Ethernet interface only. So I did it to Eth0 only. If you want it to go wireless, you have to edit the Wlan0 settings.

Enter the following command to download the required package..
sudo apt-get install dnsmasq

Now enter following commands to create a backup default config file for the DHCP server..
cd /etc
sudo mv dnsmasq.conf dnsmasq.default

Now goto the file and specify the parameters and save & exit..
sudo nano dnsmasq.conf

interface=eth0
dhcp-range=10.1.1.10,10.1.1.20,255.255.255.0,12h

It says that the interface which listens DCHP requests is eth0 and the range of IPs to offer are 10.1.1.10 - 10.1.1.20 with a subnet mask of 255.255.255.0 and the leased time is for 12 hours..
Now enter the following command to start the service effectively..
sudo service networking restart

Even though the Pi is rebooted the DHCP service will be delivered..

Tuesday, January 3, 2017

I don't know whether this term "Wireless Bridge" really can be used to this, anyway it does what I want to do which is more like acting as a point to point wireless link. The reason I wanted this is my new networking lab hardware (routers/switches/servers) which do not have a wireless adapter, needs to connect to internet to get updates/ ping internet etc and the home router is in a another room (about 50 feet from my lab). I don't like to mess with Ethernet cables around my home. If I had to lay an Ethernet cable, it should have to be done from outside of the house or else I have to drill holes through my walls.
So I chose to give a wireless solution with the things I have..

Sample setup is like the following..












Assign IP Addresses

I assigned an IP address to Pi's Ethernet interface. I gave 10.1.1.5
Assigned Pi's Ethernet IP address as the default gateway of the devices (ex:- server)
Pi's wireless interface does not need to be manually configured, as it gets a DHCP IP address from the ADSL router.. Only what needed was to give the WiFi password and connect to the network..

Enable IP Forwarding in Pi

IP forwarding should be enable to route traffic between interfaces. Entered the following command to edit the sysctl file..
sudo nano /etc/sysctl.conf

Scrolled down until I found #net.ipv4.ip_forward=1 and uncommented it (removed #) and hit Ctrl + X, Y, Enter to save and quit.















Entered the following command too..
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Setup Network Address Translation (NAT)

From the IPs comming from the Ethernet interface side of the Pi will not be able to go to Internet and comeback with their own source IP because the real default gateway of my home network, the ADSL router (192.168.1.1) does not know those source IP addresses to route traffic back. It only knows the 192.168.1.0 subnet which it leases from it's DHCP.

Entered the following command..
sudo /sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

Edit IP Tables

Now let's see my Pi's routing table (IP tables)






As I can see there are 2 default routes in the table.
Via Eth0 interface with a metric of 202..
Via Wlan0 interface with a metric of 303..

Eth0 interface will be the preferred path by default because of the lower metric. Here, I'm deleting the 1st default route by entering the following command. Let's see what happens..
sudo route del default






Now only one default route is there and it is the wlan0 interface. So now everything works fine for me..

Save IP Tables

I wanted to save the routing table and the forwarding configurations I made because otherwise every time I power off the Pi, it will go to defaults and I have to config again and again.

This is how I saved my work..

Entered the following commands..
sudo apt-get install iptables-persistent

After installation is done, following commands will save the iptables and start at the bootup..
sudo su
iptables-save >/etc/iptables/rules.v4

Now all done, Bridge works fine..

Note:- 

Each time I add persistent route to the routing table, I have to save it using the above 2 commands. Then only they will survive after a reboot..
In addition to this setup, if you want to connect to the subnets beyond the Pi's end via the home router (ex:- connect 10.1.1.0 subnet from my laptop) you willl have to put static routes on the home router.
ex:- static route to 10.1.1.0 as the next hop 192.168.1.7

Monday, January 2, 2017

SBCs (Single Board Computers) are a good way to reduce your infrastructure cost easily. It is more reliable because it is a dedicated hardware and doe not need expensive licenses like when you deal with Hyper-visors. Also it is a good and cheap environment for learners and lab testers of these tools on Linux servers. In this post we will see how Cacti will be installed on a Raspbary Pi.

About Cacti, It is an open source web-based network monitoring tool which can do lot of things if you configured it well.
Go to the Pi's terminal and enter the following command to install Cacti
sudo apt-get install cacti

During the installation, your 1st stop will be to give a root password for the MySQL server.



Because I didn't install a database server this will popup.

(click on images to view in full)





Next, it will ask to install a web server..

I chose the default Apache2..


Now it will go again with a long installation procedure..






Again it will stop to ask whether you like to configure database for Cacti..

Hit Yes and enter the password you entered previously as the database admin password..




Next it will ask for MySQL application password for Cacti..






Now the installation is done..

Now open a web browser from a PC which can reach the Pi and type the "ip address of the Pi with a following /cacti" on url space..

Ex:- 192.168.1.7/cacti



Hit Next and it will ask whether this is a new installation or an upgrade..

Go for new and you will have the following page.




































After hitting Finish, you will be asked for the Cacti login. Default login is un:admin pw:admin
So the installation is complete.. Let's configure some devices using SNMP on a later post..

Monday, November 14, 2016

Most of the time Network Engineers use a dedicated laptop with internet connection to access and troubleshoot their networks remotely when they do not have physical access. This is what I call a Remote Access Server here (I don't know what others call it) & I am going to create a low cost solution for this using existing software tools you know. I spent about 50$ for the entire setup.

Before you go through this, go through my previous post Get Raspberry Pi into Networking to complete the basic setup needed.

Install TeamViewer & Fine Tuning

Now download Teamviewer Host for Raspberry Pi from here from the Pi's web browser.
Go to Downloads and right click on the package and install it.

After installation is completed, go to the desktop via TightVNC and go to Menu > Internet > TeamViewer Host and accept terms and conditions and on the app, go to settings > Security and disable the random password from drop down menu.

You can enter following command in Terminal to get the Teamviewer ID and other info from CLI.
teamviewer info 

Now enter the following command to set a static password which will really work.
sudo teamviewer passwd <your password>

This password will be used to log into Teamviewer later on.

Now go to Terminal and enter following command to edit the config.txt file to change the console resolution to match your PC. Resolution of my PC is 1920x1080
sudo nano /boot/config.txt

Now uncomment disable_overscan=1 and framebuffer_widthframebuffer_height parameters and change the values like the following capture.














Hit Ctrl+X and Y and Enter to save and exit.
Hit sudo reboot and after reboot access through your PC's Teamviewer giving the ID and password.

Now you can install other necessary software like Wireshark, SecureCRT or PAC Manager to SSH access etc.

Install Wireshark

Enter following command to download and install Wireshark
sudo apt-get install wireshark

Hit Yes for the dialog box which will prompt

Now enter,
sudo usermod -a -G wireshark pi

Hit sudo reboot and after reboot go to desktop from either TeamViewer or TightVNC and got to
Menu > Internet > Wireshark

Install Putty and Console to a Cisco Device

Start with plugging your console cable to one of the USB ports on your Pi.

Enter following command to Install Putty
sudo apt-get install putty

Time to find out the port of the USB-Serial cable is using. Therefore enter,
dmesg | grep tty
















Look at the last line which says ttyUSB0  which means my Pi is using ttyUSB0

While selecting Putty's serial connection select /dev/ttyUSB0











Notes:-

Make sure to change default usernames and passwords after everything is done because it is critical to add some security to this box which could manage the network you work with.

Saturday, October 1, 2016

As many electronic enthusiasts know, Raspberry Pi is a small credit card size computer which runs a Linux operating system called Raspbian which can be used in many ways to do computer engineering stuff. I am writing this post which I will use as a reference to my future posts regarding network solutions which can be provided using this small piece of electronics.

Get Hardware Fixed

Assemble Raspberry Pi into the casing with a fan. Because this is going to be a server, it is better to use a casing with a fan to reduce the heat caused by continuous long time operation. The only thing you need to know in fixing hardware is where to plug the fan. (click on the image to view full size)

Put it just like I have done on the long GPIO / Input Output line running on the board. 

Power (Red) must be connected to the 2nd pin from the left and the Ground (Black) must be connected to the 3rd pin from the left.





Format SD card

SD card is the hard disk of this machine.
You will also need a card reader if your PC does not have a SD card reader slot. Also before buying a SD card, check whether the card supports Raspberry Pi or not though most cards do support. 

To correctly format it use SDF Formatter from here











Go to Option and select Format Type as FULL (Erase) and Format Size Adjustment ON

Now go to My Computer and right click on the SD card and select Format.


This time select the File System as exFAT because it is more faster and select Quick Format and hit Start.


Now the Hard Disk is ready to install the OS.










Burn Raspbian OS to SD card

Now download Raspbian OS (Jessie) from Raspberrypi.org
Do not download Noobs if you do not have a HDMI cable and  a LCD Display because SSH is not active by default in Noobs. I'm going to do SSH to install a remote access software like VNC next.
So I need clean OS which the SSH is enabled by default.

Time to download Win32 Disk Imager from here.


Select the downloaded image and hit Write.

Now the SD card is fully ready to insert in to the Raspberry Pi.





Boot up, SSH & Update Packages

Now plug your Pi to a 2.5A power plug (which is recommended) and plug an Ethernet Cable to the Pi which is connected to your home router. Because DHCP is enabled by default on the Ethernet port, it is the easiest way. And aslo you can guess the ip address which it will get by looking at your PC's IP and if you know how many devices are connected. If you are not sure, download a scanner like Advanced IP Scanner from here.












You can see the IP address of my Pi is 192.168.1.7 which I'm going to SSH into.
Download Putty to do SSH. SecureCRT will not work because of a SSH version mismatch.
























Select port 22, SSH etc. Just normal terminal access.

Hit Open.

In the 1st time you SSH, it will prompt an Security Alert in Putty.
Hit Yes to ignore it and log in to the Pi.

Default Logins:-

Log in as: pi
Password: raspberry

After logged in, enter the following command in terminal to access Pi's software configuration tool.

sudo raspi-config

Select Expand Filesystem to use all the space in SD card for root partition.

Hit Ok for the next dialog box and it will ask to reboot. Hit Ok and start a new SSH session after reboot.

Now enter following commands to download & update packages.

sudo apt-get update
sudo apt-get dist-upgrade

To view the available space in memory enter following command anytime in terminal.

df -h

After packages are updated, enter following commands to clean the downloaded update packages to free space & reboot.

sudo apt-get clean
sudo reboot

Install TightVNC to Access Desktop

Enter following commands to install and run TightVNC

sudo apt-get install tightvncserver
tightvncserver

It will ask a password to the remote session. It will be used to login to the Pi via TightVNC. After confirming that it will ask a view only password. You can ignore that.

Remember to enter "tightvncserver" command to start a session with Pi everytime you reboot before accesing through TightVNC.

Now install TightVNC on your native PC from here.

Now open TightVNC from your PC and start a session to your Pi by giving IP address with a : followed by a 1 for the session like shown in the screen capture.


Hit Connect and it will ask the password. Give the password entered a short while ago and hit OK




Now you are on the desktop of the Pi.
Now it's only a GUI. You can move around easily and customize as you like.

From upper right hand corner, you can see the network icon on the tray. Click on it to connect Wifi network too using your Wifi Key. You can also give static IP from here too.





Go to Menu > Preferences > Raspberry Pi Configuration

You can change many important things here like Hostname, Password, Enable Interfaces, Overscan, Date and Time etc and reboot the Pi to make the changes effective.