element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Code Exchange
  • Technologies
  • More
Code Exchange
Forum PI3 wlan0 access point without internet and predefined 192.168.XXX.XXX IP and eth0 with DHCP
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Code Exchange to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 9 replies
  • Subscribers 46 subscribers
  • Views 2170 views
  • Users 0 members are here
  • tcpip
  • rpi
  • access_point
Related

PI3 wlan0 access point without internet and predefined 192.168.XXX.XXX IP and eth0 with DHCP

ataf
ataf over 7 years ago

Good Day,

 

 

I try to create wlan0 AP (access point) without internet which allows to open tcpip socket connection to my process running on the rpi3 (just for some packages exchange with client application connecting to the AP with predefined 192.168.XXX.XXX IP adress and port), at the same time I need eth0 internet connection with DHCP.

 

 

Apparently, I get pretty close result configuring /etc/hostapd/hostapd.conf

[code]

interface=wlan0

driver=nl80211

ssid=MY_AP_SSID

hw_mode=g

channel=6

macaddr_acl=0

auth_algs=1

ignore_broadcast_ssid=MY_AP_SSID

wpa=0

wpa_passphrase=passphrase

wpa_key_mgmt=WPA-PSK

wpa_pairwise=TKIP

rsn_pairwise=CCMP

[/code]

and after that running

[code]

/etc/init.d/hostapd stop

ifdown wlan0

ifup wlan0

/etc/init.d/hostapd restart

[/code]

and I can connect socket and communicate with the rpi3 from my PC but I get "dynamic" IP 169.254.XX.XX. The IP is the same every time but it doesn't look like the constant one.

 

 

The question is: [b]how to configure static 192.168.XXX.XXX IP for the AP?[/b]

 

 

As soon as I try to do it with /etc/dhcpcd.conf addition like

[code]

nodhcp

static interface wlan0

static ip_address=192.168.111.111

[/code]

I can see the correct wlan0 IP in the 'ifconfig' and 'ip -4 addr show' output and I can  'ping 192.168.111.111' successfully on the rpi3 but I get 'destination unreachable' if I ping the IP from my PC connected to the AP.

 

 

I use  RPI3 (model B) with 'raspbian jessie lite', 'uname -a' output is

[code]

Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv71 GNU/Linux

[/code]

 

 

Any comment, thoughts, ideas are welcome image

  • Sign in to reply
  • Cancel
  • gecoz
    0 gecoz over 7 years ago

    Hi Alex,

    I don't know if you have already read this tutorial, but I think you might find it useful in solving your problem.

    Fabio.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ataf
    0 ataf over 7 years ago in reply to gecoz

    Hi Fabio,

     

    Thanks for that.
    I've seen the tutorial and the /etc/dhcpcd.conf configuration seems to work for me but I don't succeed to ping the static ip from my PC. I can ping it inside the raspberry but it's not 'visible' from PC connecting to the AP.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gecoz
    0 gecoz over 7 years ago

    The fact that, even if connected to the AP, the PC cannot reach the AP IP address seems to point to a routing problem with the PC. Is the PC a multihomed one (i.e. has it got more network cards and IP addressed/networks assigned)?

    Fabio

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ataf
    0 ataf over 7 years ago in reply to gecoz

    No, it has one IP on eth0 and another one for wlan0. If the wlan0 is generated by the DHCP (169.254.XXX.XXX) everything is alright. But if I change the address to the 192.168.XXX.XXX the external ping doesn't work.

     

    I don't mind to use 169.254.XXX.XXX address, but I cannot change it and I need I don't know how it's generated. I mean how constant it is for the rpi3 and what its generation depends on.



    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gecoz
    0 gecoz over 7 years ago in reply to ataf

    Ok, I might have misunderstood your configuration. Just to make sure I got your set up right, let me recap.

     

    You got the RPi3 running Raspian with 2 netword cards: wlan0 (the wireless AP, not connected to the internet) and eth0 (wired, connected to the internet). Each network card is configured on a different network, and the 2 networks are not routed/bridged in any way.

     

    You got your PC, with  a wireless adapter which you use to connect to the AP. I assume this PC is running a Windows OS.

     

    When you  connect to the AP, using DHCP set to dynamic address, your PC get the 169.254.xx.xx address assigned.

     

    If this is the case, the fact that you are getting the 169.254.xx.xx address is a symptom there is no DHCP server configured anywhere, and Windows falls back to configuring a local link address.

     

    Now, if you don't specify a static IP for wlan0 in the DHCP client configuration file on the RPi3 (dhcpcd.conf), the said connection works, but as soon as you change the wlan0 ip address on RPi3 to the static IP 192.168.111.111, you get the destination unreachable error from the PC. Have you tried assigning a static IP address on the PC for the connection with the AP, using the same subnet as wlan0 (i.e. something like 192.168.111.112)? I'm saying this because I still suspect a routing problem.

     

    Failing that, you can try to solve this problem by installing a DHCP server (dnsmasq) on the RPi3, following the instructions given in the tutorial mentioned previously. Configuring dnsmasq for a range of dynamic IP addresses, and setting the PC to connect using dynamic IP should work.

     

    Fabio.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ataf
    0 ataf over 7 years ago in reply to gecoz

    It's description of my configuration exactly image

    I've tried to set Win10 (my PC) network properties IP4 to the address from the subnet and it didn't help...

     

    And I've tried to configure the DHCP (dnsmasq) addresses range on rpi3, it's didn't help as well. I mean the wlan0 IP changes to correct one but external 'ping' returns 'unreachable destination'. I'll try to redo it tomorrow and capture some commands output.

    The 169.254.XXX.XXX ip is still a mistery for me: it seems to constant on the rpi3 but on another IP I get different 169.254.XXX.XXX ip and it's constant for the rpi3.

     

    it should be a way to see logs or something for the pings with unreachable destination. I understand that the ping packets reach rpi3 and it doesn't succeed to rout the packet and it has to log reason for the failure, not just 'error 1065'...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gecoz
    0 gecoz over 7 years ago in reply to ataf

    Hm... the more I think about it, the more I believe it is a routing issue on the RPi3.

    What is exactly the message you get on the PC when you try pinging the AP?

    And, could you try issue the following command on the RPi3:

     

    route -n

     

    and paste here the result you get?

    Fabio.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • ataf
    0 ataf over 7 years ago in reply to gecoz

    Your intuition is correct and very helpful, it looks like routing issue.  The 'route -n' output was

     

    Kernel IP routing table

    Destination    Gateway        Genmask        Flags Metric Ref    Use Iface

    0.0.0.0        192.168.0.1    0.0.0.0        UG    202    0        0 eth0

    192.168.0.0    0.0.0.0        255.255.255.0  U    202    0        0 eth0

    192.168.0.0    0.0.0.0        255.255.0.0    U    303    0        0 wlan0

     

    I've changed static IP in the /etc/dhcpcd.conf to

     

    interface wlan0

    static ip_address=111.111.111.111/16

     

    installed dnsmasq with /etc/dnsmasq.conf

     

    interface=wlan0

    dhcp-range=111.111.111.2,111.111.111.110,255.255.255.0,16h

     

    and the 111.111.111.111 is pingable from my PC (I've got Ip 111.111.111.84, it looks like the DHCP works like expected) and the 'route -n' output now is

     

    Kernel IP routing table

    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

    0.0.0.0         192.168.0.1     0.0.0.0         UG    202    0        0 eth0

    111.111.0.0     0.0.0.0         255.255.0.0     U     303    0        0 wlan0

    192.168.0.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0

     

    Apparently  it solves my original problem, I'm quite happy to use IP which is not 192.168.X.X or 169.254.X.X but  I still wonder:

     

    • is it a way to configure wlan0 for IP addresses in the 192.168.X.X range and to have the eth0 connected at the same time?
    • is it possible to configure the 'Genmasks' and avoid overlapping between eth0 and wlan0 IP addresses?
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gecoz
    0 gecoz over 7 years ago in reply to ataf

    Glad you solved the issue.

     

    As for your questions about using addresses in the range 192.168.x.x for both eth0 and wlan0, it is possible, because the subnetwork defined by the modem/router eth0 is connected to is a class C network (192.168.0.0/24), and all is needed is to use 2 different class C subnetworks on the RPi3, one for wlan0 and one for eth0.

     

    I'll assume the eth0 is connected to the internet via a modem/router using the subnetwork 192.168.0.0/24 with the gateway on 192.168.0.1 (as far I can see from the output of the route command).

     

    RPi3 will act as gateway on the subnetwork for wlan0, making sure such subnetwork does not overlap with the one eth0 is on.

     

    For instance, you can use the subnetwork 192.168.1.0/24 for wlan0, and set the the IP address of the RPi3 wlan0 interface as 192.168.1.1. This will be the gateway for the AP, so, for example, you will need to change the static IP address in /etc/dhcpcd.conf to 192.168.1.1/24, and change dhcp-range in /etc/dnsmasq.conf to 192.168.1.2,192.168.1.110,255.255.255.0,24h

     

    The 2 subnetworks don't need to be able to route traffic to each other, so you won't need to define any extra routing rule.

     

    As for genmask, it represents the subnet mask, and it is automatically assigned when you define the type of subnetwork (ie. a class C network like 192.168.1.0/24 has a subnet mask of 255.255.255.0, a class B network like 128.1.0.0/16 has a subnet mask of 255.255.0.0).

     

    Fabio.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube