In my local machine if I set the IP address to an interface, how other machines know this and route the packets to me if anyone tries to send packets to my new IP? I am in a private network.
Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.– Ron Maupin ♦Dec 17, 2020 at 16:20
Simple answer: The machines don't know the route.
The IP address that you use must be in the range of the so-called "subnet" the machine belongs to.
This means that all machines that can be reached without using a router in between must have an IP address in the same range and all these machines need to know this range.
In an Ethernet network you need the MAC address of a machine to send data to that machine.
If a machine wants to send data to another machine, it will first send an ADP packet (used together with IPv4) or an NDP packet (IPv6) to all machines in the "subnet".
This ADP or NDP packet contains the IP address of the machine to which the data shall be sent. The machine having that IP address will send an answer back to the machine that wants to send the data.
The first machine now knows the MAC address of the second machine and can send data to the second machine.
In (very) old Ethernet installations data was always sent to all machines in the network. It was the task of the network card to filter out all data that was sent to machines with another MAC address.
In current Ethernet installations "switches" are used. When data is routed through a switch, the switch remembers the sender's MAC address and the "port" (the cable) on which the data was received. When a packet shall be sent to that computer later, the switch knows the route to this MAC address. When a switch does not know the route, it routes the data to all ports (which may mean: to all computers in the "subnet" - just like in old Ethernet installations).
If a router is between two computers, the computers are in different "subnets".
In this case the computers must know the (MAC or IP) address of the router which is used to reach the destination computer's "subnet".
In the case of an IPv4 home network the DHCP protocol is often used to tell all computers the IP address range of the home network (which is a subnet) and the "default router" (which is the router that must be used for all IP addresses outside that subnet). This information does not change if you change the IP address of your computer because the new IP address must be inside the IP address range of your home network.
@Martian tnx for your response, I make sense to me. I have one more doubt. After switch caches the mac address and the port, Incase if an IP address assigned to a different host, will switch drops the cache if yes, is it costly. Mar 18, 2020 at 10:38
I am asking this because in my case single IP will be assigned to a different host from time to time but it is sure that one IP will be assigned to one Host at any given time. Mar 18, 2020 at 10:40
@KarthikNedunchezhiyan A switch doesn't care about the IP address, it only uses the MAC address. The MAC address is inserted by the local router and whether it is accurate or not depends on the router's ARP caching. If an IP is reassigned on short notice, the new host should send a gratuitous ARP (GARP) to update all ARP caches.– Zac67 ♦Mar 19, 2020 at 9:40