liderbug
Posts: 143
Joined: Sat Oct 08, 2011 4:47 pm

RP 3B, Stretch, Access point

Tue Jun 05, 2018 2:08 pm

This write up is for:

Code: Select all

     Raspberry Pi 3 Model B Rev 1.2
     uname -r:  Stretch  ver: 4.14.34-v7+
To say that this has been a painful trip in that "Make a Hot Spot/Access Point in 10 minutes" failed. Problem being the 20 some write up's were written for pre-Jessie and pre-3 and and and... A.N.D along comes Jessie then Stretch and without (public) reason little things, like /etc/network/interfaces, are no longer used - empty. But with help, Merci, I have been able to get it up and running. Well I can find the SSID, connect, connect to the cloud, etc.

( my situation: I use a RasPi to control my hydroponic greenhouse that is at 80+% the limit of my primary router. I ran Cat-5 to the greenhouse - which was fine until I wanted to include some ESP8266 chips for temp/humd. control. And then... )

I think/hope I've read my notes correctly plus my memory (ha) for the instructions below - if something doesn't go right let me know and I'll be happy to try and help. (of mi tiping...)
===============================================

Note: I don't do windoz.
I downloaded: 2018-04-18-raspbian-stretch.
> dcfldd if=2018-04-18-raspbian-stretch.img of=/dev/sdx bs=1M
(x= what the system sees as the drive)
I use dcfldd vs dd to load the uSD card (I can see the progress)

sudo mount /dev/sdx1 /mnt
cd /mnt
sudo touch ssh
sync
sudo umount /mnt

sudo mount /dev/sdx2 /mnt
cd /mnt/etc

sudo vi /etc/dhcpcd.conf
replace contents with:

Code: Select all

hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
option interface_mtu
require dhcp_server_identifier
slaac private

interface eth0
static ip_address=192.168.0.153/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8 8.8.4.4

interface wlan0
static ip_address=192.168.2.1
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8 8.8.4.4

denyinterfaces eth0
denyinterfaces wlan0
==============================

sync
umount /mnt

I think that is all I did pre boot - so... insert SD card and boot
Then: ssh [email protected]


apt-get -y install dnsmasq hostapd

vi /etc/hostapd/hostapd.conf

Code: Select all

interface=wlan0
driver=nl80211
country_code=US
ssid=GH2
hw_mode=g
channel=7
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
wmm_enabled=0
macaddr_acl=0
auth_algs=1
wpa=2
ignore_broadcast_ssid=0
wpa_passphrase=34fce5800a
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
vi /etc/default/hostapd

Code: Select all

Change the line:
#DAEMON_CONF=""
to
DAEMON_CONF="/etc/hostapd/hostapd.conf"
vi /etc/dnsmasq.conf

Code: Select all

dhcp-mac=set:client_is_a_pi,B8:27:EB:*:*:*
dhcp-reply-delay=tag:client_is_a_pi,2

no-resolv
interface=wlan0
domain-needed
bogus-priv
dhcp-range=192.168.2.11,192.168.2.200,255.255.255.0,24h
server=8.8.8.8
server=8.8.4.4
vi /etc/resolvconf.conf

Code: Select all

# Configuration for resolvconf(8)
# See resolvconf.conf(5) for details

resolvconf=NO

resolv_conf=/etc/resolv.conf...
vi /lib/systemd/resolv.conf (add)

Code: Select all

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 192.168.0.1
vi /etc/sysctl.conf and uncomment the line:

Code: Select all

net.ipv4.ip_forward=1
sudo raspi-config and ... well whatever...

Then:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables –A FORWARD –i eth0 –o wlan0 –m state --state RELATED,ESTABLISHED –j ACCEPT
iptables –A FORWARD -i wlan0 –o eth0 –j ACCEPT
[/code

apt-get install iptables-persistent
systemctl enable netfilter-persistent.service
systemctl start netfilter-persistent.service
Not sure about the above 2 lines being needed, but...

After reboot running ps on: dhcp, dnsmasq & host I get:
==================
root 358 1 0 Jun04 ? 00:00:02 /sbin/dhcpcd -q -b
==================
dnsmasq 497 1 0 Jun04 ? 00:00:01 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,19036,8,2,49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5 --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d
==================
root 518 1 0 Jun04 ? 00:00:03 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf
==================

For warm fuzzies ... run: iptables-save

Code: Select all

# Generated by iptables-save v1.6.0 on Tue Jun  5 07:38:21 2018
*filter
:INPUT ACCEPT [1556:156434]
:FORWARD ACCEPT [36:2160]
:OUTPUT ACCEPT [861:100855]
COMMIT
# Completed on Tue Jun  5 07:38:21 2018
# Generated by iptables-save v1.6.0 on Tue Jun  5 07:38:21 2018
*nat
:PREROUTING ACCEPT [102:14057]
:INPUT ACCEPT [86:13137]
:OUTPUT ACCEPT [8:552]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Tue Jun  5 07:38:21 2018
Then on your phone, Settings,Wi-Fi, [the SSID you picked] ...
or on your laptop: nmcli dev wifi con GH2 password 34fce5800a
Last edited by liderbug on Mon Jun 11, 2018 3:33 am, edited 8 times in total.

liderbug
Posts: 143
Joined: Sat Oct 08, 2011 4:47 pm

Re: RP 3B, Stretch, Access point

Wed Jun 06, 2018 1:55 am

I ran into the problem if "Obtaining ip address" ... forever. I had copied over the iptables from another computer - which didn't have the following:

Code: Select all

iptables –t nat –A POSTROUTING –o eth0 –j MASQUERADE
iptables –A FORWARD –i eth0 –o wlan0 –m state --state RELATED,ESTABLISHED –j ACCEPT
iptables –A FORWARD -i wlan0 –o eth0 –j ACCEPT
I'm still working on why I can "Connect" but no internet. I have internet via ip but not URL. nslookup not working. Oh, nevermind - it's there. <sigh>

liderbug
Posts: 143
Joined: Sat Oct 08, 2011 4:47 pm

Re: RP 3B, Stretch, Access point

Wed Jun 06, 2018 12:47 pm

Here's what I've found: searching for "connected, no internet" all talk about /etc/network/interfaces. Not used, only 1 line there. So my Pi is running and I can do anything, go anywhere I want. I can connect my phone or laptop to the AP (it notes that "connected, no internet"). But I do have internet - what I don't have is gethostbyname. If I ping URL it times out. If I ping IP it works.

SOLVED
/etc/dchpcd.conf
each interface need it's own router and nameserver

Code: Select all

interface eth0
static ip_address=192.168.0.153/24
static routers=192.168.0.1
static domain_name_servers=8.8.8.8 127.0.0.1 192.168.0.1

interface wlan0
static ip_address=192.168.2.1/24
static routers=192.168.0.1
static domain_name_servers=8.8.8.8 127.0.0.1 192.168.0.1

Hotblack43
Posts: 2
Joined: Sun Feb 01, 2015 10:14 am

Re: RP 3B, Stretch, Access point

Sat Jul 14, 2018 7:03 pm

Hi,
thanks for posting your notes about how to generate an access point on the newer versions of Raspian Stretch. I have tried to follow your notes, and ran into one problems. May I ask you a question or two?

I note that you very clearly post, right at the start, that the notes re for

Raspberry Pi 3 Model B Rev 1.2
uname -r: Stretch ver: 4.14.34-v7+

Does this imply that the instructions do not work for the latest Stretch? Because I have tried with that, and get nowhere. With keyboard, mouse and monitor connected to the RPi3B+ that I have I can get in, and I can edit the /etc/dhcpcd.conf file - I copy and paste your details into the file.

Then I reboot.

After restarting I find that I have no internet access - I cannot ping anywhere, nor do the

apt-get -y install dnsmasq hostapd

and so on

Any advice? Do you think it is all-important that I did not use the version of Raspian you used?

Best wishes,

Peter

SurferTim
Posts: 1691
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: RP 3B, Stretch, Access point

Sun Jul 15, 2018 1:24 am


liderbug
Posts: 143
Joined: Sat Oct 08, 2011 4:47 pm

Re: RP 3B, Stretch, Access point

Sun Jul 15, 2018 2:21 am

Up to now /etc/network/interfaces was the file that pretty much controlled everything - then someone(s) decided no we're not doing that way any more - why? because!

I've done my best to document my every step - but I may have typed a mis-step. One thing I did find out is it has to be a clean build - I tried to get it to work trying several things - apt-get install X & Y & Z - then remove xyz - not good - do a clean install then the network setup.

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 14 guests