JacoFourie
Posts: 67
Joined: Thu Mar 10, 2016 6:51 pm

Re: Pi 3 as wiireless client and wireless AP?

Fri Sep 01, 2017 6:15 am

Dude WOW I never knew this. I have been doing that for years and could never understand why I see the same MAC address on both IPs when looking at the router. What I have done now is to change the static IP for eth0 to dhcp and unplug the cable. Then all works 100%. Thanks so much. Now I need to figure out nic bonding of wifi links on all my other Pi's. Mmmmmmm

Msprg
Posts: 1
Joined: Thu Mar 30, 2017 11:11 am

Re: Pi 3 as wiireless client and wireless AP?

Tue Sep 12, 2017 4:57 pm

anthony19114 wrote:
Sat Mar 26, 2016 1:02 am
Configuring 1 AP + Many wireless connections with One wireless network card. :lol:
sudo bash for a root prompt :geek:

apt-get install hostapd dnsmasq

Uncomment and edit these lines in /etc/dnsmasq.conf

interface=lo,uap0

no-dhcp-interface=lo,wlan0

dhcp-range=192.168.2.100,192.168.2.200,12h



Edit: /etc/hostapd/hostapd.conf

Add: Change ssid and wpa_passphrase also. (this one is plaintext).

interface=uap0
ssid=pipi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=0123456789
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP


Edit and add to: /etc/network/interfaces

auto uap0
iface uap0 inet static
address 192.168.2.1
netmask 255.255.255.0



Edit a new file:

pico /usr/local/bin/hostapdstart

add:

iw dev wlan0 interface add uap0 type __ap
service dnsmasq restart
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE
ifup uap0
hostapd /etc/hostapd/hostapd.conf


Change permissions on /usr/local/bin/hostapdstart

chmod 667 /usr/local/bin/hostapdstart

Edit and add line to: /etc/rc.local

hostapdstart >1&

OR just type hostapdstart if you want to see details or if you do not want it to start automatically.

Ignore next step if wlan0 is up and working.
Please configure this prior.. :

Add to /etc/network/interfaces
remove all other wlan0 anything references. then add:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid ssidofAP
wpa-psk a03133ea3333471b0d33dbd1b2b19233294649968537c35904eb3389a7df65ba

Replace the psk with yours generated by typing: wpa_passphrase ssidofAP yourWPApass


Your complete /etc/network/interfaces should look like this but with different wpa-psk and wpa-ssid:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid ssidofAP
wpa-psk a03133ea3333471b0d33dbd1b2b19233294649968537c35904eb3389a7df65ba

auto uap0
iface uap0 inet static
address 192.168.2.1
netmask 255.255.255.0
Hi, and thanks for this, but i have a problem, when my RPI boot up it does not connect to wifi, only broadcasting but on RPI AP is not internet connection, also on system icon is error "Connection to dhcpcd lost" what with this? thanks.

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

Re: Pi 3 as wiireless client and wireless AP?

Wed Sep 13, 2017 1:57 am

@Msprg: I presume you are using Raspbian. Which release? Jessie or Stretch?

I don't think anthony19114 is going to be much help. That post was 18 months ago and he hasn't logged in in over a year.

I'm always willing to give new network stuff a go if I know which OS to use. Some major differences between Jessie and Stretch network-wise.

Edit: Even if this works, you will probably not be happy with the performance. It would work in the same fashion as a wifi repeater/range extender. Your transfer bandwidth will drop way off. I use two wifi devices, one onboard as the AP, and another usb wifi device as the station (client). Works well with much less performance degradation.

raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Fri Sep 15, 2017 7:45 pm

Hi , my nsme is Harry and I am a new forum member but a raspberrypi3 newbie!
My question
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE

Is the ip 192.168.2.0 the router IP?
I am working with jessie.
I do not have any /etc/network/interface file for changing?!
THX for assistance

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

Re: Pi 3 as wiireless client and wireless AP?

Fri Sep 15, 2017 8:58 pm

The 192.168.2.0/24 id the localnet. That iptables rule will masquerade to any address except itself.

You would be much better off getting a usb wifi device to act as the client. They are inexpensive and easy to set up.

robkwan
Posts: 1
Joined: Sat Sep 16, 2017 1:20 am

Re: Pi 3 as wiireless client and wireless AP?

Sat Sep 16, 2017 1:30 am

Hello! I am new to this forum and I just started using Raspberry Pi 3 recently.

I would like to share my experiences on this topic as I just got one board working today.

I bought a new CanaKit Raspberry Pi 3 Kit earlier this week.

When I type "uname -a" to check the latest OS version on this Kit,
I got,

Linux version 4.9.41-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #1023 SMP Tue Aug 8 16:00:15 BST 2017

and I noticed that

ii dhcpcd5 1:6.10.1-1+rpi3 armhf DHCPv4, IPv6RA and DHCPv6 client with IPv4LL support


From http://downloads.raspberrypi.org/raspbian/images/

I can see that
both raspbian-2017-08-17
and raspbian-2017-09-08
would give the same uname strings.

Therefore, I cannot tell which image it exactly is please.

Anyway, with this image and dhcpcd5, I would have problem to configure the Wifi to both client station and access point as I followed before:-

http://imti.co/post/145442415333/raspbe ... station-ap

on another CanaKit which has another OS version:-

uname -a
Linux raspberrypi 4.9.44-v7+ #1029 SMP Tue Aug 22 17:04:54 BST 2017 armv7l GNU/Linux

However,
I cannot find this OS version from the http://downloads.raspberrypi.org/raspbian/images/ at all?!

Not sure where I can find this OS version image?!

As a result, I tried to re-image my SD card with the even older OS version raspbian-2017-07-05
which has a different version of

dhcpcd5:armhf 6.7.1-1+rpi5 armhf DHCPv4, IPv6RA and DHCPv6 client with IPv4LL support

and I can still configure the Wifi module for both client station and access point mode ok.

Hence, I suspect that my problem was related to dhcpcd5 version because I did try to play around the /etc/network/interfaces file
and I did notice that error would pop up whenever I tried to set

iface wlan0 inet dhcp

with the new OS version image.

Hope that this piece of information may be helpful to whoever encounters the same issue as I did.


Thanks & Regards,
Robert

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

Re: Pi 3 as wiireless client and wireless AP?

Sat Sep 16, 2017 10:32 am

To determine OS version

Code: Select all

cat /etc/os-release
cat /etc/rpi-issue

raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 9:35 am

Hi ServerTim,
many thx for reply.

With your last email, I had to learn, that my new raspberrypi3 OS is "stretch" ..shame on me.. :o
So,
I am working with a raspberrypi3 with the internal wlan and the USB wlan edimax stick.
The "receiver" of all my computers,laptops from the family is a fritzbox-router which works together with
the "home" cable-set. So, my fritzbox-router has an ip-number. Is this the local IP-number you mentioned?
How can I verify my local IP?
Sorry for my terrible english!
:oops:
I am a bit confused that I do not have any /etc/network/interfaces file!??
The interface mechanism with the stretch-OS seems to be a bit different?!.

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

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 11:12 am

@raspiquax: Do you plan on using one wifi as the AP and one as the client? I'm using the onboard wifi as the AP, and the usb wifi as the client. Would this setup be ok with you also?

There are differences in the Stretch version. Run ifconfig and see what your ethernet interface name is. It will either be eth0 or enx..and a bunch of hex numbers.

raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 2:03 pm

Hello SurferTim,

many thx again.
...and yes, I would like to take the"better" Edimax stick for AP (Better performance long distance) and
my onboard wlan for the short distance to my "home"-router fritzbox, just 4 metres beside the desk.
This should be my connection to the i-net, which works at the moment very good.
(I am writing this email from my raspberrypi3 connected over putty (ssd) to my laptop)

By the way, I read you are from Florida, hopefully everything goes well after this terrible hurrican!!

raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 2:14 pm

Hmmm.... ...with ifconfig,
I can see my wlan0 static IP, wlan1 no IP and at lo(localhost?!) these standard 127.xxxxx !
So I don't understand this line
*******iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE****
Is the IP 192.168.2.0 the localhost adress, which means I have to choose 127.xxxxx?

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

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 2:30 pm

DON'T USE THAT EXAMPLE!

I'm trying my RPi3 with wlan0 as the client and wlx.... as the AP now. I have not tried it the other way around. I want to insure you will not have problems with the driver.

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

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 4:05 pm

Unfortunately, my usb wifi device is old, and does not support AP mode, so I can't test it here. Your Edimax may support AP mode.

raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 4:31 pm

In the meantime, I read so many articles that I am totally confused...:(
Do you have a complete instruction how to handle all this adjustments in the
different conf files? Thanks in advance.

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

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 5:01 pm

I have the adjustments, but i don't know about your usb wifi device. I'll post the changes you need to make.

First, did you check ifconfig? Does your ethernet interface show as eth0 or enx...? If you are uising Stretch, and it shows eth0, you must change to mac based interface names.

Code: Select all

sudo mv /etc/systemd/network/99-default.link /home/pi/
Then reboot. Check ifconfig again. It should show enx and a bunch of hex numbers (mac address).

raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 5:56 pm

Here we go....!

enxb827eb0cce9b: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:0c:ce:9b 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
one more question...
...which commands I have to do for getting this coloured field <<Select all...>>

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

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 6:03 pm

OK. Get the client wifi set up first. That will be wlan0 (onboard wifi).

Code: Select all

sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
sudo leafpad /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
and add this. Change the ssid and passphrase to your wifi network.

Code: Select all

network={
  ssid="myssid"
  psk="mypassphrase"
}
Then reboot. Insure you get a wifi connection.

raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 6:05 pm

yep, done....

B.Goode
Posts: 4689
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 6:09 pm

...which commands I have to do for getting this coloured field <<Select all...>>
Use the [ Code] markup which is created for you when you use the Code button 5th from the left at the top of the message edit screen.


raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 6:15 pm

I am still working with my raspberrypi3 SSVNC... ;)


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

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 6:19 pm

Good deal. Have you done upgrade, update, and rpi-update? If not, do so.

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo rpi-update
Then install the modules

Code: Select all

sudo apt-get install dnsmasq hostapd
For the next stuff, you will need to get the name of the usb wifi device. Use ifconfig.
The /etc/dhcpcd.conf addition at the end of the file. Replace wlx12345 with your wifi name:

Code: Select all

interface wlx12345
static ip_address=192.168.4.1/24
Then save the original /etc/dnsmasq.conf file.

Code: Select all

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig.
Edit /etc/dnsmasq.conf (should be empty) and add this:
The /etc/dnsmasq.conf file. Replace wlx12345 with your interface name.

Code: Select all

interface=wlx12345
dhcp-range=192.168.4.8,192.168.4.250,255.255.255.0,12h
The /etc/hostapd/hostapd.conf file. Replace wlx12345 with your interface name. Change the ssid and wpa_passphrase for your AP.

Code: Select all

interface=wlx12345
driver=nl80211
ssid=RPiNet
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mypassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit /etc/default/hostapd, uncomment and change this:

Code: Select all

DAEMON_CONF="/etc/hostapd/hostapd.conf"
Edit /etc/sysctl.conf and uncomment

Code: Select all

net.ipv4.ip_forward=1
Reboot. You should see your ssid appear on a client device. If this works, only thing left is the iptables masquerades so you can access the internet.

raspiquax
Posts: 20
Joined: Fri Sep 15, 2017 7:17 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 6:36 pm

two remarks regarding the /etc/dhcpcd.conf file:

Code: Select all

static ip_address=192.168.4.1/24
I changed this IP to my wlan0 Ip.... ok?
I can see my SSID and passphrase twice in the dhcpcd.conf file?
Shall I delete one of them?

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

Re: Pi 3 as wiireless client and wireless AP?

Sun Sep 17, 2017 6:42 pm

raspiquax wrote:
Sun Sep 17, 2017 6:36 pm
two remarks regarding the /etc/dhcpcd.conf file:

Code: Select all

static ip_address=192.168.4.1/24
I changed this IP to my wlan0 Ip.... ok?
I can see my SSID and passphrase twice in the dhcpcd.conf file?
Shall I delete one of them?
NO! Leave it as 192.168.4.1/24

You shouldn't see the ssid and passphrase in /etc/dhcpcd.conf. If you mean in /etc/wpa_supplicant/wpa_supplicant-wlan0.conf, then yes, remove one.

Also check /etc/wpa_supplicant/wpa_supplicant.conf and insure no ssid or phassphrase there. Only the top 3 lines should be there.

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 5 guests