-1

I set the IP of the PI to static (following these guidelines How do I set up networking/WiFi/static IP address on Raspbian/Raspberry Pi OS?) to be able to access it from multiple phones used with tethering.

Specifically I used the dhcpcd method

Editing the /etc/dhcpcd.conf as follows:-

Here is an example which configures a static address, routes and dns.

interface wlan0
static ip_address=192.168.43.12/24
static routers=192.168.43.6
static domain_name_servers=192.168.43.6

The addresses were found using

ip -4 addr show | grep global

ip route | grep default | awk '{print $3}'

cat /etc/resolv.conf

This worked wonderfully as I can connect by VNC without problems but since then I cannot access the internet.

I found several post about this problem but I cannot apply any fix to my specific case.

ping 8.8.8.8 returns:

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.43.12 icmp_seq=1 Destination Host Unreachable
From 192.168.43.12 icmp_seq=2 Destination Host Unreachable

and it would continue endlessly the sequence

ping google.com returns:

ping: google.com: Temporary failure in name resolution

For ip route:

default via 192.168.43.6 dev wlan0 src 192.168.43.12 metric 303 
192.168.43.0/24 dev wlan0 proto dhcp scope link src 192.168.43.12 metric 303 

For sudo ping -c3 $(ip route | awk '/default/ {print $3}')

PING 192.168.43.6 (192.168.43.6) 56(84) bytes of data.
From 192.168.43.12 icmp_seq=1 Destination Host Unreachable
From 192.168.43.12 icmp_seq=2 Destination Host Unreachable
From 192.168.43.12 icmp_seq=3 Destination Host Unreachable

--- 192.168.43.6 ping statistics --- 3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 82ms pipe 3

For cat /etc/resolv.conf

# Generated by resolvconf nameserver 192.168.43.6 nameserver 8.8.8.8

Is anybody able to help me? And to explain me why it was not working/what I did wrong?

Thank you very much in any case.

user68186
  • 524
  • 1
  • 7
  • 16
have fun
  • 101
  • 5

3 Answers3

2

Mobile phone is not a typical router

The issue is "...to be able to access it from multiple phones used with tethering."

Mobile phone is not a typical router. A typical router usually sets aside two ranges of IP addresses. One range is used as a pool for dynamic IP address assignment. The other range is left alone by the router, so that count l client devices can set static IP addresses from that range.

When you set up a static IP address for a client device from the second range in a typical router, it is your responsibility to make sure you don't assign the same IP address to two computers and create a conflict.

If you set up a static IP address from the first range, reserved for dynamic addresses, that address may be assigned to some other device by the router, creating a conflict.

The correct way to get the same IP address from the range reserved for dynamic IP address assignment is to request the IP from the DHCP server. For example, adding the following to /etc/dhcpcd.conf will request an address on wlan0:

interface wlan0
request 192.168.43.12 

Source: How do I set up networking/WiFi/static IP address on Raspbian/Raspberry Pi OS?

This does not guarantee the requested IP address, as it may be already assigned to another device.

Since a mobile phone is not a router, it does not reserve any IP addresses for static assignment. It may not even honor the request for the same IP address every time. Moreover, different mobile phones may have different rules for assigning dynamic IP address assignment.

For example, my phone's mobile hotspot assigns dynamic IP addresses in the range from 192.168.150.xxx to 192.168.150.yyy. So, requesting an IP in the range of 192.168.43.xxx may not work on this phone.

An Experiment with my Phone

I turned my phone into a WiFi hotspot and connected my Pi to it. The phone assigned the IP address 192.168.150.96 to my Pi.

I added the following lines to /etc/dhcpcd.conf:

interface wlan0
request 192.168.150.95

and reset dhcpcd with the following commands:

sudo ip addr flush dev wlan0 sudo systemctl daemon-reload sudo systemctl restart dhcpcd

The phone still assigned the IP address 192.168.150.96 to the Pi.

I also tried using the inform option in the /etc/dhcpcd.conf:

interface wlan0
inform 192.168.150.95

and restarted dhcpcd again.

The phone still assigned the IP address 192.168.150.96 to the Pi.

The Bottom Line

The request for a specific IP address did not work on my phone.

The bottom line is even if requesting a specific IP address works on one phone same request may not work on another make and model of phone.

Hope this helps

user68186
  • 524
  • 1
  • 7
  • 16
0

Frankly if you want "to be able to access it from multiple phones used with tethering" you should not attempt to assign an address. Acceptable addresses will differ between devices.

See How to set up networking/WiFi

If you want to use an address in the range managed by router use request;
if you want to use an address outside the range managed by router use inform.

Either way the acceptable addresses will depend on the host. There is no standard.

Frankly there is little point attempting to assign an address. Even if you succeed you are unlikely to be able to use a tethered phone for anything other than internet access.

Milliways
  • 62,573
  • 32
  • 113
  • 225
0

I have never had success with dhcpd.conf I would focus on the /etc/network/interfaces file. Mine looks like this:

 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 allow-hotplug wlan0 iface wlan0 inet static

    address 192.168.1.111
    netmask 255.255.255.0
    gateway 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Chiwda
  • 183
  • 2
  • 14