7 useful functions that a network RaspberryPi can do (FTP-TFTP-WEB-SAMBA-SYSLOG-RADIUS-DHCP)

Let’s see how to set up a Raspberry Pi to use it as a server on your local network.

Below you will find a list of commands and actions to perform step by step to configure the device.


[1] SERVER FTP

mkdir -p /home/pi/files/
chmod 777 /home/pi/files/
sudo bash
apt-get install pure-ftpd -y
pure-pw useradd pi -u pi -g pi -d /home/pi/files/

set as password: raspberry, then

pure-pw mkdb
ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb
service pure-ftpd restart

 

[2] SERVER TFTP

wget http://downloads.sourceforge.net/project/tftp-server/tftp%20server%20single%20port/opentftpspV1.66.tar.gz
tar xvf opentftpspV1.66.tar.gz
cd opentftp/
g++ opentftpd.cpp -oopentftpd -lpthread
mkdir /home/pi/files
chmod 777 /home/pi/files/
sudo bash
cp opentftpd /usr/bin/
vi /etc/opentftp.ini

in the file you should verify or add the following content

[LISTEN-ON]
[HOME]
/home/pi/files
[TFTP-OPTIONS]
username=pi
ThreadPoolSize=10
Read=Y
Write=Y
Overwrite=Y
/usr/bin/opentftpd -i /etc/opentftp.ini

 

[3] WEB SERVER

mkdir -p /home/pi/files/
chmod 777 /home/pi/files/
sudo bash
apt-get install apache2 -y
rm -rf /var/www/html/
ln -s /home/pi/files/ /var/www/html

 

[4] SAMBA SERVER

mkdir -p /home/pi/files/
chmod 777 /home/pi/files/
sudo bash
apt-get update
apt-get install samba -y
rm /etc/samba/smb.conf
vi /etc/samba/smb.conf

 

in the file you should verify or add the following content

[global] netbios name = server server string = server workgroup = WORKGROUP security = user

[server] comment = server path = "/home/pi/files/" public = yes guest ok = yes read only = no

pdbedit -a -u pi

set as password: raspberry, then

service smbd restart

 

[5] SYSLOG SERVER

mkdir -p /home/pi/files

chmod 777 /home/pi/files

sudo bash

apt-get install syslog-ng -y

edit the config file found in:

/etc/syslog-ng/syslog-ng.conf

change the permissions settings of the config file from 640 to 644:

options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no); owner("root"); group("adm"); perm(0644); stats_freq(0); bad_hostname("^gconfd$");

};

insert in the file also these 3 line configurations:

source s_net { udp(ip(0.0.0.0) port(514)); };

destination d_files { file("/home/pi/files/${YEAR}_${MONTH}_${DAY}__${HOST}"); };

log { source(s_net); destination(d_files); };

save the modified file and restart the server:

service syslog-ng restart

[6] RADIUS SERVER

sudo bash
apt-get update
apt-get install freeradius -y

edit (with vi <file>) the config file located in:

/etc/freeradius/clients.conf

in the file you will have to verify or add the following content

client 0.0.0.0/0 {
secret = {RADIUS server shared key}
shortname = anyone
}

edit (with vi <file>) the config file located in:

/etc/freeradius/users

in the file you will have to verify or add the following content

testuser Cleartext-password := "password"

[7] DHCP SERVER

sudo bash

set a static IP in the file

/etc/dhcpcd.conf

for example, enter

static value
interface eth0
static ip_address=192.168.0.1/24
static routers=192.168.0.254
static domain_name_servers=8.8.8.8

restart the raspberry

reboot

update

apt-get update
apt-get install isc-dhcp-server -y

edit the config file for DHCP located in  /etc/dhcp/dhcpd.conf

For example, enter

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.20 192.168.0.40;
option routers 192.168.0.254;
option domain-name-servers 8.8.8.8;
}

if you also want to enter additional options based on vendor, add

option vendor-class-identifier "AppleInc";
option vendor-encapsulated-options "192.168.1.100";

launch the DHCP server with the command

dhcpd -cf /etc/dhcp/dhcpd.conf
Share on Social Media
Scroll to Top