Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a 'one liner' for a script that needs to:

  • disable eth0.
  • make it not start on boot.
  • take away its IP address
  • ensure that it does not try to use this address again.
share|improve this question
up vote 9 down vote accepted

One liner? How about this as root?

echo "DEVICE=eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0 && service network restart

It will remove the configuration for eth0 and replace it with something that is unconfigured.

share|improve this answer
+1, beat me to the punch – MDMarra Sep 24 '10 at 21:50
what command will cause this file to be used? with out resetting the rest of the interfaces? – Arthur Ulfeldt Sep 28 '10 at 18:49
Arthur: You can do ifdown eth0 && ifup eth0 instead of service network restart to restart eth0 and not all interfaces. – Richard Holloway Sep 29 '10 at 16:08

In /etc/sysconfig/network-scripts/ifcfg-eth0 you need to change "ONBOOT=" to no and you can delete the lines for IPADDR and NETMASK.

After you copy the config file, you need to restart the network daemon.

share|improve this answer

No need to restart the network daemon, especially if you have other network cards that are in use. You can just do a 'ifdown eth0'.

share|improve this answer

Put alias eth0 off in /etc/modprobe.conf. This will make sure that nothing in the system can use it ever. It won't even be able to be brought up manually.

share|improve this answer
Thats good and harsh! nothing's coming out of that nic. – Arthur Ulfeldt Sep 27 '10 at 23:09

There is another one option for inexperienced people (like me). go at download and install webmin.

configure your server via a web based environment.

share|improve this answer
I was looking for a command that i could add to a script. – Arthur Ulfeldt Oct 13 '10 at 20:00

Your Answer


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.