0

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.

5
  • to be clear, 192.168.43.6 is your routers address and 192.168.43.12 is the static IP you've assigned? which method in that link did you use to configure static IP?
    – Bravo
    Nov 23, 2021 at 22:31
  • @Bravo 192.168.43.6 is the routers address (I think how can I check?) and 192.168.43.12 is the static IP I chose. I used the dhcpcd method. Thank you very much for your interest.
    – have fun
    Nov 24, 2021 at 6:57
  • you responded to one part of my comment, but the most important part you chose to ignore ... which method in that link did you use to configure static IP please show exactly what you did (in the question, not as a comment)
    – Bravo
    Nov 24, 2021 at 8:06
  • @Bravo thanks but I did not ignore part of you comment, I replied that I used the dhcpcd method. I now copy pasted it in my question from the link that I had already provided.
    – have fun
    Nov 24, 2021 at 12:10
  • that's what I meant to say, to SHOW it :p sorry for the confusion
    – Bravo
    Nov 24, 2021 at 12:46

2 Answers 2

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

8
  • Under the heading static value in man dhcpcd.conf, it says: For IPv4, you should use the inform ip address option instead of setting a static address. Note that inform is not the same as the request option. Is there a reason your answer is at odds with the man dhcpcd.conf documentation? FWIW, the author of the reference you've cited has also ignored the man page - without explanation.
    – Seamus
    Nov 25, 2021 at 21:14
  • @Seamus I read the man page again. The inform and static options are similar. I have not used inform at all. I will have to run some tests to see if inform works in the address range dedicated in the router for static IP addresses. In this answer we are talking about a cellphone as a DHCP server! None of the three options may work as OP wants.
    – user68186
    Nov 25, 2021 at 22:43
  • Yeah - some of the questions we get here cause one to wonder... I think it's always a good idea to test & verify. My only point was that your answer contradicts the "advice" in man dhcpcd.conf - and that seems to be beside the point that the question is "a bit odd". When you say, it's the correct way..., and it's at odds with the advice given by the authors of the software, I think you've put yourself in a difficult situation unless you have a sound reason for doing so. But of course at the end of the day, it's your answer, and it's up to you how you write it up.
    – Seamus
    Nov 25, 2021 at 23:13
  • @Seamus I see what you are getting at. The "correct way" is to "request" when you want a specific IP address from the dynamic address range. The DHCP server may or may not accept the request. If you want a specific IP address from range not reserved for dynamic assignment, you may use the static or presumably the inform option.
    – user68186
    Nov 25, 2021 at 23:22
  • Maybe.. I've not thought through it all recently. If you're interested, you may want to peruse this Q&A, and read the RFC documents to get a feel for the various permutations. Personally, I don't know why Roy Marples recommends inform over static, but I'm sure he understands the operation of his software far better than I. :)
    – Seamus
    Nov 25, 2021 at 23:28
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.

2
  • When one uses a phone as an Wi-Fi access point, what you call the "host" or the "router" is nothing but the phone. In that case the phone is also the "DHCP server". I don't see any settings for the DHCP server in my phone. But then this is not a Pi problem.
    – user68186
    Nov 27, 2021 at 1:03
  • Thank you very much for your reply. I do not "want" to be able to access it from multiple phones used with tethering. I "have to" as I am in a remote area in Africa and the only possible internet connection is through phones. All tutorials I saw are for places with routers, fast internet, monitors and so on, unfortunately there is not always access to all these tools, so thank you for trying to understand the problem.
    – have fun
    Nov 28, 2021 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.