LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to change the ipaddress and gateway using script? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-the-ipaddress-and-gateway-using-script-667501/)

sathyguy 09-04-2008 05:18 AM

how to change the ipaddress and gateway using script?
 
Friends,

RHEL AS 3/4

i have to connect my backup pc (RHEL AS 3) to the production server and test server very frequently(RHEL AS 4)

for that, each time i am manually opening /etc/sysconfig/network-scripts/ifcfg-eth0 and editing the below lines to and fro according to my need.

IPADDR=182.17.7.23 (this is production ip)
to
IPADDR=182.17.1.23 (this is test ip)


and the gateway...

GATEWAY=182.17.1.1 (production)
to
GATEWAY=182.17.7.1 (test)

can anybody give a solution to change it thru shell/bash script?

thanks

chrism01 09-04-2008 08:10 AM

sed -i -e 's/182.17.7.23/182.17.1.23/' /etc/sysconfig/network-scripts/ifcfg-eth0

Aboveyou 09-04-2008 12:15 PM

..
 
...thanks good to know


All times are GMT -5. The time now is 07:19 PM.