0

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.

edotan
  • 1,876
  • 13
  • 39
  • 57

1 Answers1

1

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
Khaled
  • 36,533
  • 8
  • 72
  • 99
  • 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 08:11