Message destination host unreachable from default gateway - packet

I have some PCs (win) + server + network printers all connected to the same switch and all configured in the same subnet.
When the switch is not connected to the uplink everything works fine
(my office is isolated from the rest of the world). But when we
connect the uplink (to other switches) we have random packet loss.
If I ping my subnet (my PC's!!!) I get random temporary messages "destination host unreachable" replied from my default gateway (???), but if I ping outside my subnet I have no packet loss. When I'm getting the "host unreachable message" in my ARP table I see the default gateway MAC address at the IP that I'm pinging (???).
What's going on? Thanks

Related

How does ping -a know the hostname of my Raspberry Pi 4?

My Raspberry Pi 4 B is connected (for the first time) to the WiFi of my PC (running Windows). Then the raspberry(ip) showed up in the list in Network Scanner of MobaXterm. What surprised me is that the list also shows the name of my Pi. And ping -a ip also shows the name.
How does this work?
When the Raspberry Pi connects to your WiFi it doesn't just get an IP address assigned. It also gets a host name assigned. It either sends its own host name to the DHCP server or the DHCP server assigns a host name.
Now, when you have an IP address, you can do a reverse search. Usually DNS works in the way that you give it a name and it returns the IP address. But there is also reverse search, give it an IP address and get a name back.
In your local network the DHCP server and your DNS resolver work together. Whenever a reverse search for a local IP address is made, the answer is fetched from the DHCP server. And the DHCP server answers with the host name from step one.
In most WiFi routers dnsmasq does this for you, on a Windows machine it is built into Windows.

How sockets determine the requesting machine

how does a socket finds my private ip address as public ip are different than private and inside a public network there can be many private ip addresses with listening to a particular port
In order for a remote machine to send packets to your computer, the remote machine must know it's "public" (from the view of the remote machine) IP address.
Most routers these days have only a single IP address assigned to them from the upstream service and so do Network Address Translation (NAT) for those machines behind it.
Every IP packet outbound from your machine to an outside server has it's address changed to the public address of the router and the router keeps an internal record with the destination address & port along with the true source that sent it. Every inbound packet has the originating address & port checked against those records to find out what internal machine should receive it; the destination address is set appropriately and the packet forwarded.
Neither side can generally tell (or care) that NAT is happening.
Note, however, that you can't initiate a connection from the outside to an internal machine because there is no record indicating where those initial packets should be sent; additional static configuration would be necessary.

Connect to server via a local network

When I launch a server in my pc he is listening any ip and a port 105. If a client on another computer wants connect to the server in my computer he is using local ip address like 192.168.1.101.
If a client will use my local ip address (192.168.1.101:105) to send a request, then my server will be able to receive it?
So long as there is a network route between the two computers and no firewall getting in the way: yes.

TCP/IP Socket Programming Static Web IP between Dynamic IP

I am confused about TCP/IP Socket Programming. I know the internet protocols but in theory...
I am explaining my problem (what i need )
I have a server working on X.X.X.X IP Adress. And it always listens to Y PORT.
When i want to connect that server on MY PC, i have no problem because i wrote the ip adress (X.X.X.X) and the port (Y) and my PC connects..
When i connect to server server keeps my ip adress and my local ip adress.. After that connection is end.
Here is my problem starting...
As i sad my server knows my local PC informations. How can i connect to my local PC on server my web server and sent TCP or UDP packets ? I did port forwarding on my modem but i dont want it. When i did port forwarding there is no problem but i dont want it ...
Thanks for replies and sorry for my engislih if i have mistakes .
If a router/NAT sits between your server and an outside client, you MUST use port forwarding on the router. The outside client will NOT be connecting to your server's private LAN IP/Port directly, it will be connecting to the router's public WAN IP/Port instead. So the router needs to know to forward inbound packets to that IP/Port to the server's private LAN IP/Port.
A client running on your local PC is able to connect to the server because they are both on the same LAN side of the router, so the connection is direct and does not go through the router's WAN. That is not the case for clients that are on the WAN side of the router.

Can't connect to my webserver from external source

I am having problems connecting to my website from a source outside my local network. I had another server before running the same site. The only difference is the old one was FreeBSD and now I'm trying it on Linux.
Here is my setup: I'm using Apache2. The server is behind a Netgear router. I'm using a Freedns host name. I have ddclient updating my ip.
Here is what happens: I can look at my site from the server in Chrome or my phone connected to the local wifi. It works using either the host name or ip address. It does not load from my cell phone or from my desktop using a proxy for either the host name or the ip address (the external one from googling my ip and from the router's wan info page). When I try the proxy with the host name I get "conection timed out" error, and when I try the ip address I get "couldn't connect to host error".
Here is what I've tried: I enabled port forwarding to the server from and to port 80 to my lan ip address. I disabled the firewall on the server. I double checked that the host name is directed to the right ip address. I ensured that the ip address does indeed point to my router. I've watched wireshark on my server while trying to connect and don't see any incoming requests when I try to load it from my phone.
It seems like maybe my port forwarding isn't working, but on my router it says that that port forwarding rule is active.
I'm out of ideas as to why what else could be going wrong.