LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 10: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, 03:52 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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, 07:49 AM   #3
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 516

Rep: Reputation: 139Reputation: 139
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 mddnix; 12-14-2013 at 08:00 AM.
 
Old 12-14-2013, 09: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, 09:19 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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, 09: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, 10:11 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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, 10:44 AM   #8
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 516

Rep: Reputation: 139Reputation: 139
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:	3
Size:	145.4 KB
ID:	14211  
 
Old 12-15-2013, 06: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, 03:56 AM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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:	13
Size:	118.4 KB
ID:	14227  
 
  


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
Script for sending date and time to a user on the network Grimlox57 Programming 8 09-01-2013 11: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 04:16 AM
How to specify Network Time Protocol Server in Kickstart script? EStester Linux - Enterprise 3 03-26-2005 02:46 PM
Change parameter of /etc/sysconfig/network with a script philipina Linux - Hardware 1 03-11-2004 01:59 PM
Change parameter of /etc/sysconfig/network with a script philipina Linux - General 3 03-11-2004 06:05 AM


All times are GMT -5. The time now is 04:13 PM.

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