0

Suppose there is a setup like below:

                                  ------
                                -INTERNET-
                                  ------
                                     |
                                     |
                                     |
                                     | 
                                ___(ETH1)___ 
                               |            |
(SUBNET 1)---------------(ETH0)|   ROUTER   |(ETH2)---------------(SUBNET 2)
                               |____________|
                                   (ETH3)
                                      |
                                      |
                                      |
                                      |
                                  [SWITCH]
                                   /  |  \
                                  /   |   \
                                 /    |    \
                                /     |     \
                             PC#1    PC#2   PC#3

My first questions are regarding the router. I am under the impression that each router interface has its own IP address and subnet mask, both of which are given to them by the ISP. For example, ETH3 could have the IP: 192.168.1.20/24. This means that the network ID (id of the subnet) is 192.168.1, and thus all servers in the subnet connecting to the ETH3 interface will have IP's of the form 192.168.1.XX. Is all this correct?

Next, I am a little uncertain as to how a packet is routed from the internet to, say, PC #3. Suppose PC#3 has the IP 192.168.1.45 and makes a request to www.facebook.com. Is the following correct? PC#3 is part of the 192.168.1 subnet (which connects to the 192.168.1.20 ETH3 interface). So, www.facebook.com sees a request is made from 192.168.1.20 (ETH3 interface). It sends a response to this request, which is eventually routed to ETH1 and then to ETH3. Finally, when the response reaches the switch, the switch reads the MAC address in the response packet header, and sees that PC#3 made the request. Thus, it sends the packet to PC#3.

If this is correct, I am slightly confused as to why it is necessary for PC#3 to have its own IP address in the first place, if the only information used to get the packet from www.facebook.com to PC#3 is the IP address of the router interface the PC is connected to + the MAC address of the PC.

Finally, I have a question about the ethernet interfaces. Are ETH0, ETH1, etc. just generic names given to ethernet ports? So, if my laptop has an ethernet port, will that also often be referred to as ETHO? In the same vein, are switch ethernet ports also enumerated in the same way (ETH0, ETH1, ETH2).

Any clarification on this would be greatly appreciated. Thanks!

4 Answers 4

3

I am under the impression that each router interface has its own IP address and subnet mask, both of which are given to them by the ISP.

If an interface is connected to something your ISP controls, you'll need to use an IP that your ISP assigns. If it's connected to something you control, you'll need to assign IP addresses yourself.

Technically, you could have an "internal only" router that only connects 2 or more private subnets, and access to other subnets would not be possible. There is no strict requirement that a router hand off traffic not matching any known route in it's routing table to a default gateway.

ETH3 could have the IP: 192.168.1.20/24. This means that the network ID (id of the subnet) is 192.168.1, and thus all servers in the subnet connecting to the ETH3 interface will have IP's of the form 192.168.1.XX. Is all this correct?

It also means that you get a "free" directly-connected route based on the IP/subnetmask assignment - the router knows that it can reach 192.168.1.XX via ETH3, so an entry will be placed in the routing table simply due to that fact.

Next, I am a little uncertain as to how a packet is routed from the internet to, say, PC #3.

  • PC#3 wants to talk to facebook.com
  • PC#3 issues a DNS lookup and finds facebook.com's address
  • PC#3 uses local TCP/IP stack to talk to facebook.com.
  • TCP/IP stack consults local routing table to see if facebook.com's IP address matches any routes.
  • Since PC#3 is a standard PC, it's routing table is probably going to be pretty simple and look like this (simplified):
    • 127.0.0.1/8 via virtual localhost interface
    • 192.168.3.0/24 via local NIC.
    • Default gateway which should be router's IP (which HAS to be a 192.168.3.XXX/24 address in the same subnet as PC#3).
  • The TCP/IP stack will try to find a matching route, and if none is found, will send traffic to the default gateway if it exists. As facebook.com's IP will not match any of those routes, PC#3 will send the traffic to the default gateway.
  • Router receives traffic on eth3.
  • Router's TCP/IP stack will consult routing table to see if it can find a matching destination. It does the same thing as the PC does. The router's routing table will look something like this, though (I made up addresses for the other interfaces as an example):
    • 192.168.0.0/24 via eth0
    • 192.168.2.0/24 via eth2
    • 192.168.3.0/24 via eth3
    • Default gateway via eth1
  • Router's TCP/IP stack consults its routing table to see if facebook.com's IP address matches any routes, and if none is found, will send traffic to the default gateway if it exists. As facebook.com's IP will not match any of those routes, PC#3 will send the traffic to the default gateway.
  • eth1 will have to have NAT configured, so at that point, NAT changes the source address to look like it came from eth1 and remembers that fact for when it receives a response.

And so forth. The same process happens at your ISP, then your ISPs upstream provider, and so forth until it reaches the destination.

... I am slightly confused as to why it is necessary for PC#3 to have its own IP address in the first place

When traffic crosses routers, it leaves one network and enters another. The original MAC address is lost once traffic crosses a router. IP stands for Internetworking Protocol - it's an address scheme that is designed to allow any computer to reach any other computer globally - and if the destination computer is not on the same network, a hierarchy of routers is supposed to forward on the traffic back and forth.

Finally, I have a question about the ethernet interfaces. Are ETH0, ETH1, etc. just generic names given to ethernet ports

The ethX scheme is just a convention - by default Linux will name the first one it sees eth0, the next eth1, and so forth. Names are assigned by udev or systemd and persist by MAC address. The name can be changed to anything you want.

0

You ISP gives you 1 IP address (be it static or dynamic). This is usually assigned to your router. The rest of your devices usually just get NATed versions of that IP address. You can read more about NAT on Ciscos website - they give a pretty good explanation of how it works: http://www.cisco.com/c/en/us/support/docs/ip/network-address-translation-nat/26704-nat-faq-00.html

Basically PC3 doesn't have it's own global IP address, it only has a unique IP address within it's own network.

In regard to your ethernet port question - the name is given by the interface of the adapter, this totally depends on the manufacturer and the drivers. Typically though they're called things like 'Local Area Connection'

0

I am under the impression that each router interface has its own IP address and subnet mask, both of which are given to them by the ISP.

Only the WAN-facing interface (ETH1 in this case) would have an (external/public) IP address assigned by the ISP. The other interfaces would have a manually configured (internal/private) IP address (in this particular case).

For example, ETH3 could have the IP: 192.168.1.20/24. This means that the network ID (id of the subnet) is 192.168.1, and thus all servers in the subnet connecting to the ETH3 interface will have IP's of the form 192.168.1.XX. Is all this correct?

Correct, even though the subnet ID would be 192.168.1.0 to be exact. http://www.cisco.com/c/en/us/support/docs/ip/routing-information-protocol-rip/13788-3.html

PC#3 is part of the 192.168.1 subnet (which connects to the 192.168.1.20 ETH3 interface). So, www.facebook.com sees a request is made from 192.168.1.20 (ETH3 interface). It sends a response to this request, which is eventually routed to ETH1 and then to ETH3. Finally, when the response reaches the switch, the switch reads the MAC address in the response packet header, and sees that PC#3 made the request. Thus, it sends the packet to PC#3.

No, facebook.com would see a request from your external IP address (the one on the ETH1 interface). Since private IP addresses are not routable on the public Internet, the private IP address of the PC (192.168.1.x) is “translated” to the public/external IP address through a process known as Network Address Translation (NAT). The router keeps track of these translations in a so-called NAT table, so it knows where the request came from, and where to send the reply from the server. http://www.cisco.com/c/en/us/support/docs/ip/network-address-translation-nat/26704-nat-faq-00.html

If this is correct, I am slightly confused as to why it is necessary for PC#3 to have its own IP address in the first place, if the only information used to get the packet from www.facebook.com to PC#3 is the IP address of the router interface the PC is connected to + the MAC address of the PC.

Because routers don’t work with MAC addresses (layer 2 of the OSI model), they work with IP addresses (layer 3). The router knows which IP address the packet is for, and so it forwards the packet to the switch, which looks for the IP address in its ARP table to find the corresponding MAC address and then send out the frame on the appropriate interface/port. https://en.wikipedia.org/wiki/OSI_model
https://en.wikipedia.org/wiki/Address_Resolution_Protocol

0

My first questions are regarding the router.

If it's a router ;-)

'cos remember that a lot of devices marketted as routers, they have a router and switch in there, they route and switch, and all the external LAN ports on many of these devices, are switch ports rather than router interfaces.

But for your diagram, with the distinction you make between router and switch, let's say the router is a router and the switch is a switch.

I am under the impression that each router interface has its own IP address and subnet mask,

Yeah it does.

both [router interfaces]... are given to them by the ISP.

What are you talking about

You say "both" but your picture shows Four.

And only one of those 4 has an IP from the ISP, though even that could be set statically e.g. if the ISP gives you a static IP you could get it by DHCP from the ISP, or set it yourself.

For example, ETH3 could have the IP: 192.168.1.20/24. This means that the network ID (id of the subnet) is 192.168.1, and thus all servers in the subnet connecting to the ETH3 interface will have IP's of the form 192.168.1.XX. Is all this correct?

I think the terminology there is right or about right.. (surprisingly). But why do you say "all servers". Why are you concerning yourself with whether a computer connected on that interface is a "server". (whatever you mean by "server" - since that's an ambiguous term)

And from books i've read, generally router interfaces tend to be .1 or .2 e.t.c. generally the subnet address is .0 and the router interfaces on that subnet are +1 or +2 from that e.g. .1 or .2. e.g. there could be two router interfaces on a subnet.

Next, I am a little uncertain as to how a packet is routed from the internet to, say, PC #3. Suppose PC#3 has the IP 192.168.1.45 and makes a request to www.facebook.com. Is the following correct? PC#3 is part of the 192.168.1 subnet (which connects to the 192.168.1.20 ETH3 interface). So, www.facebook.com sees a request is made from 192.168.1.20 (ETH3 interface). It sends a response to this request, which is eventually routed to ETH1 and then to ETH3. Finally, when the response reaches the switch, the switch reads the MAC address in the response packet header, and sees that PC#3 made the request. Thus, it sends the packet to PC#3.

No Way.

For a start there's NAPT. aka NAT/PAT which is a form of NAT. And the following would be true even without the PAT. If you go to www.whatismyip.com you will see that the Internet will never see an IP address like 192.168

You should know that before you even know what a router is! And long before you even know what a subnet is

Have you not noticed that loads of peoples computers have IP addresses like 192.168 Do you realize those would clash if they were all out there on the Internet.

If this is correct,

It wasn't

I am slightly confused as to why it is necessary for PC#3 to have its own IP address in the first place, if the only information used to get the packet from www.facebook.com to PC#3 is the IP address of the router interface the PC is connected to + the MAC address of the PC.

The way a router works is the computers on or beyond one interface don't know the MAC addresses of the computers on another interface.

And the thing is, that technically you could take a router with 2 ports, one internet side and one LAN side, and a switch, and that's how most peoples "routers" are. And in that situation, technically, theoretically, and they're not built like this, but technically.. If TCP/IP were very different, you could do away with the IP Addresses.. on the LAN. It just won't be as efficient.. on a huge LAN. Since IP addressese are hierarchical and MAC addresses are flat. Hierarhical means e.g. you can narrow a computer down to a subnet, like narrowing a person down to a country when sending a letter. You can get it to them quicker.

Finally, I have a question about the ethernet interfaces. Are ETH0, ETH1, etc. just generic names given to ethernet ports? So, if my laptop has an ethernet port, will that also often be referred to as ETHO? In the same vein, are switch ethernet ports also enumerated in the same way (ETH0, ETH1, ETH2).

I have no idea what you have in mind by "generic name",

but anyhow, I don't know.. I know what it means and i've used it in windows but I don't know the nature of that name - particularly in windows one almost never sees names like that in windows, but I think maybe a program called tcpdump (originally a *nix program) but which has a windows version, so can run on windows, calls them that.. so perhaps it's somewhat fundamental at least in some way, (e.g. at the minimum maybe one interface is 0 and one is 1, e.t.c. even if eth0 and eth1 e.t.c. is more *nix terminology and cisco ios terminology, or non windows terminology put on Windows.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .