Help - Search - Members - Calendar
Full Version: How To Set Static Ip On Linux?
Linuxhelp > Support > Technical Support
Termina
I have several computers on my LAN, and would like each to have the same IP every time they start up.

How could I do this? Thanks!
hughesjr
It depends on your distro ....

I know you use mostly debian ... and I assume you have a DHCP server and and internal IPs (10.x.x.x or 192.168.x.x).

I don't know what you are doing for the DHCP server ... but on DHCP servers, you can assign a reservation for a specific MAC address to get a specific IP address...that is one way. Here is an easier one:

In the device that controllers the IP addresses, make sure to block off a range that doesn't get assigned ... for example, if you are using the 192.168.0.0 network, 192.168.0.1 is probably your gateway ... set the dhcp range that the server will give to something like 192.168.0.21 - 192.168.0.50.

Now you can make static assignments from 192.168.0.2 - 102.168.0.20 .... and > 192.168.0.51 ... but the system can still assign from 192.168.0.21 to 192.168.0.50 to PCs using dhcp.

Make sure you exclude the static assignments from the dhcp server (as discussed in the above 2 paragraphs), otherwise if you leave any PC on DHCP, it could get assigned an address that duplicates your static address.

Now to make a static assignment (in debian), edit the file /etc/network/interfaces and remark out (put a # in front of it) the line:

iface eth0 inet dhcp

so it becomes this:

#iface eth0 inet dhcp

The add a lines like this at the bottom of the file:
CODE
iface eth0 inet static
   address 192.168.0.2
   netmask 255.255.255.0
   gateway 192.168.0.1

(substitute the address you want for 192.168.0.2 ... and the gateway)
--------------------------
In whitebox, you can use the command:

redhat-config-network
Termina
Thank you very much for answering all my questions. happy.gif
hughesjr
your welcome biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.