• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 407
  • Last Modified:

Changing IpAddresses

I was given a new ipaddress for my server, but I do not know how to change it.  Does anyone know how I can do this?

Thanks!

Randy
0
rjohnsonjr
Asked:
rjohnsonjr
  • 3
  • 2
  • 2
  • +2
1 Solution
 
pjedmondCommented:
Hmm - for this type of question, it does help if you give details of distributio/version/interface being used, as there are a number of subtle variations, and differrent sets of tools available. I'll give the generic solution in order to do this from a text file.

The file you need to edit on many of the mainstream distributions is:

/etc/sysconfig/network-scripts/ifcfg-eth0

for eth0 - obviously there may be additional files eth1 etc for other interfaces.

It will look something like this:
-------------------------8X--------------------------
BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth0
MTU=""
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
IPADDR=192.168.1.101
NETWORK=192.168.1.0
ONBOOT=yes

-------------------------8X--------------------------
Obviously, you change the IPADDR entry to your new allocated IP address. You then need to restart the interface (or restart the PC if you want)

Note - if your server is configured using DHCP, then you don't need to do anything - the change will be automatic next time you reboot.

If you have problems with this, provide the output from:

ifconfig

and the content of the aforementioned file, your old ip and the new ip, and we can provide you with a more thorough set of instructions.

HTH:)
0
 
manav_mathurCommented:
assuming the interface device you want to use is eth0
ifconfig eth0
will show you the existing inet_addr. let us suppose it is 1.2.3.4 and new one to be assigned is 5.6.7.8

ifconfig eth0 down  ##thats because Im not sure whther IP addresses can be changed on the fly
ifconfig eth0 del 1.2.3.4
ifconfig eth0 add 5.6.7.8
ifconfig eth0 up   ##for bringing up the interface back again
0
 
wesly_chenCommented:
Hi,

  Which Linux do you have? If your server is not Debian, then pjedmond's suggestion will do.
Here is another simply command that you can change your IP address (as root)
/usr/sbin/netconfig
which will bring the text mode table for your to enter IP address, netmask and the default gateway.
It will reflect the change to file /etc/sysconfig/network-scripts/ifcfg-ethX.
After the change, just run
/etc/init.d/network restart
to take effect.

Regards,

Wesly

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rjohnsonjrAuthor Commented:
it is redhat 9

I have an eth0  and an eth0:1


Randy
0
 
manav_mathurCommented:
eth0:1 is your virtual interface. Which interface do you want to get the ip changed for??
0
 
rjohnsonjrAuthor Commented:
Both of them actually.


Randy
0
 
manav_mathurCommented:
Randy,
- What class network does this server serve??

ifconfig eth0 your.valid.ip.address

will do the job for you. however, you will need to change all your subnet ,achines to have this ip address as the default gateway. Also, the use of a virtual network suggests you are using IP masquerade possibly??

Manav
0
 
wesly_chenCommented:
For eth0
edit
/etc/sysconfig/network-scripts/ifcfg-eth0

For eth0:1
edit
/etc/sysconfig/network-scripts/ifcfg-eth0:1

You can also use the RedHat configuration tool
/usr/sbin/redhat-config-network

Then do
service network restart
to take effect.
This way your setting will keep after reboot. The change via ifconfig won't keep after reboot.
0
 
hexfusionCommented:
Opps did you forget your hosts file

make sure to edit
/etc/hosts
 to reflect you change

Also don't forget to change the ip address in other applicable areas example apache config.

edit
/etc/httpd/conf/httpd.conf

Did your dns servers change?
edit
/etc/resolv.conf

good luck
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now