On Linux how can I make the IP address constant and not dynamic?

2

When I enter ifconfig command, I get inet address as 192.168.1.36 for example.

But sometimes this address changes to something like 192.168.1.34 like when linux is restarted or when the router is restarted or sometimes it changes even by itself.

This causes a lot of work for me to change again configurations in my projects that needs this IP address.

I am using Fedora 13 64bit.

My DSL Model/Router box is connected to this linux box in addition to other boxes in the local area network. This in unbranded modem/router reachable via http://192.168.1.1. I am not sure if this has anything to do with the issue in this question.

Mark

Posted 2011-06-06T08:52:06.397

Reputation: 307

1You need to configure both your router and PC for static IP addresses. There should be an option on your router. I'm not a Linux expert and you don't give your router make/model. However, unless your projects are strictly personal you'll have to make sure that they can cope with running on other machines where the IP address will be different. You should really look into modifying them so that they can auto-detect the IP address if possible. – ChrisF – 2011-06-06T09:16:18.927

Answers

3

DHCP Reservation

Set a reservation in your DHCP server (your router) based on the MAC address (Ethernet address) of the Linux computer's main Ethernet interface.

You can find your Linux PC's MAC address by opening a command shell and typing /sbin/ifconfig -a and looking for HWAddr 00:af:fa:56:ef:fe

Since your DSL-router is unbranded and unidentified we cannot tell you how to do this, you might navigate to it's configuration screen and takes some screen shots to post here (edit your answer and add them to the end).

Static IP address

Alternatively, configure a static IP-address on the Linux computer and ensure the router's configuration excludes that address from it's DHCP pool.

This also requires some configuration work on your unidentified router (see above).

On Fedora, the easiest way to set a static IP address is to use the network configuration tools. I would open a shell session and use sudo system-config-network.

See http://fedoraproject.org/wiki/F8_User_Guide_-_Configuring_Internet#Static_IP_Address

Using a static address requires that you understand how to configure a default route, and probably the DNS resolver etc. I suggest it will be much easier for you to configure a DHCP reservation in your router (if it supports it).

RedGrittyBrick

Posted 2011-06-06T08:52:06.397

Reputation: 70 632

I am new to Linux. Thanks for your answer but I am completely at a loss how to make use of your answer to solve my problem. I would like instructions like what commands to run etc. – Mark – 2011-06-06T09:37:59.047

I'll update the answer. – RedGrittyBrick – 2011-06-06T09:58:09.880