This is an issue with name resolution. So far as I can see from your description we have the following situation. The RasPi is connected to two subnets:
- to the subnet 192.168.4.0/24 with interface wlan0 and static ip address 192.168.4.1 that spans the wifi for the access point. With access point we have a managed wifi and the raspi managed it on this subnet.
- to the subnet 192.168.137.0/24 with interface eth0 as client. It get its ip address by DHCP from the laptop that act as an router to the internet on this subnet.
There is no routing between wlan0 and eth0 so a subnet is independent from the other. On each subnet is a DHCP server running: one on the RasPi for the wifi and one on the laptop (presented with shared internet) for clients connected to it. If avahi find a DHCP server on its subnet it will never autoconfigure an ip address from range 169.254.0.0/16. This is by specification in RFC3927. See also discussion on Can't SSH by name on stretch; can on jessie. You can verify it very simple with
ip addr when avahi is running. The interfaces have only the ip address from the DHCP server. This means you will never find a host with domain
.local, e.g. raspberrypi.local in your case.
For name resolution is the DHCP server responsible together with a DNS server, mostly a caching only DNS server on the local system. When the DHCP server gives a new lease (ip address) to a client it also informs the DNS server what hostname it has which caches it. The laptop has this functionality because it defines a dns domain
mshome.net so you can address its clients e.g. with gateway.mshome.net.
I don't know how do you setup your access point but on a RasPi usually the software
dnsmasq is used to setup a DHCP server and a caching only DNS server. If you also use it then look at its configuration what DNS domain it presents. dnsmasq by default enables its DNS server. Then with the hostname and the domain you should be able to address your hosts on the wifi, e.g. gateway.my-wifi.net.
With your update I had a look at the man page of dnsmasq and found:
Dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server. It loads the contents of /etc/hosts so that local hostnames which do not appear in the global DNS can be resolved and also answers DNS queries for DHCP configured hosts.
I'm not using dnsmasq so I cannot test it, but with an entry in
/etc/hosts you should be able to solve your problem. Try it by inserting one or two of these lines into
# 127.0.1.1 is often used for the FQDN of the machine
127.0.1.1 gateway.my-wifi.net gateway
192.168.4.1 gateway.my-wifi.net gateway
Please give me feedback because im interested in this.