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 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 255.255.255.128 to 255.255.255.0 in ifcfg-eth0.

can someone please help? Thanks, Elad.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

A simple sed command like this will do it:

$ sudo sed -i 's/NETMASK=255.255.255.0/NETMASK=255.255.255.128/' /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
1  
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
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.