Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.