Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
1  
belongs on superuser –  cas Aug 15 '09 at 10:16
19  
Why? Because it's a beginner level question? Or a networking question? I think the subject matter is fine for SF. –  pgs Aug 15 '09 at 12:16
    
because it's an end-user question. –  cas Aug 16 '09 at 9:16

6 Answers 6

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%5Fgci212924,00.html

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

Edit: Just found an über excellent explanation of routing which contains all needed knowledge: http://serverfault.com/questions/49765/49836#49836

share|improve this answer
4  
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 '09 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 '09 at 11:18
    
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 '09 at 17:00
    
Another way to have a router that routes but only has one IP address would be to have it route through unnumbered tunnels (MPLS TE tunnels come to mind). They definately do routing, and have a routing table that they use. But this is all for extra credit. The simple answer for one who has to ask is as you say; a router is a device with addresses on at least two networks, and it performs routing between them. It's not the definition for a router though. –  Thomas Aug 15 '09 at 17:06
    
'Router has a minimum of two interfaces' instead of two IP's would be more correct. –  Marcin Aug 15 '09 at 18:56

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.

share|improve this answer
2  
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 '09 at 17:11
    
Ah nice, didnt know that, never used frame relay or ATM. –  Marcin Aug 15 '09 at 18:55
    
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 '09 at 12:36

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?)

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
    
Also, if you give a mouse a cookie, he'll probably want a glass of milk... –  jj33 Aug 15 '09 at 11:29
    
This is not an IP router - it's a voice gateway :-) –  slovon Aug 15 '09 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 '09 at 1:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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