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 have 30 linux servers that I need to change subnetmask. I want to use a simple script or a simple command to change the subnemt mask from to in ifcfg-eth0.

can someone please help? Thanks, Elad.

share|improve this question
up vote 1 down vote accepted

A simple sed command like this will do it:

$ sudo sed -i 's/NETMASK=' /etc/sysconfig/network-scripts/ifcfg-eth0

You can combine this sed command with SSH command to execute this on each server using the a command like:

$ ssh user@server command
share|improve this answer
A simple for loop + SSH key-based authentication should make it automatic to change files on all machine, but you need to do another command to restart the network service for the changes to take effect. – Khaled Feb 16 '12 at 8:11

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.