Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to set up a development environment on my home LAN on the cheap. I have purchased 3 PCs with some extra RAM to play the role of "servers", and am planning on just using my NetGear (wireless) router between these 3 "servers" and my dev machine (laptop).

Since these aren't actual servers, I don't want to keep them powered on and running 24/7/365 as they would probably break pretty quickly and I just don't have the budget to keep replacing parts. So a big constraint is that I need to be able to turn them on and off, pretty much daily. To add to that, there might be "pockets" of development, where I code for a few days, turn them off to save power/hardware, and then I'm not able to get back to the project until the weekend. I only mention this in case my router has some kind of cache with an explicit TTL, etc.

So, as far as I understand networking, every time I power these machines on, the router will assign them a new IP. This will make consistent development a nightmare for me, because both my app and my buildscripts need to reference each of the three servers throughout their lifecycle. For instance, one server will be my Apache Ivy and Subversion repository, so my Ant buildscript will need to reference http://<build-server-ip>/svn/my-app/trunk, etc. If <build-server-ip> is constantly changing every time I bounce the server, this is going to make development very choppy and painful.

I'm wondering if these so-called "static routes" (or their likes) can help solve my problem. So I ask: is there any way to do some router magic and somehow assign a static, dedicated IP address to each server no matter how many times I power it on/off?

Specifics:

  • My router: Netgear WGR614v7
  • My servers (all 3 identical): Acer desktop running Ubuntu Server 12.04

Thanks in advance!

share|improve this question
1  
Why assign the IP in the router when you could just do it on the server? Someone who knows Ubuntu will need to provide the steps, but if you were working in a Windows world, that's what I'd do. –  N_Lindz Aug 14 '12 at 12:36
    
Thanks @N_Lindz (+1) - I'm weak on the networking side of things. You're saying that it's possible (in Windows at least) for a machine to declare its own IP address on a LAN, and for the router to honor that declaration?!? If that's the case, that's the first time I've heard of such a thing! Seems like it would introduce a security nightmare, but it's definitely worth investigating for my needs. To anyone reading this: if this is possible with Ubuntu, please let me know how! –  pnongrata Aug 14 '12 at 12:45
    
If possible, you could add static hostnames in the router and use these rather than IP addresses to reference services. –  Simon Richter Aug 14 '12 at 15:10
add comment

4 Answers

up vote 1 down vote accepted

The "router magic" you are talking about is called "reservations" - which basically allow you to tell the DHCP server running on the unit to always give a specific IP to a specific MAC address. I'm pretty sure your router has this feature.

@RedGrittyBrick is correct, but there's always a small chance something could change or screw up (i.e. what you have to reset the router, and since it's a consumer level router you will at some point) so if you want 100% reliability of knowing a specific machines IP address either set up DHCP reservations or assign the IPs manually. In "real life" servers usually are set with static IP addresses and not to get configuration information via DHCP.

Assigning an IP on the server does NOT cause the server to tell any other machine about the assignment. You'll have to document the setup manually.

"Static routes" tell your machines or router which specific "further-down" router will forward traffic to a specific set of destinations. It has nothing to do with assigning IP addresses.

share|improve this answer
    
Thanks @ultasawblade (+1) - so if I understand you correctly, first I need to get the MAC address for each machine, and then I must be able to login to the router admin web app and configure these reservations? I assume I'll need to provide an IP address and subnet mask for each? Or am I off-base here? Thanks again! –  pnongrata Aug 14 '12 at 12:59
    
You got it. You'll usually just need to specify an IP address. The router's subnet mask (typically 192.168.0.X/24 or 192.168.0.X/255.255.255.0) will be assumed and pushed to clients via DHCP. –  ultrasawblade Aug 14 '12 at 13:26
add comment

Dynamic configuration

Generally, Computers renewing DHCP leases provide the previously used address and are likely to be reallocated it.

A change of IP address shouldn't matter as long as you use DNS names, and the DHCP server is used as your local DNS server.

You can usually configure most routers to make DHCP reservations such that the same IP-address will always get allocated to each device (based on the specific MAC address burned into it's Ethernet adapter)

Static configuration

However for three or four PCs, static configuration is easily managed.

With a large number of computers it can be tedious to walk around, logon to each one, configure static IP address, subnet mask , default gateway, DNS servers or local hosts tables, and so on. Keeping track of it all requires careful record keeping, keeping lists of MAC addresses and watching out for accidental IP-address duplication, knowledge of how to recognise and diagnose misconfiguration etc. With only four computers this isn't a problem.

share|improve this answer
    
Thanks @RedGrittyBrick (+1) - a few followups: (1) I'm not planning on configuring DNS/DHCP for this local dev/test environment: this app will end up being deployed to Google App Engine so DNS is not something I need to worry about for a long while; and (2) you say that static config is easily managed with a small set of PCs: can you please elaborate on what you mean by that? Thanks again! –  pnongrata Aug 14 '12 at 12:47
    
See updated answer –  RedGrittyBrick Aug 14 '12 at 12:55
add comment

There are two basic methods for a machine to have an IP address. One is static, the other dynamic. In a static configuration I sit down at the machine and configure a static, non changing IP address (used across reboots), a subnet mask (how many IP addresses exist in THIS network), and a gateway (where do I go to exit this network). In a dynamic configuration (DHCP) I configure the router with a contiguous pool of IP addresses and a gateway and let it hand them out.

There is a hybrid third option. I configure the pool, but configure each system to have an IP address. This is referred to as static IP in a DHCP configuration. Tricky, no?

For the sake of brevity, and consistency, I would recommend a static IP set up. You will have the guarantee that IP addresses can't and won't change, and if you set up a domain controller (active directory or open directory) and choose to build a DNS server, it will work. You'll have to configure your router with the following information:

A static network: You've set the limit of your network from 5 (and if you throw on network attached storage or a printer) to < 10. How about having up to 254 hosts (individual IP addresses) just in case you think of something you want to try?

192.168.0.0 to 192.168.0.255 (192.168.0.0 will be the network address, and 192.168.0.255 will be the broadcast address, explain these later).

To tell the router we want to use this address range it has to be configured to use a 192.168.0.0 network IP address, and a subnet mask of 255.255.255.0 That last 0 gives you a range from 0 to 255 on the network IP address. So valid IP addresses IN your network will be 192.168.0.0 to 192.168.0.255 (the first three "octets" or 192 168 and 0 don't change, only the last one does). So you have a total of 2^8 IP addresses or 256 addresses (remember two out of that are already assigned the .0 and .255), so really you have 254 left.

You can use any of what's left, you don't have to use them in order. I recommend starting at 192.168.0.1 and stopping when every system has an IP address. For simplicity in your config assign the router 192.168.0.1, server A 192.168.0.2, server B 192.168.0.3, server C 192.168.0.4, and your development machine 192.168.0.5. Yes, you could reverse the order, or use only even numbers, or make them all powers of ten (.10, .20, .30, .40, .50) if you wanted to. I'm just doing simple.

Now that you have your network design, you need to configure the following on each piece of equipment:

IP address:

Subnet Mask:255.255.255.0

Gateway:For everything but the router this will be the IP address of the router, or 192.168.0.1 (for the router it is the IP address of your ISP provided). Imagine this as a static route between your network and the ISP (or whatever network you connect it to).

Some advantages of this system. By not handing out DHCP addresses a new device that is connected to your network isn't just given an IP address by default. It has to be configured. This means that it is slightly more difficult for people to attach themselves to your network without you knowing it.

Another nicety, if you configure a VPN server on the Ubuntu box, you can connect remotely. Instructions for that will not be provided here.

Also, you don't have to worry about things like MAC addresses, just IP addresses.

With all this, you should have a network. If you want to know how to configure each individual box, I'm sure google will assist you in this. Remember this is just a basic network configuration I have walked you through. No bells and whistles, this way it is easy to configure, troubleshoot, and secure as you have fewer variables to work with. Remember that under this configuration you have hard coded the IP addresses to each device. The router is just moving traffic. Any questions?

Oh, and to answer your question, yes static routes work across router reboots if they are written to a non-volatile storage device, but that is a different question than what you apparently meant to ask.

share|improve this answer
add comment

On Ubuntu Server, to set up a static IP address, you need to edit the /etc/network/interfaces file to look like this (make the address, netmask, andgateway your own of course).

auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1

Quoted from here:

To configure your system to use a static IP address assignment, add the static method to the inet address family statement for the appropriate interface in the file /etc/network/interfaces. The example below assumes you are configuring your first Ethernet interface identified as eth0. Change the address, netmask, and gateway values to meet the requirements of your network.

share|improve this answer
add comment

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.