13

Do routers have IP addresses, if so then how many? and how can I get the IP addresses of the router if connected to a LAN?

According to me it can have only one IP address, it cannot have multiple addresses. Please correct me if i am wrong, or does there exist a situation where it can have multiple addresses?

Thanks.

3
  • 1
    belongs on superuser
    – cas
    Aug 15, 2009 at 10:16
  • 21
    Why? Because it's a beginner level question? Or a networking question? I think the subject matter is fine for SF.
    – pgs
    Aug 15, 2009 at 12:16
  • because it's an end-user question.
    – cas
    Aug 16, 2009 at 9:16

8 Answers 8

21

An IP router has to have a minimum of 2 IP addresses, because its function is deciding on where to send the packet next. A minimal configuration of TCP/IP network where you need a router is a connection between two networks with different network part of the network addresses.

Many times there is also another IP address for management purposes, so you can say that it is the router's own address, but it has nothing to do with the function of router as its merely a convenient access.

So a minimum is one incoming interface and one outgoing interface each of which has to have a different IP address to differentiate them. There can be as much as you want, taking care of many network interconnections, provided you have the needed resources (RAM, CPU, network interfaces, ...).

If there is no choice, there is no routing function so even if you call the box an IP router, it is not. :)

Links to learn more:

http://en.wikipedia.org/wiki/Router

http://searchnetworking.techtarget.com/sDefinition/0,,sid7_gci212924,00.html

http://computer.howstuffworks.com/router.htm

Edit: Just found an über excellent explanation of routing which contains all needed knowledge: How does IPv4 Subnetting Work?

10
  • 7
    Arguably, a device with two ip unnumbered serial interfaces & one (numbered) ethernet might still be called a router, especially if it is deciding which serial interface to send the packet down based on destination IP address. </nitpick>
    – derobert
    Aug 15, 2009 at 11:02
  • I'd rather call it a bridge in this case, but you have a point. And in this case there would still be a routing rule association between IP addresses on "the other side" and the unnumbered serial interface so technically the two machines on both sides of the serial link together form one route with internal bridge. And it has at least two IPs.
    – slovon
    Aug 15, 2009 at 11:18
  • 3
    slovon: You can call it an elephant if you want, it's still a router with a routing table that takes routing (layer3) decisions. A bridge is something else.
    – Thomas
    Aug 15, 2009 at 17:00
  • 1
    'Router has a minimum of two interfaces' instead of two IP's would be more correct.
    – Marcin
    Aug 15, 2009 at 18:56
  • 2
    @Marcin: A router need not have two interfaces. It could be routing between multiple (tagged) VLANs on one interface, or even multiple subnets on the same VLAN & interface.
    – derobert
    Aug 16, 2009 at 4:39
8

Routers usually do, but don't have to have IP addresses. Routing itself does not require any of the interfaces to have an IP bound to them. When a packet arrives on any interface, the IP headers get inspected, primarly the destination IP. That gets compared against the routing table, and as long as it fits into one of the specified ranges (or the default route if not), it gets put on the corresponding INTERFACE, not IP. At no point in this process the router needs it's own IP. The only reason they have them is so you can access them remotely for maintenance, or to easily keep track of which interface belongs on what network.

6
  • 3
    Almost right. On multiaccess networks the IP is of course used to find what circuit (frame relay or ATM) or what destination MAC (ethernet) the router is on. Not needed for the router itself though. So maintenance is not the only reason.
    – Thomas
    Aug 15, 2009 at 17:11
  • 1
    Ah nice, didnt know that, never used frame relay or ATM.
    – Marcin
    Aug 15, 2009 at 18:55
  • 1
    Without an IP address associated with an interface, there is no way for stations on the LAN connected to the interface to resolve eth hardware address of the interface. So, while it's not (necessarily) needed for the administration of the router, it's needed for IP traffic to pass through. A switch does not need an IP address, other than for management, though, as it's purely a "layer 2" device.
    – Vatine
    Aug 17, 2009 at 12:36
  • 1
    @Marcin They also need an IP address to use as source address on any error messages generated in case a packet cannot be routed. It is possible to use the same address for all interfaces.
    – kasperd
    Jan 7, 2016 at 9:18
  • 1
    @Vatine but one ip addr shoud be enouth to resove its mac addr
    – scottxiao
    Feb 1, 2022 at 3:11
3

The short answer is:

Yes. By definition, a router must have more than one interface (with an IP address per interface) to send and receive packets and forward packets from one to the other based on the destination addresses of the packets. Not all routers speak only IP, but "multi-protocol" routers are not really necessary now that everything speaks IP.

The more complex answer is also yes...

The typical implementation of a router has an IP address per "directly attached network" or subnet the router can reach via a local network. (ie if the router has an address 10.10.10.1/23 it can reach any IP address between 10.10.10.1 through 10.10.11.254 from that interface). Hosts on that layer 2 network and in that address space would be configured to use 10.10.10.1 as their "default route" so any traffic not going to 10.10.10.1/23 would be given to the router to send to the final destination. At this point, hopefully the router has one more IP address which it uses to communicate with that router's default route (or the other directly attached network that has the destination address).

In addition to having more than one IP address, routers may even have more than IP network such that the same IP address exists on several different subnets in the router and the router knows that if traffic from interface A is destined to 10.10.10.10 it goes out interface C, but if it comes in from interface B it must go to interface D. The two most common situations where this can happen are with management networks or with "virtual routers" where a single router is partitioned into different virtual routers for different non-related clients.

It is even possible for a thing that I would call a router to not have an IP address, such as if you have what everyone else calls a "firewall" in bridging mode that enforces policy routes. Such a device would be a nightmare to support and confuse the people who take over for you after you're fired, but it does route and it doesn't have a local IP address. (the lunatic who implements such a thing would obviously manage it from a serial port, right?)

1

Yes, and pretty much as many as you wish, as for how to get the address - well that's a much bigger question that needs a bit of thought. Why don't you ask us what you really want to know and maybe give us some better/more information.

1

I have a router with a single IP address - it's a voice gateway. It's a cisco 2431 (I think). The call agents on our voip system route outbound local calls through it. It speaks IP on the LAN side and TDM over PRI out the other. So, in effect, it's a router routing between an IP LAN and the PSTN. Kind of a half answer, but it helps to remember that the whole world isn't IP.

As a closer answer:

  • In a pure IP network, most routers would have an IP address per physical interface.

  • If they are running a dynamic routing protocol like OSPF, they'll probably have a /32 loopback address also

  • If they are running trunking, they may have multiple IPs per physical interface, but still only one IP per LAN

  • It is possible to put multiple broadcast domains on the same LAN, in which case you would have a router gateway address per broadcast domain, per LAN

  • You might also have a shared address between multiple routers. Cisco would use HSRP for this. You would have a unique address per broadcast domain, per LAN as described above, and then the gateway address used by the devices on the broadcast domain would be "shared by two routers so that is one filed, the other would take it over.

3
  • Also, if you give a mouse a cookie, he'll probably want a glass of milk...
    – jj33
    Aug 15, 2009 at 11:29
  • This is not an IP router - it's a voice gateway :-)
    – slovon
    Aug 15, 2009 at 14:00
  • It's a router... It routes between IP and PSTN... But yeah, I know it was a silly answer, that's why I gave the real one too.
    – jj33
    Aug 16, 2009 at 1:32
0

Routers typically have multiple IP addresses. They have (at least) one IP for each LAN (well, at least if it's an IP LAN) and usually one (sometimes more, but usually one) address attached to a "loopback interface" for management purposes.

A router with just a single IP address doesn't make much sense, as it will need an IP address per interface/LAN it wants to provide IP connectivity to. So with only a single IP, you'd need to have a translation between IP and another protocol and while I can probably concoct a scenario where that is exactly what you want, it's definitely not a common occurence.

0

Router work at network layer.It helps connecting two different types of network.It has two NICs (Network interface card) corresponding to each network it connects to, So it consist of two IP addresses[Minimum] for each NIC.

For ex. If we are connected to network1 (lets say LAN) and we want to send data to network2 (assume it a ring network) then we need to send data to some other type of network (our system doesn't know protocols related to ring network as we are connected to network1 (LAN)). so at this point we need a router which knows protocols related to both type of networks (LAN and RING) as it has two NIC (One supports LAN network and other supports RING network). Now we send our data (Which is in LAN format) to router which then converts that data in RING format and pass it to RING network.

This is how router works.

Ways you will get your routers IP address:

  1. Your gateway address is your routers address ipconfig /all
  2. You can trace the route of your data packets tracert command. There you can spot your routers IP address.
-2

The router MUST ATLEAST HAVE 2 DIFFERENT PHYSICAL/MAC ADDRESSES, given it connects 2 different networks, having different architecture... ( peer protocols come in use ).

NOW, talking about router's multiple ip addresses,  one for each interface....

One must recall that a router is primarily a network layer device,  like the 3-layer switch ( a kind of router ), although it can and is often used at 2nd layer also ( private network routers  - termed intradomain routers ) And the TCP/IP suite requires the network layer devices to handle the  flow of packets ( since the internet is a packet switched network  - packets being called datagram ) across asynchronous systems ( interdomain routing )....

Thus, a router or any third layer device ( specifically  the interdomain ones - acting as  gateways between 2 asynchronous systems )....needs to be able to correctly & EFFICIENTLY DETERMINE the route ( the next node in its immediate neighborhood network  i.e. physically linked )....  The keyword is " efficiently "...

Now, to do that, the routers , specifically at the interdomain level, need to communicate  - about their local networks, status of their neighborhood routers ( directly connected ), their own status like heavy traffic , busy/closed interfaces, etc...

ALL OF THIS COMMUNICATION  FOR - getting a datagram packet from any corner of the internet to any other corner.... There are dedicated international and peering agreements  ( local ISPs ) called protocols for these router-router communication ( inter and intradomain ). These are the protocols which help every host - end devices , routers etc,  connected to the internet to maintain their routing tables..... and which is the  software level BACKBONE of the entire internet....

Now, consider, one router R1 in any area A1 goes down for some reason, this will immediately alert its neighboring routers ( thanks to protocols ) and they will send the message to ALL THE OTHER ROUTERS CONNECTED TO THE INTERNET.... let say this router was the only one which connected all the local devices in area A1 to the internet.

THE FINAL AHA MOMENT - how does the routers which have ENTIRELY DIFFERENT ARCHITECTURE FROM THE R1 router know which particular router (  MORE ACCURATELY  -  which interfaces/path-ways/routes ) are now unable to accept any packets  and hence to be aware in case any packet having destination at A1 arrives,  i.e.  that packet must be dropped and send a host-unavailable message to the sender....

Since, routers already have a lot to deal with, and  being able to process the address version of different architectures is going to be REALLY REALLY inefficient in a internet level WAN ... SO obviously we need a way to be able to address basically any router being connected with a single set of addressing system... thus we need a logical address... AHA -  enter ip addresses for each interface of the router.... Obviously,  in case a specific interface goes down or becomes heavily congested.. that particular path need only be communicated to other routers or the routers which use that path..

So , there you have it.... why routers need ip addresses too with physical address... for each interface

2
  • 1
    I can set up a perfectly valid router (in an OSI sense, the device which forwards packets based on layer 3 information), which has exactly one IP address (besides 127.0.0.1). The router also can have only a single network interface. And yet it is valid router. I even can suggest two distinct use cases for this, which are completely different. Each and every your sentence here can be proven wrong. If you were reading other answers here, you'd see the magic word "unnumbered" here, and that's one of them; that's the example case of an IP interface which doesn't have any IP address assigned. Oct 3, 2022 at 12:18
  • 1
    Look into the comments of the best rated answer to see such cases. derobert seems to be networking-related guy, he essentially mentioned two of the possibilites, there are two more in my opinion. but that's already a good start. Oct 3, 2022 at 12:30

You must log in to answer this question.

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