Discussion Locked

Linux IP Address Change

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am trying to change the IP address of my Linux Machine, I logged onto the box and used the following command "ifconfig eth0 192.168.1.2" but each time I reboot it changes back to the old address, is there any way to make this change permenant?

7 replies

by spiceman

Do it through the GUI interface (Network Configuration) and save the changes!

Good luck

by jcmcintyre

If you are running a GUI, you can use netcfg. The netcfg utility may run directly from the command line, as root, or through the gnome control-panel utility. You may also use linuxconf. In linuxconf, go to client tasks --> Host name and IP network devices, and change teh Ip address and subnet mask for the appropirate interface.

The best way haowever, is to edit your /etc/hosts file. As root, open /etc/hosts, and enter the new hostanme and IP address for you machine. This method works on all linux systems, and no gui is required.

Jim

by joe prochazka

If you goto the following directory:
/etc/sysconfig/network-scripts/
You will see a file in there:
ifcfg-eth0

You may see some other files in there also:
ifcfg-eth0:0
ifcfg-eth0:1

ifcfg-eth0 will be the configuration file of the primary address for your network card. The other ifcfg-eth0:0, ifcfg-eth0:1, etc...
are the configuration files containing the informaion for ip aliases set for device eth0.

Now if your looking to change your primary ip address just edit ifcfg-et0 the following to suit your needs:

BROADCAST=10.0.0.255 <--Generally your ip with 255 at the end

IPADDR="166.102.18.2" <---your new ip address

NETMASK="255.255.255.0" <--Netmask if changed

NETWORK=166.102.18.0 <--Generally your ip just a zero at the end

After making the changes on this file you should everytime after reboot your system will read these files and load your new ip address.

This discussion is closed to new replies.