LinuxQuestions.org
Visit Jeremy's Blog.
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 03-30-2004, 11:55 AM   #1
kreese
LQ Newbie
 
Registered: Mar 2004
Posts: 3

Rep: Reputation: 0
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.
 
Old 03-30-2004, 12:14 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
It sounds like you just need to add a route to your routing table. You can see where connections will be routed by viewing the output of:
route -n
 
Old 03-30-2004, 01:06 PM   #3
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
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.
 
Old 03-30-2004, 02:34 PM   #4
kreese
LQ Newbie
 
Registered: Mar 2004
Posts: 3

Original Poster
Rep: Reputation: 0
sorry 'bout that, bogus info in my question

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.

Thanks
 
Old 03-30-2004, 03:04 PM   #5
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
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.
 
Old 03-31-2004, 10:31 AM   #6
kreese
LQ Newbie
 
Registered: Mar 2004
Posts: 3

Original Poster
Rep: Reputation: 0
thanks, very helpful. Now a bit of routing help?

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?


Thanks a bunch for the help so far btw.
 
Old 03-31-2004, 11:09 AM   #7
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
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.
 
Old 03-31-2004, 12:04 PM   #8
tunnelit
LQ Newbie
 
Registered: Mar 2004
Posts: 9

Rep: Reputation: 0
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.

Thanks
 
Old 03-31-2004, 12:09 PM   #9
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
Tunnelit: You problem is probably the NAT part.
Your linux box will have to redirect outgoing traffic to the SNAT target of iptables.
Have a look here: http://iptables-tutorial.frozentux.n...-tutorial.html
 
Old 03-31-2004, 12:12 PM   #10
tunnelit
LQ Newbie
 
Registered: Mar 2004
Posts: 9

Rep: Reputation: 0
Thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Swapping cables to eth0 & eth1 on the same machine still works. Why? ses Linux - Networking 2 06-07-2005 01:31 AM
Wireless network on eth1 diabled Ethernet eth0 and eth0 never comes back tadatoshi Linux - Wireless Networking 4 09-23-2004 05:57 PM
Firewall WAN eth0 LAN eth1 self-bridges, eth0 does all routeing. Nichole_knc Linux - Networking 5 07-29-2004 02:33 PM
Kernel 2.4.22 finds eth0 and eth1 but 2.6.0 does not find eth1 coollink Linux - Networking 3 01-13-2004 07:32 PM
Multiple Cablenet Connections, single eth1 vinayras Linux - Networking 0 08-01-2003 11:22 AM


All times are GMT -5. The time now is 10:43 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration