LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   change ip by command line (https://www.linuxquestions.org/questions/linux-networking-3/change-ip-by-command-line-469103/)

noorudin 07-30-2006 08:52 AM

change ip by command line
 
I am using suse 10.1 with static ip address 192.168.40.100.
And I want to change ip by command line permanently.How can I do?

jschiwal 07-30-2006 09:57 AM

Which distro are you using? See if you have a /etc/sysconfig/network/ifcfg-eth0 file. You need to su to root to edit it. ( Note: I'm guessing that your interface is named eth0 )

Change the IP address listed after "IPADDR=".
Quote:

from the ifcfg.template file:
# If using a static configuration you have to set an IP address and a netmask
# or prefix length. The following examples are equivalent:
# 1) IPADDR=192.168.1.1
# NETMASK=255.255.255.0
# 2) IPADDR=192.168.1.1
# PREFIXLEN=24 # NETMASK will be ignored
# 3) IPADDR=192.168.1.1/24 # NETMASK and PREFIXLEN will be ignored

crep 07-31-2006 10:53 AM

/sbin/ifconfig eth0 new.ip.goes.here

this will only change it for the time being, at reboot it gets reset to the ip in sysconfig/ifcfg-eth0 (above)

sudipta_cht 08-31-2006 07:19 PM

Hi,

Can someone help me and tell me how to implement this on Ubuntu? I have been taking a look at /etc/sysctl.conf, /etc/init.d/networking and the different files in /etc/network but I haven't yet been able to figure out how to do this permanently.

Thanks a lot
Sudipta

crep 08-31-2006 10:14 PM

can't tell you exactly where it is, but likely in /etc/sysconfig/network-scripts there will be a file ifcfg-eth0.

Edit that file to the new ip. If you need details on how to do it, post that file here and I'll help you.

sudipta_cht 09-07-2006 05:29 PM

Umm.. nothing like /etc/sysconfig in Ubuntu. Any pointers to what the equivalent of that directory is in Ubuntu?

crep 09-07-2006 05:44 PM

as root do: updatedb
then do: locate ifcfg

so edit ifcfg-eth0 (post it if you still need help)

sudipta_cht 09-07-2006 06:11 PM

Quote:

Originally Posted by crep
as root do: updatedb
then do: locate ifcfg

so edit ifcfg-eth0 (post it if you still need help)

Crep, hey!

Thanks for the help. Even after the updatedb nothing was found: even tried a find . -name and left it for 2 hours to come back with no such file.

However, I found what I was looking for: as it turns out, Ubuntu systems use /etc/network/interfaces to maintain ip addresses and all, and so I edited that file manually and could get the system to change its ip address. :)

Thanks for all the help, though: I appreciate

crep 09-07-2006 06:13 PM

glad you got it :)


All times are GMT -5. The time now is 05:31 PM.