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 need to create a shell script the gets as first parameter a subnet mask and as the second paramater a GW address.

something like this: "replace_IPs.sh 255.255.0.0. 10.0.0.254" by running this line I will be able to put the new subnet mask and DW.

Thanks.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

You have ifconfig for that?

ifconfig eth0 192.168.0.1 netmask 255.255.255.0 gateway 192.168.0.254

share|improve this answer
    
how do I put it in a script to receive argument of 192.168.0.1 and 255.255.255.0? –  edotan Mar 13 '12 at 12:29
    
To just echo what's currently set you could use grep/awk and the like to parse the output of ifconfig, for example ifconfig eth0 | grep "inet addr:"|awk '{print $2}' or if installed you could also use ifdata. ifdata -pa eth0 for IP address ifdata -pn eth0 for netmask. –  duenni Mar 13 '12 at 12:52
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.