This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fixed IP address when connected to wifi network.
#1
I have a Pi Zero 2w with usb wifi adaptor connected to an android phone mobile hotspot, usually the mobile  will assign the Zero with the same IP address like 192.168.45.101 but sometimes it changes which means the webpage bookmarks are wrong for any devices wanting to look at sigk but connected to the phone network. 

Google comes up with a few options but what is the best way to set a fixed ip address for external wifi networks  in openplotter? 

Also, is it poss the set the openplotter network to somethong other than 10.10.10.1?

TIA as ever Smile
Reply
#2
Deleted
Reply
#3
(2022-04-11, 12:25 PM)baltika_no_9 Wrote: Please excuse me if I'm answering the wrong question here!

Possibly  Big Grin

That's all come up from google, though not sure just how openplotter sets up the wifi, that might not be the best way to go.
Reply
#4
(2022-04-11, 12:36 PM)PaddyB Wrote:
(2022-04-11, 12:25 PM)baltika_no_9 Wrote: Please excuse me if I'm answering the wrong question here!

Possibly  Big Grin

That's all come up from google, though not sure just how openplotter sets up the wifi, that might not be the best way to go.

Fair enough but all I can tell you is that it's the way I set up my Openplotter systems and it works fine. However I shall delete the post if it is not helpful. Just trying to help.

Please let us know when you discover the best way.

Best of luck
Reply
#5
(2022-04-11, 12:45 PM)baltika_no_9 Wrote: Just trying to help.
Which is always appreciated ?

Anyone else know more about how openplotter sets up & stores wifi? 
I've never quite got to know the big picture with wifi on Linux, seems a bit spread out..
Reply
#6
Paddy let me add a bit more information to that I provided earlier which was incomplete.

I am absolutely certain that this is how Openplotter sets up it's Wifi. There is nothing Wifi specific in openplotter.conf, it uses the base Linux facilities.

Setting a fixed IP address (OP uses this to set up the fixed ip address for the AP as you can see)

Edit /etc/dhcpcd.conf, adding the lines at the bottom of the file (here I am fixing wlan0):

interface wlan0
static ip_address=192.168.1.199/24 (obviously you have to set this to an address that is within the range of addresses that the AP you are connecting to can give out)

After rebooting then as expected you will see whatever interface you amended (here wlan0) has the address specified.

You can also specify default gateway of DNS servers in the same entry if you wish, such as:

static routers=192.168.1.254
static domain name servers=192.168.1.254 8.8.8.8



Changing the default 10.10.10.1 Openplotter AP address

If you look in /etc/dhcpcd.conf on your Openplotter device you should see that OpenPlotter AP address of 10.10.10.1 is defined in exactly the way I mention above (static ip_address=) so in answer to your second question then no there is no reason why you can't change it to something else.

To do that you need to make the following changes (Here I use 10.10.99.x as an example instead of the default 10.10.10.1):

In /etc/dhcpcd.conf


interface wlan9
denyinterfaces wlan9
metric 510
static ip_address=10.10.99.1/24 < Change 10.10.10.1 to your preferred address eg 10.10.99.1
static routers=10.10.99.1 <And again as above
static domain_name_servers=8.8.8.8
nohook wpa_supplicant

You also need to change the range of addresses the AP gives out to make sure they’re in the same range as the AP itself now you’ve changed it. So instead of giving out addresses in the range 10.10.10.50 to 10.10.10.200 it will now give addresses in the 10.10.99.50-200 range in this example.

in /etc/dnsmasq.conf (again this is a file provided by OP)

interface=wlan9
no-dhcp-interface=wlan0,wlan1,wlan2,usb0,eth0
dhcp-range=10.10.99.50,10.10.99.200,12h < Change this line

All we have done is to change two files that are provided by OP as default, there is no further OP specific magic. Why would there be when Linux has all the capabilities required although as ever I am willing to be corrected?
Reply
#7
(2022-04-12, 09:39 AM)baltika_no_9 Wrote: Paddy let me add a bit more information to that I provided earlier which was incomplete.

Thanks v much.

Did all that before but didn't work, must have had a stray typo or something, seems to work now though Ta.

And couldn't access a "192.168...:3000" or ssh through the phone which seems to work now  Cool

Successful morning  Smile

Sailoog - any comments? OK to edit /etc/dhcpcd.conf and leave it at that?

(tried 10.10.10.2 which seemed to work OK) 
Code:
pi@openplotter:~ $ cat /etc/dhcpcd.conf
# 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
nohook lookup-hostname

# 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
noipv6

interface wlan1
static ip_address=192.168.252.160
static routers=192.168.1.254
static domain name servers=192.168.1.254 8.8.8.8


interface wlan9
denyinterfaces wlan9
metric 510
static ip_address=10.10.10.1/24
static routers=10.10.10.1
static domain_name_servers=8.8.8.8
nohook wpa_supplicant


Code:
pi@openplotter:~ $ ifconfig
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 42905  bytes 8723667 (8.3 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 42905  bytes 8723667 (8.3 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.252.160  netmask 255.255.255.0  broadcast 192.168.252.255
       inet6 fe80::20f:60ff:fe05:8d9f  prefixlen 64  scopeid 0x20<link>
       ether 00:0f:60:05:8d:9f  txqueuelen 1000  (Ethernet)
       RX packets 38971  bytes 2831261 (2.7 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 46878  bytes 21770716 (20.7 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 10.10.10.1  netmask 255.255.255.0  broadcast 10.10.10.255
       inet6 fe80::e65f:1ff:fe54:2590  prefixlen 64  scopeid 0x20<link>
       ether e4:5f:01:54:25:90  txqueuelen 1000  (Ethernet)
       RX packets 49026  bytes 3400624 (3.2 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 46281  bytes 14049319 (13.3 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Reply
#8
(2022-04-12, 11:35 AM)PaddyB Wrote:
(2022-04-12, 09:39 AM)baltika_no_9 Wrote: Paddy let me add a bit more information to that I provided earlier which was incomplete.

Thanks v much.

Did all that before but didn't work, must have had a stray typo or something, seems to work now though Ta.

And couldn't access a "192.168...:3000" or ssh through the phone which seems to work now  Cool

Successful morning  Smile

Sailoog - any comments? OK to edit /etc/dhcpcd.conf and leave it at that?

(tried 10.10.10.2 which seemed to work OK) 
Code:
pi@openplotter:~ $ cat /etc/dhcpcd.conf
# 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
nohook lookup-hostname

# 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
noipv6

interface wlan1
static ip_address=192.168.252.160
static routers=192.168.1.254
static domain name servers=192.168.1.254 8.8.8.8


interface wlan9
denyinterfaces wlan9
metric 510
static ip_address=10.10.10.1/24
static routers=10.10.10.1
static domain_name_servers=8.8.8.8
nohook wpa_supplicant


Code:
pi@openplotter:~ $ ifconfig
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 42905  bytes 8723667 (8.3 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 42905  bytes 8723667 (8.3 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.252.160  netmask 255.255.255.0  broadcast 192.168.252.255
       inet6 fe80::20f:60ff:fe05:8d9f  prefixlen 64  scopeid 0x20<link>
       ether 00:0f:60:05:8d:9f  txqueuelen 1000  (Ethernet)
       RX packets 38971  bytes 2831261 (2.7 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 46878  bytes 21770716 (20.7 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 10.10.10.1  netmask 255.255.255.0  broadcast 10.10.10.255
       inet6 fe80::e65f:1ff:fe54:2590  prefixlen 64  scopeid 0x20<link>
       ether e4:5f:01:54:25:90  txqueuelen 1000  (Ethernet)
       RX packets 49026  bytes 3400624 (3.2 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 46281  bytes 14049319 (13.3 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

static ip_address=192.168.252.160
static routers=192.168.1.254
static domain name servers=192.168.1.254 8.8.8.8

This is inconsistent, it is usually better to specify the desired IP address in CIDR form, e.g 192.168.252.160/24

Also you have specified router and dns addresses that are on another subnet. Have you set up routing from 192.168.252.160 to 192.168.1.254? The 192.168.1.254 addresses in my post are my local router, you should add your own specific ones, normally the IP address of the device handling dhcp, that would be a good place to start.
Reply
#9
might have found the problem if not a solution without un rooting the phone Sad -


Quote:Unfortunately, starting with Android 9, the gateway is always set randomly. You cannot change it without editing the source code and building the firmware
https://forum.xda-developers.com/t/how-d...0.4037021/

Oh well, not the end of the world ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)