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, 05: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, 08:10 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748
sed -i -e 's/182.17.7.23/182.17.1.23/' /etc/sysconfig/network-scripts/ifcfg-eth0
 
Old 09-04-2008, 12: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 03:14 PM
script to mail ipaddress aeby Linux - Networking 1 05-07-2007 07:47 AM
How to change the ipaddress,hostname,mac number in Fedora 6 from Terminal me4linux Linux - Networking 1 03-24-2007 06:34 AM
How do I change the gateway? bamsesbilledbog Linux - Networking 1 07-05-2006 12:59 PM
Cannot change default gateway parr Linux - Networking 22 07-31-2003 06:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03: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
Open Source Consulting | Domain Registration