eth1 added, mysql connections FROM this machine are from eth1. Need bound to eth0???
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.
eth1 added, mysql connections FROM this machine are from eth1. Need bound to eth0???
I configured a second network card associated with a different host name on server_1. This server runs apache, php, mysql and postfix and sends mail triggered by php scripts. I added eth1 to allow me to send some mail out on eth1 which is on a different network. I am running a second instance of postfix and all seems well there (mail sent from a php script can be sent out through eth1 onto the new network).
However, when eth1 is configured, php scripts connecting to a remote database are failing. The firewall on the database server is rejecting the mysql connection because the connection now comes from the new IP on eth1. I have added the bind-address command in the my.cnf but that does not seem to affect the interface that the client uses. I am thinking now that that configuration parameter just binds the mysql server to that IP.
I can certainly allow the new IP in the database server's firewall and set it up in mysql access tables to allow connections from this new host. But I would prefer to CONTROL this stuff. What can I do to force a mysql connection made in php to utilize a specific interface?
Also, I posted this in the networking area because while this is the only problem I have spotted so far, that doesn't mean I have set this second interface up correctly.
I am running redhat 7.3. I set up eth1, added the new IP and hostname into the hosts file, restarted networking. What else do I need to do or check?
I would prefer that the ONLY thing that utilizes eth1 be my second instance of postfix. I can prevent intrusion in the firewall, but what other things should I be looking for on my server to bind to eth0? Any tips there would be appreciated also.
If eth1 really is on another network there should be no problem. I agree with David_ross that this seems like a routing problem.
Your computer should use the IP address of the interface that the packet leaves the computer through as source IP for the packet. Your MySQL server should not see the other network, provided it's separate.
Please post the result of route -n along with your network setup, which networks are LAN and which are internet.
Oops, getting ahead of myself. Same network at the moment. I wanted to make sure I could get the various programs communicating through the proper interfaces before having the new network set up. I still might run this as set up now where this is just another IP and another hostname.
Same network, different IP would have been the accurate way to ask the question. So is this still a routing thing or a program configuration issue or an eth1 config issue?
I googled and I can't find anywhere that mysql client IP binding is discussed. I am getting into some of these areas for the first time, so I don't know much about this stuff. If an app, like the mysql client, has no configuration option for binding to an interface or IP or host, how is that type of thing controlled in redhat? Seems there would be a way to force mysql connections to utilize a specific interface when connecting to a remote mysql server? With only eth0 configured, mysql client uses eth0, but with eth1 configured it uses eth1 every time I have tried it so far.
I recently read about a problem in the linux kernel when using two NIC's on the same physical connection.
The issue was that when trying to determine the MAC addresses for the cards linux would only answer for one of the NIC's. There where a patch out for some of the older kernels.
I don't know if this patch have been merged with the recent kernels.
If you get both NIC's working then, yes it is still a routing problem as far as I can see. You need to tell which of the two NIC's that linux should use for outgoing traffic.
List the routing table route -n
the first appropriate entry would be use. That is the most precise entry.
Thanks, that appears to have been the problem. I set the routing back up the way it should have been with the single interface, but the stuff going out to the network was set for device eth1 which was what I was observing. The current routing info is:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
66.129.100.176 0.0.0.0 255.255.255.240 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 66.129.100.177 0.0.0.0 UG 0 0 0 eth0
Does the above mean:
1. data for IPs on my network segment go out eth0
2. localhost stuff uses loopback
3. anything else goes out the gateway on eth0 out to the internet
???
If that is correct?
How do I add another 0.0.0.0 destination for eth1?
I think my ignorance had me asking the wrong questions perhaps. If I understand the above OK, then I see how I can force the database queries to use a specific interface (eth0 as I had asked) because the database server is on my segment. In fact the current configuration should do that. My ultimate goal however is to send out mail on two different interfaces (where I control which) and ALL other activity local and otherwise happens on eth0. I have 2 instances of postfix set up each sending through a different host and IP. If postfix knows to send out through the IP for eth1, does this work even with the above config? Or does routing have to include some rule to allow packets to go out eth1?
Your conclusions 1 to 3 are correct.
You can only have one default gateway, or else it wouldnät be default.
In your case you donät want a second default gateway.
Incoming traffic will be directed to eth0 and eth1 respectively depending on the destination IP used.
As for the outgoing traffic all traffic not specifically directed elsewhere will use the default gateway in an effort to resolve the final destination.
The routing table only lists the adjacent networks, that means the networks you are directly connected to. In your case only one, your LAN.
One possible way to direct your outgoing mail traffic on the eth1 interface would be to make a iptables rule matching all outgoing mail traffic to the eth1 interface. Haven't tried it my self.
Hey I think what you all are talking about might be what's wrong with my network. I made a post about it called RedHat9.0/WinXPPro Network. Anyways, I have eth0 and eth1 on the linux box, eth0 for internet connection and eth1 for local net. Eth1 runs to a switch and then the switch runs to my Win box. My Win box doesn't have internet though, I'm assuming the Linux box doesn't know where to route the info when it recieves it from the Win box.
Anyways, here is the results I get from route -n.....
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
24.210.176.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 24.210.176.1 0.0.0.0 UG 0 0 0 eth0
Any idea what's going on? If you have any questions just ask.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.