Two network interfaces - how do I change the primary one?
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.
Two network interfaces - how do I change the primary one?
I am running Centos 5.1 on a box with two network cards each connected to different networks. After booting, the wrong network card (eth1) is the primary interface (the last one to be activated, presumably). How do I get Centos to choose the other one?
Adding a couple of lines to /etc/rc.local works:
ifdown eth0
ifup eth0
... but that just does not seem like the proper way to do this.
Oh, and I'm not looking for "why don't you just switch the network cables?" ... that would work, but I've got reasons for not wanting to do that. I want eth0 to be the primary interface.
I guess I'm curious as to what you need from a "primary" interface.
From a routing point of view, your primary interface is the one that your default route will go out, and your secondary interface will support other routes that might be faster, and those routes are set specifically.
I should point out that it's a bit of a no-no for a host to have two live interfaces (see "multihoming"). However, in your case, I'm assuming that one network is the open world, and the other is some closed link (logically or physically...).
After all that babbling, I would play around with the routing table.
eth0 is the WAN (open world). eth1 is a local network. I can access the box from both sides just fine. However, DNS requests, for example, are being sent via eth1. I want them to go out on eth0.
haha. Well, after saying i didn't want to hear "why don't you just switch the network cables?" ... that's exactly what I did. I won't give the details, but it meant I had a few other minor hoops to jump through on my particular setup, but it all took about 10 minutes. Problem solved. Now I simply have the WAN on eth1.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.