For each IP, there is only one MAC address? - ip

I read a book about IP & MAC addresses.
As I understand, we use ARP in order to find the MAC address of the PC.
My question is if there is only one MAC address for each IP's address? And if so, why do we need the IP address? Why we can't easily go to the MAC address?

There should only be one MAC address per IP address but the MAC address never leaves the subnet and the MAC address has nothing to do with routing outside the subnet. You can't say anything about where a packet should go from outside the subnet given only MAC address. Think of it like a person's name. Even if it were unique it wouldn't help you find them. You need to look up the street address (ARP) and use a map (routing table) to figure out how to get there. Then once you get to the right house (subnet) you just dump all the mail on the counter and let everyone pick up the mail with their name (MAC address) on it.

Related

User can't see server

The user is reporting the issue has an IP address of 10.10.15.67/20. The server has an IP address of 10.10.16.1/20. The user's machine has an IP address of 10.10.25.197/20. Can anyone explain to me based on this why he can't get to the file? This users has full permissions.
The first IP address belongs to network 10.10.15. The other two, to 10.19.16.
Do the first machine not being in the same subnet cannot talk to the two others. Use ping to confirm that.
You can use the subnet calculator here: https://www.calculator.net/ip-subnet-calculator.html

How does a computer know other computer's IP address on a local network?

I'm currently learning about ARP and L2/L3 networking - would someone be able to help out? If I use an ethernet cable to connect my laptop (A) to another laptop (B), it could use ARP to find out B's MAC address based on B's IP address. Then, any ethernet frames could be sent and accepted by B.
But how does A know B's IP address in the first place? What if there is a switch (L2 device) in between A and B? Does this change the answer? What if there was a router in between (an L3 device)?
Usually, a switch/Router will assign an IP.
The question is unclear -
find out B's MAC address based on B's IP address.
B's MAC address is not based on B's IP.
A MAC is associated to the hardware (but somewhat assignable/cloneable) where as an IP is assigned. Either by DHCP or statically by an admin.
Effectively, you need a switch/router to make what you're defining work.
EDIT:
you can connect two computers direct, but you still need to give each a static IP address so they can find each other - this would likely not be ona network so the IP sub-network doesn't matter.
It still has very little to do with MAC.
If two PC's hand-shake, they'll see each others MAC.
It sends out a broadcast packet to the broadcast MAC address asking "who has the IP address x.x.x.x" which goes to all computers on that broadcast domain. If a computer sees that packet that owns the IP address "x.x.x.x" it will send a unicast reply back to the MAC address of the original requestor with its MAC address which will then be cached for further communication.
It doesn't know the IP unless you tell it. You say "the default gateway is 192.168.1.1" and it will start trying to talk to 192.168.1.1 etc.
If there is a router in between, all traffic to the remote device would go to the MAC of the router and your computer wouldn't be doing any ARP lookups other than that router.
Switches wouldn't matter for this, all they do is make the broadcast domain bigger. With a cable the broadcast domain is just you and the remote device. With a switch, it expands that to all devices connected to the same switch (or VLAN in the switch)
But how does A know B's IP address in the first place?
It doesn't know. At least there's no general method to find out.
The IP address of any resource needs to be supplied by "something else". You need to either provide the address yourself, resolve it from a (also provided) DNS name, read it from a file, ... Alternatively, you need to provide some kind of auto discovery between the nodes (broadcast, multicast, LLDP, ...) or provide a commonly known discovery service, registration server or similar.
What if there is a switch (L2 device) in between A and B?
That changes nothing but excludes link-level discovery (unless it's a "dumb" switch that simply forwards those frames).
What if there was a router in between (an L3 device)?
That eliminates broadcast and multicast from the picture. (Multicast could be routed but that is unlikely for discovery and I won't dive into that.)

Intra and Inter Subnet Routing

Consider the following figure:
Now, suppose that the host with IP address 111.111.111.111 has to send a packet to 222.222.222.222. Here is what I think will happen:
The sending host will determine that the destination machine is on some other subnet, and hence there won't be an entry for it in it's ARP table. This is done by ANDing the destination IP address with the mask of the sending host's subnet, and then checking for the subnet address.
If it is determined that the destination host is determined to be off the host's subnet, then it will send the frame with the destination address MAC address of the left interface of the middle gateway. My first question: How does the host know the MAC address of this interface?
The gateway will receive the frame, and send it to it's interface on the right. In the frame, the destination and source IP addresses will remain the same, but the source MAC address will be of the left interface, and the destination MAC address will be of the right interface.
The interface to the right will receive the frame, and then will replace the source MAC address with the interface address, and the destination MAC address as the MAC address of??? The router or will be consult its ARP table to find the destination MAC address.
What is the use of the routers in between? Are frames also sent to them using their interfaces' MAC address? For example, the host with IP 111.111.111.111 would first send the frame to the router using its MAC, and then the frame is routed forward.
I am so confused right now. Can someone clear these things up?
Thanks!
Here are some comments/answers:
How does the host know the MAC address of this interface?
It uses ARP for that, but instead of MAC of the destination IP address it requests MAC of the middle gateway.
and the destination MAC address as the MAC address of???
The right host uses the same technique: it sends the ARP request to get a MAC of the middle gateway.
What is the use of the routers in between?
There is just one router and two switches in the picture. Switches are used to split collision domains, while routers are used to split broadcast domains. More on that on Wikipedia:
https://en.wikipedia.org/wiki/Broadcast_domain

Basic networking questions

I am trying to understand how exactly routing works:
if 2 computers are on the same network
if they are on different networks.
More specifically I am trying to understand this: Routing
I am also trying to understand the difference between
IP Address,
Net Address,
Mac Address.
From what I understand:
1) IP Address: is used when computers communicate on the internet only.
2) Net Address: is a local version of the IP address and each device on the network has a unique net address. It's used when devices on the same network want to communicate with each other.
3) Mac Address: is a globally unique address and no other computer in the world has the same Mac address. In reality this is not true because it can be changed. It's used when ???
When a computer wants to communicate with another on the same network, they use net address, right? If the computers are on different networks what exactly happens?
Question: Can someone please fix my mistakes if any and explain what I am missing?
Thank you very much.
There are many network types, but since the most used ones are Ethernet and IP networks (and you seem to be asking about them), I will answer shortly based on them.
IP addresses are always used. They may not be used for deciding who gets the packets directly, but they are the basis even in local networks, since it is an IP network. There can also be other network types that have their own mechanisms, but they are not that common.
In local Ethernet the machines ask via ARP protocol "who has this IP address?" and get a reply with a MAC address. After that they send and receive packets based on that MAC address. The packets still have the IP address information, otherwise the receiving machine wouldn't know what is the destination. Do note that the receiving machine might be a firewall or other middleware device, not the actual computer that has the address. Also a single machine and network card may have several IP addresses set up for it.
In IP networks the IP address is used for routing. All routing devices have a routing table that will tell where the packets should go. If it's a simple device, it usually has a local network and everything else goes via a default gw, which will know better what to do with the packets.
A home router will just push them to the operator, there another router will know what addresses go to their networks, others are pushed forward via another connection, until a bigger place is reached where there are inter-operator connections and they choose again the correct route. And then it goes to smaller and smaller pipes the other way around.

Different IP address error?

I had connect my laptop and phone under a same router/modem.
But the IP addresses that shown on my laptop and phone are different, why???
I'm quite newbie for it, please help me
IP addresses are different inside your network. When you send data outside the network your router uses NAT (Network Address Translation) to assign your Internal(LAN) address your External(WAN) address for the duration of that communication. If they had the same Internal IP address then you would have an error like this http://compnetworking.about.com/od/workingwithipaddresses/f/ip_conflict.htm

Resources