LinuxQuestions.org
Review your favorite Linux distribution.
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 09-05-2011, 06:17 AM   #1
thehadar
LQ Newbie
 
Registered: Aug 2011
Posts: 18

Rep: Reputation: Disabled
Obtaining static IP while in DHCP


Hi guys,
My interface is set to DHCP -

# cat /etc/network/interfaces
# Configure Loopback
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
up route add -net 224.0.0.0 netmask 240.0.0.0 eth0


Is there a way to configure Linux to use a static IP incase no dhcp server is found? (and continue searching for a dhcp server every timeout inorder to get back to "dhcp mode" when a suited server is found)

I beleive that this is what Windows does.

Thanks!
Hadar
 
Old 09-05-2011, 03:29 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,976

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Assign a secondary ip or use a zero config, in some cases a hosts file or other file to use depending on the service needed.

http://www.practicallynetworked.com/..._and_linux.htm

The problem is still the dhcp is out. That should be fixed.
 
Old 09-05-2011, 03:56 PM   #3
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
If you are using dhclient you can also write a script in "/etc/dhcp/dhclient-exit-hooks.d" and check for operation FAIL or TIMEOUT, then configure static IP. Read "man dhclient-script" for more info.
 
  


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
Setting a static IP address, but dynamically obtaining DNS config from a router bgoodr Linux - Hardware 3 09-28-2008 12:33 PM
obtaining DNS from DHCP mohtasham1983 Linux - Networking 3 12-24-2005 07:44 PM
Eth0 set up for Static, obtaining DHCP address?! IndustrialGeek Linux - Networking 2 01-03-2005 12:39 AM
dhcp not obtaining lease on Slackware 10 juxstapose Linux - Networking 2 07-23-2004 07:04 PM
Obtaining an IP through DHCP orange400 Linux - General 1 06-09-2004 03:05 PM

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

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