LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-04-2008, 06:18 AM   #1
sathyguy
Member
 
Registered: Sep 2005
Location: Indian Working in Saudi Arabia
Distribution: Redhat Linux AS 3.0
Posts: 93

Rep: Reputation: 15
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
 
Old 09-04-2008, 09:10 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
sed -i -e 's/182.17.7.23/182.17.1.23/' /etc/sysconfig/network-scripts/ifcfg-eth0
 
Old 09-04-2008, 01:15 PM   #3
Aboveyou
LQ Newbie
 
Registered: Sep 2008
Posts: 2

Rep: Reputation: 0
..

...thanks good to know
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot change gateway on two different interfaces? Risc91 AIX 4 07-03-2007 04:14 PM
script to mail ipaddress aeby Linux - Networking 1 05-07-2007 08:47 AM
How to change the ipaddress,hostname,mac number in Fedora 6 from Terminal me4linux Linux - Networking 1 03-24-2007 07:34 AM
How do I change the gateway? bamsesbilledbog Linux - Networking 1 07-05-2006 01:59 PM
Cannot change default gateway parr Linux - Networking 22 07-31-2003 07:13 PM


All times are GMT -5. The time now is 09:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration