LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-28-2003, 05:43 PM   #1
joeljensen
LQ Newbie
 
Registered: Jul 2002
Posts: 20

Rep: Reputation: 0
Exclamation Dynamic DHCP or static IP


Boy does this sound strange.

For my network at work, I have to have a static IP address assigned to my RH8.0 laptop. This is required because of the network arrangement.

I want to have the ability of deciding whether to use the static IP or DHCP on boot. This would allow me to hook up to other DHCP networks.

Could this be done? I was thinking maybe with having a specific run-level that sets up DHCP while the rest use static IP.

Any ideas?

I have no problem having to select the run-level at startup.


Thanks
 
Old 03-28-2003, 06:52 PM   #2
Texicle
Member
 
Registered: Oct 2002
Location: Northern Ontario, Canada
Distribution: Slackware 10.0
Posts: 789

Rep: Reputation: 30
Your ISP will determine whether you get dynamic or static IP. Most times static IPs are assigned to business accounts while dynamic IPs are usually given to residential (at least with my cable internet company). I don't think you'll be able to control that beyond selecting whether you want a business or residential account. If I'm wrong, someone please correct me. Hope this helps.
 
Old 03-28-2003, 08:12 PM   #3
joeljensen
LQ Newbie
 
Registered: Jul 2002
Posts: 20

Original Poster
Rep: Reputation: 0
At work, the IP is assigned. Elsewhere, it will be DHCP.
 
Old 03-28-2003, 09:26 PM   #4
twolf
LQ Newbie
 
Registered: Mar 2003
Location: CZ/USA
Posts: 24

Rep: Reputation: 15
what about a shell script?

I believe that it would be possible to make it work through a shell script that would give you an option to run one of two (or more) options.
ie.: press 1 to DHCP
press 2 to staticIP

Would that be a sollution? I don't know if there is a way of setting up profiles... But if the script would help -- let me know and I'll produce it and send it... (hoping that your shell is BASH and the 'ifconfig' runs smoothly + your network interface is Eth0).

Let me know -- Tomas
 
Old 03-29-2003, 05:18 AM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
I think twolf is right - get a script that copies either "eth0.static" or "eth0.dhcp" to "ifcfg-eth0" then restarts networking.
 
Old 03-31-2003, 11:35 AM   #6
joeljensen
LQ Newbie
 
Registered: Jul 2002
Posts: 20

Original Poster
Rep: Reputation: 0
Twolf. I think you have a successfull idea. I have already setup run-level 5 as the network at work, run-level 4 as no network, and I could use run-level 2 for other networks.

If you already have a script to do this, maybe other would benifit from seeing it also.

Thank you very much.
 
Old 03-31-2003, 12:02 PM   #7
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
This isn't very advanced but it should work OK. Just create 2 files "eth0.dhcp" "eth0.static" and put the relevant details in each. Put this script a startup folder or run it manually. (you will need to create a seperate one for static ip's - just change "eth0.dhcp" to "eth0.static")
Code:
#!/bin/bash

echo Changing to DHCP config.
rm -f /etc/sysconfig/network-scripts/ifcfg-eth0
cp /etc/sysconfig/network-scripts/eth0.dhcp /etc/sysconfig/network-scripts/ifcfg-eth0

echo Stopping eth0.
ifdown eth0

echo Starting eth0.
ifup eth0
 
Old 04-01-2003, 01:50 PM   #8
joeljensen
LQ Newbie
 
Registered: Jul 2002
Posts: 20

Original Poster
Rep: Reputation: 0
Works like a charm. Thank you.
 
  


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
Dynamic IP to Static Temujin_12 *BSD 2 06-10-2005 04:58 PM
FC2 Overriding static if in favor of dhcp system set for static pkraus109 Linux - Networking 8 09-21-2004 11:13 AM
Static vs Dynamic Big Al Linux - Networking 2 12-08-2003 03:10 PM
Connect static and dynamic DHCP with VLANs FatMike Linux - Software 0 11-12-2003 07:08 AM
DNS, NIS, Static <-> Dynamic DHCP, Proxy bjc Linux - Networking 5 11-12-2000 05:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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