Link to home
Start Free TrialLog in
Avatar of Koolandrew
Koolandrew

asked on

HOw do i change the ip address using command line

i need to change teh ip address from 64.34.228.250 to 64.34.135.56.

I used the command

ifconfig net0 64.34.135.56 netmask 255.255.255.240 (with and without up) and it would work but when i rebooted the old ip came back.

Please help, and it keep very simple as i am a novice with no training in linux.
Avatar of cbmm
cbmm
Flag of United States of America image

what flavor of linux?
Avatar of almilyo
almilyo

try using /usr/sbin/system-config-network
the command you are using to change the ip address is only temporarily
Sorry, didn't explain that very well, system-config-network has a gui that works in the console and lets you save changes to the network configuratrion, which is stored in /etc/sysconfig.

It's pretty intuitive to use
Avatar of Koolandrew

ASKER

i am using centos 4.5
please help with a step by step solution

edit etc/sysconfig/network/<interfacename>
i somehow muddled my way through it. Could someone please tell me how to add a second ip.

I used ifconfig eth0:1 64.34.135.54 netmask 255.255.255.240 but it didnt work.

thanks
Create this file
/etc/sysconfig/network-scripts/ifcfg-eth0:1
Edit the file with whatever program you wish (nano, vi)
Here are the settings:
DEVICE=eth0:1
  BOOTPROTO=static
  BROADCAST=69.34.135.63
  IPADDR=69.34.135.54
  NETMASK=255.255.255.240
  ONBOOT=yes

You should also have a file
/etc/sysconfig/network-scripts/ifcfg-eth0
This file should be set with your first IP address info

what does that mean, create this file.

I am linux newbie. I copied and pasted and got the following. Please provide more details..


[root@localhost ~]# /etc/sysconfig/network-scripts/ifcfg-eth0:1
-bash: /etc/sysconfig/network-scripts/ifcfg-eth0:1: No such file or directory
[root@localhost ~]# ifconfg
-bash: ifconfg: command not found
[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:09:6B:A3:7B:D3  
          inet addr:64.34.135.56  Bcast:64.34.135.63  Mask:255.255.255.240
          inet6 addr: fe80::209:6bff:fea3:7bd3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5377 errors:0 dropped:0 overruns:0 frame:0
          TX packets:487 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:463579 (452.7 KiB)  TX bytes:204637 (199.8 KiB)
          Interrupt:185

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:14479 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14479 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1131736 (1.0 MiB)  TX bytes:1131736 (1.0 MiB)

[root@localhost ~]#
try this
nano /etc/sysconfig/network-scripts/ifcfg-eth0:1
if this command fails try
vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
This should allow you to start editing the new file.
i did as you suggested with vi

this is the file i input and below is the result

DEVICE=eth0:1
  BOOTPROTO=static
  BROADCAST=64.34.135.63
  IPADDR=64.34.135.54
  NETMASK=255.255.255.240
  ONBOOT=yes


ifconfig
eth0      Link encap:Ethernet  HWaddr 00:09:6B:A3:7B:D3  
          inet addr:64.34.135.56  Bcast:64.34.135.63  Mask:255.255.255.240
          inet6 addr: fe80::209:6bff:fea3:7bd3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15697 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1135 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1309670 (1.2 MiB)  TX bytes:429102 (419.0 KiB)
          Interrupt:185

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:38929 errors:0 dropped:0 overruns:0 frame:0
          TX packets:38929 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2961572 (2.8 MiB)  TX bytes:2961572 (2.8 MiB)
Sorry, did i need to reboot?
I was just goint to ask that..
BTW, if you hate how VI works (as I do),  install NANO.  This program will work a lot like most windows based txt editors.
/etc/init.d/network restart
Run this to restart the network services
i think i did it, thanks
ASKER CERTIFIED SOLUTION
Avatar of cycle303
cycle303

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial