3

So I got pretty confused with this question, and while looking online I've found several answers saying that a router does need 2 IP addresses at a minimum, but it isn't clear to me why.

Lets say there is the following scenario:

A computer, connected to a router (which will be called 'R1'), which is connected to another router (which will be called 'R2') that also acts as the DHCP server of the LAN and has an external IP address.

So I can see why R2 has two IP addresses: 192.168.1.1 - for instance, and some other external IP address, but why can't R1 have only one IP address, similar to the computer?

Thanks

  • I really think you mean IP addresses, not IPs (Internet Protocols). A lot of routers only have one IP (IPv4), but increasingly, many have both current IPs (IPv4 and IPv6). – Ron Maupin Oct 6 '18 at 22:55
  • "but why can't R1 have only one IP address, similar to the computer?" If the computer had two interfaces in two different networks, it, too, would have two IP addresses. Each layer-3 interface gets an address in the network to which it is attached. On the other hand, switches (bridges) operate at layer-2, so they do not get IP addresses on their layer-2 interfaces. – Ron Maupin Oct 6 '18 at 23:14
5

As others have said -- ignoring misconfigurations, bugs, errors states and so on -- a router needs to be on multiple networks and so most naturally has multiple IP addresses.

But there are a couple of special cases

Special case 1: Unnumbered Interfaces

There are certain kinds of networks, most notably point-to-point links and virtual private networks links, which don't need addresses and are sometimes used unnumbered. The router has routes which specify exit interfaces rather than the usual next-hop IP address; as the exit interface is point-to-point, the next router is implicit.

A router which connected lots of unnumbered point-to-point links might conceivably therefore have no IP addresses at all, and still be useful.

Consider it a theoretical case only: no one would do it in real life because you'd want to have at least an IP address to connect to for configuration purposes. And many network engineers prefer to number all the interfaces even if not strictly required, as it can help with monitoring and fault finding.

Special case 2: Next Router on Same Subnet

Directly answering your question (as an elaboration of Zac's "stub router" answer)

why can't R1 have only one IP address, similar to the computer?

You certainly can have the following:

   internet
   |
   R2
   |.1         192.168.1/24
===+===+===+===============
       |.2 |.128
       R1  PC

With R2 default route upwards, R1 default route to .1, PC default route to .2

  • Yes it works but it's considered inefficient
  • Outgoing packets go PC -> R1 -> R2 -> onwards
  • R1 also sends ICMP Redirect message to PC
  • Incoming packets go Outside -> R2 -> PC

R1 thinks it's silly to get a packet which could have and "should have" gone directly to R2, so tells PC with an ICMP redirect; which the PC can ignore or use at it pleases.

You can switch off the ICMP Redirect messages on most routers, but many network engineers consider them useful as they usually show a misconfiguration.

Special case 3: Black hole

One of the special interfaces a router can have is a "null" interface, which just throws away its packets. Normally this is used as a place to send packets which have been judged to be improper in some way, such as packets with an internal source address arriving on an external interface.

A null interface doesn't have an address. So a router which was configured just to accept packets and throw them away might have just a single IP address (or none if it is on the end of a point-to-point link), and send everything to the null interface. You might do this for logging purposes; also, it can sometimes be more convenient to propagate routes to bad addresses rather than access lists.

Search for "black hole routing" to find out about this technique.

| improve this answer | |
  • Good point! A router doesn't always require an IP address on a link. VPN links are often unnumbered. – Zac67 Oct 7 '18 at 13:44
  • (Zac's kind comment was about unnumbered interfaces, before I expanded the other special cases) – jonathanjo Oct 7 '18 at 15:42
  • AIUI with at least some routers it's possible to have unnumbered networks even using Ethernet, with the router's loopback IPs serving as the target IPs for ARP requests. – Peter Green Oct 8 '18 at 15:06
6

Welcome to Network Engineering! Routers route between networks, so they need interfaces in the networks they route to. Otherwise, they're like a "bridge to nowhere."

| improve this answer | |
2

A router can have any number of interfaces, including a single one.

Usually though, it'll have two or more - a router's intention is to connect multiple networks and for that, it is required to have an interface in each network.

Sometimes, a "stub router" or router-on-a-stick is used to route back into the same network (=subnet). For instance, there are multiple gateways attached to a network, each leading to another network. There are simple nodes that can only use a default gateway and the stub router is the one with a complete routing table - knowing all the routes to the other networks. So, it's used as the default gateway and then routes to the actual gateway through the same network.

Also (as jonathanjo has pointed out), a router may have "unnumbered links" that don't require a local IP address - simple serial interfaces, VPN connections or similar.

| improve this answer | |
0

You can have only one IP on the Router, but it will not be able to route packets to another network.

On the first interface you have an IP address of your network, but on another interface, you need to have an IP address which belongs to another network

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.