LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 12-13-2013, 09:18 PM   #1
albert0147
LQ Newbie
 
Registered: Oct 2013
Posts: 10

Rep: Reputation: Disabled
how to change the script at the network-script so not to waste time


Hello,
I was wondering if one can substitute quickly scripts. I am setting up a simple network and want to be able to have preconfigured scripts. For instance the /etc/sysconfig/network-scripts/ifcfg-eth0. This at the end could be changed quickly. I mean the path to the ifcfg-eth0 would maybe have another name or something. Or do I have to go in and change the vi file?
Take care,
Albert
 
Old 12-14-2013, 02:52 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
I'm not at all sure what you are asking.

- If you want/need to edit a script/file you can use vi (or any other editor you like),
- You can also use awk or sed (just 2 examples) to change a file/script (no need for an editor in this case).

Without knowing exactly what it is you want I cannot help you any further.
 
Old 12-14-2013, 06:49 AM   #3
Madhu Desai
Member
 
Registered: Mar 2013
Distribution: Rocky, Fedora, Ubuntu
Posts: 541

Rep: Reputation: 153Reputation: 153
Not sure what you want..

For example, if you want to change IP quickly, then
Code:
# ifconfig eth0 192.168.122.50 netmask 255.255.255.0 up

OR

# ip addr add 192.168.122.50/24 dev eth0
# ifup eth0
But these changes are not permanent. IP will default to the one in ifcfg-eth0 after reboot.

You can also set soft link to ifcfg-eth0 file from your home folder..
Code:
# ln -s /etc/sysconfig/network-scripts/ifcfg-eth0 eth0

# ls -l eth0
lrwxrwxrwx. 1 root root 41 Dec 14 18:18 eth0 -> /etc/sysconfig/network-scripts/ifcfg-eth0

# vi eth0
You can also try CDPATH.

Last edited by Madhu Desai; 12-14-2013 at 07:00 AM.
 
Old 12-14-2013, 08:03 AM   #4
albert0147
LQ Newbie
 
Registered: Oct 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thanks,
I guess one can not swap out the ifcfg-eth0 file with another...say ifcfg-eth02 or any other name. I guess the permanent change is not that important for the ip address because it can be change quickly as noted.
Thanks again,
Albert
 
Old 12-14-2013, 08:19 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by albert0147 View Post
I guess one can not swap out the ifcfg-eth0 file with another...say ifcfg-eth02 or any other name. I guess the permanent change is not that important for the ip address because it can be change quickly as noted.
There's a little bit more info in your reply.

Is this what you want: Have multiple ifcfg-eth0 files, each with their own unique properties inside?

If that is the case: The scripts that control bringing up the network devices look for a specific name pattern, if you use a different name it will not be used. Example ifcfg-eth0 will be used, _ifcfg-eth0 will not be used.

In the /etc/sysconfig/network-scripts/ directory you can create files like this:
_ifcfg-eth0.cfg1
_ifcfg-eth0.cfg2
_ifcfg-eth0.cfg3
etc.

The only thing you now need to to is to copy (not move) the correct file to the name that will be used:
Code:
cp _ifcfg-eth0.cfg2 ifcfg-eth0
Restart the network and cfg2 will be used.
 
Old 12-14-2013, 08:30 AM   #6
albert0147
LQ Newbie
 
Registered: Oct 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Yes perfect.
Got it.
Thanks, I need to improve my question asking abilities.
Cheers,
Albert
 
Old 12-14-2013, 09:11 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome.

BTW: Can you put up the [SOLVED] tag.
- above the first post -> Please Mark this thread as solved if you feel a solution has been provided.
- -or- -
- first post -> Thread Tools -> Mark this thread as solved
 
Old 12-14-2013, 09:44 AM   #8
Madhu Desai
Member
 
Registered: Mar 2013
Distribution: Rocky, Fedora, Ubuntu
Posts: 541

Rep: Reputation: 153Reputation: 153
Quote:
Originally Posted by albert0147 View Post
I guess one can not swap out the ifcfg-eth0 file with another...say ifcfg-eth02 or any other name.
Is this you want... Here, for example i have changed eth0 interface to bart-simpson

Code:
# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. 1 root root 192 Dec 14 20:40 /etc/sysconfig/network-scripts/ifcfg-bart-simpson
-rw-r--r--. 1 root root 254 Dec 14 21:00 /etc/sysconfig/network-scripts/ifcfg-lo

# ifconfig bart-simpson
bart-simpson Link encap:Ethernet  HWaddr 52:54:00:73:0F:F5  
          inet addr:192.168.122.204  Bcast:192.168.122.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe73:ff5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:309 errors:0 dropped:0 overruns:0 frame:0
          TX packets:137 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:34208 (33.4 KiB)  TX bytes:16876 (16.4 KiB)

# ifdown bart-simpson

# ifup bart-simpson
Determining IP information for bart-simpson... done.
Attached Thumbnails
Click image for larger version

Name:	Screenshot.png
Views:	8
Size:	145.4 KB
ID:	14211  
 
Old 12-15-2013, 05:16 PM   #9
albert0147
LQ Newbie
 
Registered: Oct 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Druuna,
I can not find that [solved]
Albert
 
Old 12-16-2013, 02:56 AM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by albert0147 View Post
Druuna,
I can not find that [solved]
Albert
Have a look at the attached screenshot.
Attached Thumbnails
Click image for larger version

Name:	solved.png
Views:	22
Size:	118.4 KB
ID:	14227  
 
  


Reply



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
Script for sending date and time to a user on the network Grimlox57 Programming 8 09-01-2013 10:42 PM
Each time a script is called. A log file is created with time and date + Bash Script. y0_gesh Programming 6 08-17-2012 03:16 AM
How to specify Network Time Protocol Server in Kickstart script? EStester Linux - Enterprise 3 03-26-2005 01:46 PM
Change parameter of /etc/sysconfig/network with a script philipina Linux - Hardware 1 03-11-2004 12:59 PM
Change parameter of /etc/sysconfig/network with a script philipina Linux - General 3 03-11-2004 05:05 AM

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

All times are GMT -5. The time now is 09:41 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