Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to change my ip address and subnet mask with the following command: ifconfig eth1 192.168.1.2 netmask 255.255.255.0 up

and

route add default gw 192.168.1.1

when I reboot my linux it's gone. I would like to keep it permanent with this command. is it possible?

Thanks

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

If you don't want the sys V way, you can add

/sbin/route add default gw 192.178.1.1

to /etc/rc.d/rc.local . Although, editing the initi scripts as qweet points out is better.

share|improve this answer
add comment

The ifcfg script contains permanent details of your internet devices. You can find them in /etc/sysconfig/network-scripts/ifcfg-<devicetype><num>. There, you should alter/add the following to ifcfg-eth1:

BOOTPROTO=static
IPADDR=192.168.1.2 
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

Which should do the trick. To see the changes in effect, do a sudo /etc/init.d/network restart

share|improve this answer
add comment

maybe this link will help. static IP tutorial

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.