Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 07, 2019 5:17 pm

Hi, I have used/own the original Raspberry Pi 1 some years ago but never had a project for it. So I’m still a beginner in the Linux world.

I’m using an Amcrest camera which I don’t want running on my home network. (not sure but it appears to be talking to the outside world, which I don’t want.)

I would like to use my Raspberry Pi 3 Model B as a Wi-Fi access point and FTP file location, the Amcrest Camera Image’s & video files are sent via Wi-Fi to the FTP site also running on same PI 3. The Pi will not be connected to the Internet, it will run in a self-contained network.

I would use a laptop to connect to Pi’s Wi-Fi to view any images or Videos footage the camera has taken and sent to FTP site.

I just need to know what software I would need to make it possible. And would I run it all from the native Raspbian OS distribution, or is there a more suitable Linux distribution OS for this task.

Thanks for any help.

epoch1970
Posts: 3322
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Mon Jul 08, 2019 12:43 pm

Follow the 1st part of this document.
https://www.raspberrypi.org/documentati ... s-point.md

You'll need to add an FTP server to the mix. I suggest you start w/ the AP setup and then come back to the FTP part.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Mon Jul 08, 2019 6:24 pm

Thanks for the link. I'll read it tonight and make a start on it later this week.

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Fri Jul 12, 2019 5:10 pm

I'm having some problems with the first part after installing hostapd I get the error :
Job for hostapd.service failed because the control process exited with an error code. See "systemctl status hostapd.service" and "journalctl -xe" for details.
It then creates symlink /etc/systemd/system/hostapd.service /dev/null.

I decided to follow the rest of the guide until I got to the hostapd and I got as far as
Sudo systemctl start hostapd
after which I get exactly the same error as a above.

How do I fix this?

epoch1970
Posts: 3322
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Fri Jul 12, 2019 5:42 pm

The guide specifies 3 commands:

Code: Select all

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd
The error you report could suggest you missed the "unmask" or perhaps "enable" ones?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Fri Jul 12, 2019 5:54 pm

I've typed the three commands again and I still get the same error.

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sat Jul 20, 2019 10:30 am

I decided to try this again, and used raspbian-stretch rather than buster version.
I don’t know if it was the OS version or a typo but it’s now working. (both my laptop and phone can connect to it.)
I’m now back and ready to move to FTP part. Any suggestion on how setup the next step?

Andyroo
Posts: 3768
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sat Jul 20, 2019 10:47 am

Simplest FTP site set up I know is nicely documented https://www.raspberrypi-spy.co.uk/2018/ ... pberry-pi/
Need Pi spray - these things are breeding in my house...

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sat Jul 20, 2019 11:44 am

Oh dear maybe I should have setup FTP first as I’ve lost the Ethernet connection to the internet.
I believe configuring the static IP using dhcpcd has done this?

Anyway to segregate the Ethernet connection so it can still connect to my router’s internet connection? Or should I start again?

Or is it possible to get packages off the internet using my windows laptop or my mac-mini and copy it to a usb drive to my Pi, would anyone know the links I would need?

Andyroo
Posts: 3768
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sat Jul 20, 2019 3:13 pm

Did you overwrite dhcpcd.conf?

Do you want to publish it here? No need to hide the local addresses as we cannot get to them :)
Need Pi spray - these things are breeding in my house...

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 7:33 am

Yes I overwrote the file as I only needed to add to end of file what was described in the guide.

Code: Select all

 
 # A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0

inferface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant

epoch1970
Posts: 3322
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 8:21 am

Captain-Pie wrote:
Sun Jul 21, 2019 7:33 am
Yes I overwrote the file as I only needed to add to end of file what was described in the guide.
If you’ve lost connection to the internet via the Ethernet cable, it is not due to this file.

Check /etc/network/interfaces is empty as it should.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 12:45 pm

I only seem to have an /etc/network/interfaces.d folder see image here:
Desktop1.jpg
Desktop1.jpg (107.47 KiB) Viewed 523 times
Image

epoch1970
Posts: 3322
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 12:51 pm

On the picture you posted: there is a file "interfaces" next to a directory "interfaces.d"
The directory must be empty. It is, fine.
The file must be devoid of any configuration. Check it.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 1:13 pm

ok here is the file contents for Interfaces do erase the last line?

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

Andyroo
Posts: 3768
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 2:00 pm

You can just comment it out with a hash (pound) at the start but all that is doing is instructing the system to read any file in that directory for config.

Not sure if it would help but commenting it out will not hurt.
Need Pi spray - these things are breeding in my house...

epoch1970
Posts: 3322
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 2:12 pm

Captain-Pie wrote:
Sun Jul 21, 2019 1:13 pm
ok here is the file contents for Interfaces do erase the last line?
That is stock as well. You can leave it as is.

Now this raises a question: what is making ethernet fail to get an IP??
Can you post the output of "ifconfig -a" and "route -n"?
And also the contents of /etc/resolv.conf.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 2:59 pm

ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.4.1 netmask 255.255.255.0 broadcast 192.168.4.255
inet6 fe80::b3e0:f816:2678:a78d prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:79:5b:3a txqueuelen 1000 (Ethernet)
RX packets 25 bytes 3911 (3.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 22 bytes 3042 (2.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 480 bytes 32160 (31.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 480 bytes 32160 (31.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::d3a7:4615:bb29:fa42 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:2c:0e:6f txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 1678 (1.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.4.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0


/etc/resolvconf/update.d/dnsmasq

Code: Select all

#!/bin/sh
#
# Script to update the resolver list for dnsmasq
#
# N.B. Resolvconf may run us even if dnsmasq is not (yet) running.
# If dnsmasq is installed then we go ahead and update the resolver list
# in case dnsmasq is started later.
#
# Assumption: On entry, PWD contains the resolv.conf-type files.
#
# This file is part of the dnsmasq package.
#

set -e

RUN_DIR="/run/dnsmasq"
RSLVRLIST_FILE="${RUN_DIR}/resolv.conf"
TMP_FILE="${RSLVRLIST_FILE}_new.$$"
MY_NAME_FOR_RESOLVCONF="dnsmasq"

[ -x /usr/sbin/dnsmasq ] || exit 0
[ -x /lib/resolvconf/list-records ] || exit 1

PATH=/bin:/sbin

report_err() { echo "$0: Error: $*" >&2 ; }

# Stores arguments (minus duplicates) in RSLT, separated by spaces
# Doesn't work properly if an argument itself contains whitespace
uniquify()
{
	RSLT=""
	while [ "$1" ] ; do
		for E in $RSLT ; do
			[ "$1" = "$E" ] && { shift ; continue 2 ; }
		done
		RSLT="${RSLT:+$RSLT }$1"
		shift
	done
}

if [ ! -d "$RUN_DIR" ] && ! mkdir --parents --mode=0755 "$RUN_DIR" ; then
	report_err "Failed trying to create directory $RUN_DIR"
	exit 1
fi

RSLVCNFFILES=""
for F in $(/lib/resolvconf/list-records --after "lo.$MY_NAME_FOR_RESOLVCONF") ; do
	case "$F" in
	    "lo.$MY_NAME_FOR_RESOLVCONF")
		# Omit own record	 
		;;
	    lo.*)
		# Include no more records after one for a local nameserver
		RSLVCNFFILES="${RSLVCNFFILES:+$RSLVCNFFILES }$F"
		break
		;;
	  *)
		RSLVCNFFILES="${RSLVCNFFILES:+$RSLVCNFFILES }$F"
		;;
	esac
done

NMSRVRS=""
if [ "$RSLVCNFFILES" ] ; then
	uniquify $(sed -n -e 's/^[[:space:]]*nameserver[[:space:]]\+//p' $RSLVCNFFILES)
	NMSRVRS="$RSLT"
fi

# Dnsmasq uses the mtime of $RSLVRLIST_FILE, with a resolution of one second,
# to detect changes in the file. This means that if a resolvconf update occurs
# within one second of the previous one then dnsmasq may fail to notice the
# more recent change. To work around this problem we sleep one second here
# if necessary in order to ensure that the new mtime is different.
if [ -f "$RSLVRLIST_FILE" ] && [ "$(ls -go --time-style='+%s' "$RSLVRLIST_FILE" | { read p h s t n ; echo "$t" ; })" = "$(date +%s)" ] ; then
	sleep 1
fi

clean_up() { rm -f "$TMP_FILE" ; }
trap clean_up EXIT
: >| "$TMP_FILE"
for N in $NMSRVRS ; do echo "nameserver $N" >> "$TMP_FILE" ; done
mv -f "$TMP_FILE" "$RSLVRLIST_FILE"

/etc/resolvconf/update-libc.d/avahi-daemon

Code: Select all

#!/bin/sh
#
# If we have an unicast .local domain, we immediately disable avahi to avoid
# conflicts with the multicast IP4LL .local domain

if [ -x /usr/lib/avahi/avahi-daemon-check-dns.sh ]; then
  exec /usr/lib/avahi/avahi-daemon-check-dns.sh
fi

Andyroo
Posts: 3768
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 3:09 pm

You have no default route on eth0 to the Internet (normally via the router).

You can add these into dhcpcd.conf along these lines:

Code: Select all

interface eth0
static routers=192.168.1.254
static domain_name_servers=192.168.1.254 8.8.8.8
Obviously change the IP addresses to match your needs.

Not sure if that will impact the AP functions though (esp if the WiFi clients need access to the Internet).
Need Pi spray - these things are breeding in my house...

epoch1970
Posts: 3322
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Sun Jul 21, 2019 3:47 pm

Captain-Pie wrote:
Sun Jul 21, 2019 2:59 pm

Code: Select all

ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.4.1  netmask 255.255.255.0  broadcast 192.168.4.255
        inet6 fe80::b3e0:f816:2678:a78d  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:79:5b:3a  txqueuelen 1000  (Ethernet)
        RX packets 25  bytes 3911 (3.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 22  bytes 3042 (2.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Your home network is 192.168.4.0? In other words, the IP address of the computer you're reading this post from is 192.168.4.x?
The routing table on your Pi is messed up because 192.168.4.0/24 is also the network you have picked for your separate wifi network (as per the official guide above.)

Change either one. I suggest changing the wifi network, it should have less impact.
For example in /etc/dhcpcd.conf, change the wlan0 definition to

Code: Select all

inferface wlan0
static ip_address=192.168.5.1/24
nohook wpa_supplicant
and /etc/dnsmasq.conf to

Code: Select all

interface=wlan0      # Use the require wireless interface - usually wlan0
dhcp-range=192.168.5.2,192.168.5.20,255.255.255.0,24h
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Mon Jul 22, 2019 7:08 pm

I've tried both below still not working. The Ethernet just uses wlan0 (WiFi) ip address 192.168.5.1/24
by epoch1970 » Sun Jul 21, 2019 3:47 pm
Your home network is 192.168.4.0? In other words, the IP address of the computer you're reading this post from is 192.168.4.x?
The routing table on your Pi is messed up because 192.168.4.0/24 is also the network you have picked for your separate wifi network (as per the official guide above.)

Change either one. I suggest changing the wifi network, it should have less impact.
For example in /etc/dhcpcd.conf, change the wlan0 definition to

Code: Select all

inferface wlan0
static ip_address=192.168.5.1/24
nohook wpa_supplicant

and /etc/dnsmasq.conf to

Code: Select all

interface=wlan0 # Use the require wireless interface - usually wlan0
dhcp-range=192.168.5.2,192.168.5.20,255.255.255.0,24h
and
by Andyroo » Sun Jul 21, 2019 3:09 pm
You have no default route on eth0 to the Internet (normally via the router).

You can add these into dhcpcd.conf along these lines:

Code: Select all

interface eth0
static routers=192.168.1.254
static domain_name_servers=192.168.1.254 8.8.8.8

Obviously change the IP addresses to match your needs.

Not sure if that will impact the AP functions though (esp if the WiFi clients need access to the Internet).

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Wed Jul 24, 2019 7:45 pm

Ok I solved my lost Ethernet connection to the internet. I just needed to add a static IP address outside DHCP range.

I added to dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.0.210/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8
I'll look into the FTP at the weekend now.

Captain-Pie
Posts: 15
Joined: Sun Jul 07, 2019 4:47 pm
Location: London

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Tue Jul 30, 2019 6:58 pm

I looked into guide for creating a simple FTP server with the raspberry Pi using https://www.raspberrypi-spy.co.uk/2018/ ... pberry-pi/ but I don’t think this would work for me as I would be using an external 500GB USB 3 drive with the folder named ‘Amcrest’ for the FTP location.

Also the drive in question would be exFAT formated preferably. (I would need to download support for exFAT I guess) As I may need to copy off large files to my windows laptop or Mac mini.
I believe this would be faster then copying using Pi FTP over WiFi?

I cannot see how I would achieve this using vsftpd?

Andyroo
Posts: 3768
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Pi Wi-Fi access point with FTP site running in a self-contained network.

Tue Jul 30, 2019 7:16 pm

Any directory can be set as the ftp home by the line

Code: Select all

local_root=/home/$USER/ftp
in the config file.

All you need to do is mount the external drive and point the FTP site to the mount point.

I find this better than pointing the FTP to the external disk as I can maintain what drive hosts what by the mount rather than editing files here there and everywhere for multiple apps :lol:
Need Pi spray - these things are breeding in my house...

Return to “Networking and servers”