Linkan
Posts: 30
Joined: Tue Feb 10, 2015 3:56 pm

RPi 3 can't configure as a wifi AP

Fri Apr 01, 2016 11:57 pm

I have looked around the web for a simple guide on how to configure my raspberry pi 3 as an access point and the most up-to-date tutorial that I found was this one.

I just can't get it to work properly. I can connect to my raspberry pi 3 and I do get an ip address, but I do not get any internet access. Here is my setup:
/etc/dhcpcd.conf:

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.
#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.
# Some interface drivers reset when changing the MTU so disabled by default.
#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

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

interface wlan0  
    static ip_address=10.0.0.6/24
/etc/network/interfaces:

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

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
/etc/hostapd/hostapd.conf:

Code: Select all

# This is the name of the WiFi interface we configured above
interface=wlan0

# Use the nl80211 driver with the brcmfmac driver
driver=nl80211

# This is the name of the network
ssid=Pi3-AP

# Use the 2.4GHz band
hw_mode=g

# Use channel 1
channel=1

# Accept all MAC addresses
macaddr_acl=0

# Use WPA authentication
auth_algs=1

# Require clients to know the network name
ignore_broadcast_ssid=0

# Use WPA2
wpa=2

# Use a pre-shared key
wpa_key_mgmt=WPA-PSK

# The network passphrase
wpa_passphrase=raspberry

# Use AES, instead of TKIP
rsn_pairwise=CCMP
/etc/dnsmasq.conf:

Code: Select all

interface=wlan0      # Use interface wlan0  
bind-interfaces      # Bind to the interface to make sure we aren't sending things elsewhere  
server=8.8.8.8       # Forward DNS requests to Google DNS  
domain-needed        # Don't forward short names  
bogus-priv           # Never forward addresses in the non-routed address spaces.  
dhcp-range=10.0.0.50,10.0.0.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time
I uncommented #net.ipv4.ip_forward=1 from /etc/sysctl.conf and added iptables-restore < /etc/iptables.ipv4.nat to /lib/dhcpcd/dhcpcd-hooks/70-ipv4-nat.

/etc/iptables.ipv4.nat:

Code: Select all

# Generated by iptables-save v1.4.21 on Sat Apr  2 00:53:33 2016
*filter
:INPUT ACCEPT [25:4008]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [6:632]
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
COMMIT
# Completed on Sat Apr  2 00:53:33 2016
# Generated by iptables-save v1.4.21 on Sat Apr  2 00:53:33 2016
*nat
:PREROUTING ACCEPT [10:2086]
:INPUT ACCEPT [10:2086]
:OUTPUT ACCEPT [3:312]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Sat Apr  2 00:53:33 2016
My router is on 10.0.0.1 and the eth0 interface has 10.0.0.3 as the ip address.
Output of `ifconfig -a` on my computer connected to Pi3-AP:

Code: Select all

enp0s25: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 54:ee:75:54:df:e1  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf2500000-f2520000  

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 1  (Local Loopback)
        RX packets 10847  bytes 765133 (747.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10847  bytes 765133 (747.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.103  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::124a:7dff:fe28:2620  prefixlen 64  scopeid 0x20<link>
        ether 10:4a:7d:28:26:20  txqueuelen 1000  (Ethernet)
        RX packets 2967749  bytes 3712998994 (3.4 GiB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 938223  bytes 219054849 (208.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Clearly I get an ip address `10.0.0.103` but I cannot even ping the raspberry pi itself (nor google.com and such):

Code: Select all

[user@computer ~]$ ping 10.0.0.6
PING 10.0.0.6 (10.0.0.6) 56(84) bytes of data.
^C
--- 10.0.0.6 ping statistics ---
9 packets transmitted, 0 received, 100% packet loss, time 8007ms
What am I doing wrong? :?:

nilatacb
Posts: 1
Joined: Sat Apr 02, 2016 5:11 am

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 5:13 am

Is your eth0 up?

It seems to me it is not

Edit:you have an ip for loopback and wlan, but not eth.

That would cause your symptoms. Dhcp working, internet not.
Last edited by nilatacb on Sat Apr 02, 2016 7:43 pm, edited 1 time in total.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 7:39 am

Linkan wrote:I have looked around the web for a simple guide on how to configure my raspberry pi 3 as an access point and the most up-to-date tutorial that I found was this one.

I just can't get it to work properly. I can connect to my raspberry pi 3 and I do get an ip address, but I do not get any internet access.
Go back to the tutorial and make sure that you have followed the instructions; attempt to contact the writer... leave a comment... ask a question... see if others on the net have followed his tutorial and what (if any) issues they encountered.

It looks like the dhcpd stuff is working since you got a good internal address... I suspect that what is missing is that you need to punch a hole in your firewall (may take firewall rules [iptables rules] and|or masquerading ; packet forwarding (masquerading) is off by default (I think) and your firewall will block by default too.

Again, go back to the tutorial and start there (and finish there too) rather that pulling people into the middle of a complicated discussion without being able to assist with the diagnostics. More than likely, you just skipped an important step... get a cup of Java and try again... maybe even start over !

Cheers
marcus
:ugeek:

Linkan
Posts: 30
Joined: Tue Feb 10, 2015 3:56 pm

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 12:30 pm

MarkHaysHarris777 wrote:
Linkan wrote:I have looked around the web for a simple guide on how to configure my raspberry pi 3 as an access point and the most up-to-date tutorial that I found was this one.

I just can't get it to work properly. I can connect to my raspberry pi 3 and I do get an ip address, but I do not get any internet access.
Go back to the tutorial and make sure that you have followed the instructions; attempt to contact the writer... leave a comment... ask a question... see if others on the net have followed his tutorial and what (if any) issues they encountered.

It looks like the dhcpd stuff is working since you got a good internal address... I suspect that what is missing is that you need to punch a hole in your firewall (may take firewall rules [iptables rules] and|or masquerading ; packet forwarding (masquerading) is off by default (I think) and your firewall will block by default too.

Again, go back to the tutorial and start there (and finish there too) rather that pulling people into the middle of a complicated discussion without being able to assist with the diagnostics. More than likely, you just skipped an important step... get a cup of Java and try again... maybe even start over !

Cheers
Thanks for the tip, but the thing is, I have started over 3 times and still I have got the same result every time. I reflash my SD-card with a fresh install of raspbian and then I follow the guide thoroughly. I'll try to contact the writter I guess, because if I can't get it working with a very detailed guide 3 times over I'm doing something very wrong.

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 12:43 pm

Are you using the same LAN segment (10.0.0.x/24) for both the wifi and ethernet side?
That will not work with the way the rest is set up (DHCP, NAT)

Try using a different segment (e.g. 192.168.100.x/24) for the wifi side.

Linkan
Posts: 30
Joined: Tue Feb 10, 2015 3:56 pm

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 12:50 pm

DirkS wrote:Are you using the same LAN segment (10.0.0.x/24) for both the wifi and ethernet side?
That will not work with the way the rest is set up (DHCP, NAT)

Try using a different segment (e.g. 192.168.100.x/24) for the wifi side.
So you mean I could edit dhcpcd.conf with the following content:

Code: Select all

interface wlan0  
    static ip_address=10.0.100.1/24
Would that yield a different result?

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 12:55 pm

Linkan wrote:
DirkS wrote:Are you using the same LAN segment (10.0.0.x/24) for both the wifi and ethernet side?
That will not work with the way the rest is set up (DHCP, NAT)

Try using a different segment (e.g. 192.168.100.x/24) for the wifi side.
So you mean I could edit dhcpcd.conf with the following content:

Code: Select all

interface wlan0  
    static ip_address=10.0.100.1/24
Would that yield a different result?
Yes, I think so. You also have to change the range of the DHCP server in /etc/dnsmasq.conf

Linkan
Posts: 30
Joined: Tue Feb 10, 2015 3:56 pm

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 3:32 pm

DirkS wrote:
Linkan wrote:
DirkS wrote:Are you using the same LAN segment (10.0.0.x/24) for both the wifi and ethernet side?
That will not work with the way the rest is set up (DHCP, NAT)

Try using a different segment (e.g. 192.168.100.x/24) for the wifi side.
So you mean I could edit dhcpcd.conf with the following content:

Code: Select all

interface wlan0  
    static ip_address=10.0.100.1/24
Would that yield a different result?
Yes, I think so. You also have to change the range of the DHCP server in /etc/dnsmasq.conf
Thank you, it works now. Would it be possible to use the routers DHCP and DNS and just bridge the connection?

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 4:38 pm

Yes, that should be possible. I actually did a quick test last week, but I think I made a mistake somewhere and it did not work.
I have not looked into it again after that.

I used a tutorial in German, so I'm not sure if that's of any use to you
https://www.elektronik-kompendium.de/si ... 002161.htm

terrick
Posts: 1
Joined: Sat Apr 02, 2016 5:17 pm

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 5:23 pm

Hi, I had the same problem and the article writer was a great help.My PC was not picking up a DNS server ,But conected to the pi3 OK.
He sugested:
server=8.8.8.8 is correct
"you can try the line 'dhcp-option=option:dns-server,8.8.8.8' in dnsmasq.conf".
That worked for me.

Linkan
Posts: 30
Joined: Tue Feb 10, 2015 3:56 pm

Re: RPi 3 can't configure as a wifi AP

Sat Apr 02, 2016 8:08 pm

terrick wrote:Hi, I had the same problem and the article writer was a great help.My PC was not picking up a DNS server ,But conected to the pi3 OK.
He sugested:
server=8.8.8.8 is correct
"you can try the line 'dhcp-option=option:dns-server,8.8.8.8' in dnsmasq.conf".
That worked for me.
Hi terrick,

thanks for the suggestion. It worked for me too! I'd prefer to be able to setup my raspberry pi 3 as a WiFi hotspot like a WLAN-bridge (in the same way you can share your internet access on your phone and create a hotspot) but I can't find a good guide except that one in german. For now I will use my raspberry pi with its own DHCP and DNS server configured with dnsmasq.

Return to “General discussion”