Results 1 to 9 of 9

Thread: Changing ip through ifconfig

  1. #1

    Changing ip through ifconfig

    Hi,

    I am using Fedora 5. I have to change my nic address quite regularly from office/home...
    So I decided to write a script which will speed up the process.

    if [ $1 == 1 ]
    then /sbin/ifconfig eth0 192.168.0.2 netmask 255.255.255.0 up
    else /sbin/ifconfig eth0 *.*.*.* netmask 255.255.255.0 up
    fi
    exit 0

    Only problem is - if I restart the lan connectivity the settings revert to what was originally set by using fedora network configuration gui.
    /sbin/service network restart

    How can I make the change more permanent.

    Sorry if this is not the correct place to ask this question. But any help will be most welcome.

    Regards

  2. #2
    The network configuration files are stored in the
    Code:
    /etc/sysconfig/network-scripts
    directory. The file for eth0 is
    Code:
    /etc/sysconfig/network-scripts/ifcfg-eth0
    You may want to create two copies of the file for each scenario

    Code:
    /etc/sysconfig/network-scripts/home.ifcfg-eth0
    /etc/sysconfig/network-scripts/work.ifcfg-eth0
    and use your script to overwrite /etc/sysconfig/network-scripts/ifcfg-eth0 which is read on startup.

    Make sure the 2 base filenames don't start with the string "ifcfg", because I think the startup script checks for this prefix in configuring interfaces.

  3. #3

    Thumbs up Thanks

    Thanks for the prompt reply.

    This sure shud work. I will try it right away.

    Regards

  4. #4
    Just one little problem.

    I found -

    /etc/sysconfig/network-scripts/ifcfg-eth0
    /etc/sysconfig/networking/devices/ifcfg-eth0
    /etc/sysconfig/networking/profiles/default/ifcfg-eth0

    And they are all the same
    I am going to do some trial and error and find out which one/s is/are needed.

    Regards

  5. #5
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935
    They are the same file but just alias.
    LinuxVillage - The truely community run Linux/Floss forum !

    No IT BS !!

  6. #6
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935
    I got this from here. Hope this helps.

    Code:
    RED-HAT 9.0 and later
    -----------
    		(Cut'n'pasted from Dax Kelson web page)
    	http://www.gurulabs.com/RedHatLinux9-review.html
    
    	A little known fact is that newer versions of RHL support
    multiple network profiles. This is useful for machines that commonly
    plug into different networks (think laptops). The easy way to create
    network profiles is to use the redhat-config-network command. The
    question then becomes, what happens when you type "ifup eth0"? The
    behavior wasn't defined in previous versions, however, now in RHL 9
    the following behavior is defined;
    
    	search path for:
    # ifup $DEV
    	is:
    /etc/sysconfig/networking/profiles/$CURRENT_PROFILE/ifcfg-$DEV
    /etc/sysconfig/networking/profiles/default/ifcfg-$DEV
    /etc/sysconfig/network-scripts/ifcfg-$DEV
    
    	A cool trick is to boot your RHL box directly into a profile
    from the GRUB boot screen. To do this, create a separate
    /etc/boot/grub.conf entry for each network profile, and in each entry
    add the kernel argument netprofile=profilename.
    LinuxVillage - The truely community run Linux/Floss forum !

    No IT BS !!

  7. #7
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935
    Quote Originally Posted by gugabaga View Post
    Mods - can the thread title be changed? I think the present title is no longer appropiate.
    The more prefer route is to create another post with the appropiate discussion. If we just change it to the latter subject matter, then the first one is inappropiate for the discussion. We can separate posts and sprawn off the thread.
    Last edited by Compunuts; 11-19-2006 at 04:37 AM.
    LinuxVillage - The truely community run Linux/Floss forum !

    No IT BS !!

  8. #8
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935
    The discussion had been span off to this thread on Networking forum. Please continue there.
    LinuxVillage - The truely community run Linux/Floss forum !

    No IT BS !!

  9. #9
    Administrator Advisor peter's Avatar
    Join Date
    Apr 2004
    Posts
    882
    Closing the thread. Please follow the link to the new location.

    Thanks Compunuts.

Similar Threads

  1. ifconfig command does not exist
    By omnivore in forum Linux - General Topics
    Replies: 3
    Last Post: 01-20-2005, 02:44 AM
  2. ifconfig
    By lovswr1 in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 09-21-2002, 02:38 AM
  3. ifconfig
    By lovswr1 in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 09-06-2002, 03:13 PM
  4. OpenBSD ifconfig
    By in forum BSD
    Replies: 3
    Last Post: 04-14-2002, 07:29 PM
  5. Once again Help with IFCONFIG
    By Rastar in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 01-30-2002, 01:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •