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 07-16-2008, 09:45 AM   #1
ddekeyser2000
LQ Newbie
 
Registered: Feb 2008
Posts: 17

Rep: Reputation: 0
DHCP Client - dual personalities


Hi all,

I have done some extensive searching on the internet for this answer but haven't been very lucky.

I have a Linux system that travels from one network to the other pretty often. Network 'A' uses 172.30.0.x and has a DHCP server running. Network 'B' uses 192.168.0.x and does NOT have a DHCP server and never will.

I would like the roaming system to be able to get a DHCP assigned address when on network 'A' but have a static IP address (in the 192.168.0.x range) when on network 'B'.

Getting the DHCP assigned IP address is not the problem. Getting the system to assign a static IP address when it doesn't get a DHCP assigned address is the problem.

Is this possible? Is there a way to use dhclient.conf to achieve this? What is the best way to do this?

Thanks in advance!
 
Old 07-16-2008, 09:58 AM   #2
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
From man dhclient.conf:

Code:
       The default statement

        default [ option declaration ] ;

       If for some option the client should use  the  value  supplied  by  the
       server, but needs to use some default value if no value was supplied by
       the server, these values can be defined in the default statement.
HTH

Forrest
 
Old 07-16-2008, 10:04 AM   #3
pruneau
Member
 
Registered: Jul 2008
Location: Montreal
Distribution: Debian/Fedora/RHEL
Posts: 45

Rep: Reputation: 15
Well, the answer to your question actually is in the dhclient.conf man page, in the alias section. You even have an example of the alias syntax at the end of the man page, so you should be all set.
Unless you already have a dhclient.conf file, simply create/append the dhclient.conf file with a single alias section, leaving all the rest as default.

The dhclient.conf file can be found on your system, or here, for example.
 
Old 07-16-2008, 10:28 AM   #4
ddekeyser2000
LQ Newbie
 
Registered: Feb 2008
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks for the quick reply to both Forrest and pruneau!

I have already tried using alias like in the man page. I don't know if I got some syntax wrong or if the problem was that I was using Fedora Core 3 and alias was something newer. Also, alias looks to me to be used for setting a second IP address on a device.

I will attempt to use the default statement and report back my results. I will also give the alias statement a second look.

Thanks again.
 
Old 07-16-2008, 12:58 PM   #5
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
Fedora Network Configuration has profiles where you can have completly different configurations, e.g., dhcp assigned address in one and static address in another.
OpenSuse has extended this to include several others configuration aspects, not only networking: YaST2/Sytem/Profile Manager.

I use in my laptop running Fedora with netowrk profiles and works just fine when I switch from home (fixed 10.x network) to my work place (dhcp address).

cheers,

PS: After profiles were created, it is just a matter of choosing the profile on "NetworkManager" icon, in "Wired Networks" section, between "System home" and "System work" to switch networks.

Last edited by marozsas; 07-16-2008 at 02:23 PM. Reason: I forgot to mention how to use after configure
 
Old 07-21-2008, 03:31 PM   #6
ddekeyser2000
LQ Newbie
 
Registered: Feb 2008
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks marozsas, but I am not using X. Is there a way to automatically select a profile without graphically selecting it using X?

My attempt at using the 'default' statement was a failure. Here are my config files:

# more dhclient.conf
interface "eth0" {
# send host-name "lpm4.precisepath.com";
send host-name "lpm4";
send dhcp-client-identifier "lpm4";
default fixed-address 192.168.0.52;
# request subnet-mask, broadcast-address, time-offset, routers,
# domain-name, domain-name-servers, host-name;
# require subnet-mask, domain-name-servers;
}

#alias {
# interface "eth0";
# fixed-address 192.168.0.52;
# option subnet-mask 255.255.255.255;
#}

# more /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
TYPE=Ethernet
#BOOTPROTO=none
#IPADDR=172.30.0.82
#GATEWAY=172.30.0.1
BOOTPROTO=dhcp
IPADDR=192.168.1.52
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
USERCTL=no
IPV6INIT=no
 
Old 07-22-2008, 06:19 AM   #7
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
I use Gnome and NetworkManager, so I never try with the command line. However, I think NetworkManager was not designed to be used in command line.

Using the tradicional style with ifup, the commands system-config-network-tui and system-config-network-cmd may help you, but I believe you have to create the profiles on graphical mode. After that you can switch networks by "system-config-network-cmd -a --profile profile_name", at least is what says the man page/on-line help. You really have to try.

good luck !

BTW: Post your finds here in this thread after you figure out how to do this....

PS: Don't forget to stop NetworkManager first. (chkconfig NetworkManager off; service NetworkManager stop) to avoid conflicts between both systems.

Last edited by marozsas; 07-22-2008 at 06:21 AM.
 
Old 07-22-2008, 07:45 AM   #8
pruneau
Member
 
Registered: Jul 2008
Location: Montreal
Distribution: Debian/Fedora/RHEL
Posts: 45

Rep: Reputation: 15
Sorry to beat on an (at least) wounded horse, but I still fail to understand why having a eth0 address with a permanent fixed configuration (i.e. as given by the alias(...) paradigm), and a dhcp one is a problem.
Of course it could cause problem if:
- you need to reach the dhcp-served network and the fixed-address network from its peer, because your routing table is going to be a problem, since it won't change
- there is a dhcp server on the network where you need to have a fixed address.
But outside those conditions, I fail to see what is wrong.
Because having a secondary IP address has been supported for a couple of years now, and is not really a problem.
But before going into full dhclient configuration mode, I would try it by hand:
- launch dhclient -d in a console with an empty configuration file
- try "ifconfig eth0 add 192.x.y.z netmask ..."
Try it on both networks to see whether it works without problems.
Then I would try to change the configuration file and see whether it works.
I personally do not like and be forced to rely on a gui to do my configuration. I also like to have a configuration that works in most environment: I'm lazy, and beside, your likely to forget that manual step whenever you are in a hurry or stressed. etc.
But, like marozsas, I would recommend you to post your findings, so other people with the same problem can benefit from your experience.
Because they are always people with the same problem.
 
  


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
Force DHCP To Refuse Clients A DHCP Lease Depending On Client MAC Address blackfish Linux - Server 3 08-17-2007 12:54 AM
DHCP server and DHCP client in same box Eicos Linux - Networking 3 03-03-2007 01:28 PM
dhcp client not getting IP from dhcp server jkmartha Linux - Networking 2 06-17-2005 08:12 AM
why DHCP client not sending own host name in DHCP request packet? sonika_singhi Linux - Networking 7 05-28-2005 05:18 AM
XP Pro Build 2600/sp1 v.1105 DHCP Client to Redhat 8.0 DHCP Server - Problems atomant Linux - Networking 5 06-28-2003 11:24 AM

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

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