LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-24-2016, 01:14 PM   #1
gda
Member
 
Registered: Oct 2015
Posts: 130

Rep: Reputation: 27
Strange ethernet interface/iptable problem on Slackware 14.1


Hi all!

I have a quite strange problem on one of my linux servers running Slackware 14.1 64 bit.

Actually the server runs on a vmware virtual machine which has attached 4 different virtual ethernet interfaces. All these 4 interfaces are connected to the same physical interface via a vmware virtual switch (actually the virtal switch just bridge the interfaces).

Moreover I have iptables running as firewall filtering different type of incoming packets on the base of destination IP, destination interface and destination port.

In general this configuration seems to work perfectly but sometimes (apparently randomly and rarely) it happens that iptable drops connections that should be allowed because the interface names are somehow mixed up. In particular according to ifconfig I have the following situation:

eth0 --> XXX.XXX.XXX.2
eth1 --> XXX.XXX.XXX.3
eth2 --> XXX.XXX.XXX.4
eth3 --> XXX.XXX.XXX.5

To allow ssh connection only on IP:XXX.XXX.XXX.2 on port 22 and on the interface eth0 I have the iptable rule like:

iptables -A INPUT -p tcp -s IP_SOURCE -d XXX.XXX.XXX.2 --dport 22 -i eth0 -j ACCEPT

where IP_SOURCE is the ip address I want to allow to connect to the server.

Similarly, I have other rules allowing http connection on the other interfaces and IPs.

As already mentioned, this configuration works in general well but sometimes it happens that iptable drops for example ssh connection because apparently they have the correct destination IP and port but the wrong destination interface.
For example if I try to connect to the server from an allowed IP via ssh, my connection gets dropped and in the iptable log file I found:

Mar 24 13:20:36 xxxxxxxxx kernel: [2682350.220828] IPTables- DROPPED INPUT: IN=eth3 OUT= MAC=XXXXXX SRC=YYY.YYY.YYY.YYY DST=XXX.XXX.XXX.2 LEN=60 TOS=0x00 PREC=0x00 TTL=62 ID=22947 DF PROTO=TCP SPT=55423 DPT=22 WINDOW=29200 RES=0x00 SYN URGP=0

where YYY.YYY.YYY.YYY is the IP from which I'm trying to connect to the server.
As you can see, for some reason, iptables seems the connection directed to the right IP but to the WRONG interface (eth3 instead of eth0) and so the connection is dropped.

This happens also for http connections.

If, in this condition, I reboot the server everything works again perfectly (it means I'm able to connect from the same IP that before was dropped without changing anything in both the server and the client).

The system log files are clean and do not report any problem to any of ethernet interfaces or connection drops.

Actually I have no idea what exactly generates the problem. I'm quite sure iptable and Slackware network is configured property because the problem appear only rarely. Most of the time the server works perfectly. On the other side I don't think it is a vmware problem because in that case it wouldn't be fixed by a server reboot...

I'm confused....

Any idea?

Thanks a lot for your attention!

Last edited by gda; 03-24-2016 at 02:27 PM.
 
Old 03-24-2016, 03:19 PM   #2
NathanBarley
Member
 
Registered: Oct 2014
Location: Western Pennsylvania
Distribution: Slackware, Crux, Gentoo, FreeBSD
Posts: 94

Rep: Reputation: Disabled
I'm not sure what's causing that - maybe some udev strangeness? but as an aside if your ip addresses rules are constant, do you absolutely need to specify the interface? For instance why not omit it?

Code:
iptables -A INPUT -p tcp -s IP_SOURCE -d XXX.XXX.XXX.2 --dport 22 -j ACCEPT
 
Old 03-24-2016, 04:01 PM   #3
gda
Member
 
Registered: Oct 2015
Posts: 130

Original Poster
Rep: Reputation: 27
Thanks a lot for the feedback!

Actually I also had your same idea to not specify the interface in the iptable role. At moment this is the firewall configuration I'm using. Anyway I consider this only a partial solution because I would like to better understand what is really going on the server and why my initial configuration does not work as expected...
 
Old 03-24-2016, 08:28 PM   #4
NathanBarley
Member
 
Registered: Oct 2014
Location: Western Pennsylvania
Distribution: Slackware, Crux, Gentoo, FreeBSD
Posts: 94

Rep: Reputation: Disabled
Is the interface actually changing names? As in, is eth0 not consistently associated to the same MAC?

If that is the problem, you could look into some static udev rules, there's a few examples out there, I found this for example. I've found in Slackware 14.1 there is already a rule file that ties the interfaces together consistently. What do you have under:
Code:
/etc/udev/rules.d/70-persistent-net.rules
Secondly, how is the addressing on the linux VM allocated - is it via DHCP, or a static address? I'm wondering if DHCP is renewing the address on the interface and they're getting swapped around, although this doesn't seem likely.

Last edited by NathanBarley; 03-24-2016 at 08:36 PM.
 
Old 03-24-2016, 08:37 PM   #5
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Maybe this will help https://kindlund.wordpress.com/2007/...utes-in-linux/
 
Old 03-25-2016, 05:00 AM   #6
gda
Member
 
Registered: Oct 2015
Posts: 130

Original Poster
Rep: Reputation: 27
Quote:
Originally Posted by NathanBarley View Post
Is the interface actually changing names? As in, is eth0 not consistently associated to the same MAC?
I think this is not my case. The association between interface name and MAC address does not change. Even in the part of iptables log file I have reported above, the MAC address is the one corresponding to the eth3 which is always the same independently from the problem.

Thanks for the link! However the problem described there is a bit different from my case where the interfaces seems to get mixed up while the system is running and not at the boot.

Anyway the file you mentioned is empty on my system.

Quote:
Secondly, how is the addressing on the linux VM allocated - is it via DHCP, or a static address? I'm wondering if DHCP is renewing the address on the interface and they're getting swapped around, although this doesn't seem likely.
All the interface IPs are statically addressed.

Thank you very much for the support!
 
Old 03-25-2016, 05:23 AM   #7
gda
Member
 
Registered: Oct 2015
Posts: 130

Original Poster
Rep: Reputation: 27
Quote:
Originally Posted by Richard Cranium View Post
Hi Richard and thanks for the interesting link!

Anyway I think it does not apply to my case where all the interface IPs belong to the same subnet. Is my supposition correct?
 
Old 03-25-2016, 03:58 PM   #8
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
No, I don't think that has much to do with it. I believe that you'll need specific routing rules to ensure that packets coming in via eth0 are responded to via eth0 and so on. Maybe that's been fixed in later kernels.
 
Old 03-25-2016, 05:49 PM   #9
gda
Member
 
Registered: Oct 2015
Posts: 130

Original Poster
Rep: Reputation: 27
Ok I see the point. But I'm not sure this will fix the problem. In my case the incoming connections seem to be sent via the wrong interface (and the correct ip). While in the case described in the link the pockets coming out from the server could be sent via the wrong interface. Even if this happened how the packets sent by the client could be influenced by that?

Moreover in my case the default interface is eth0 which is also the interface used by ssh connections. So apparently there are no reasons for which this interface could be mixed with eth3. Maybe the communications via eth3 could be sent back by the server via eth0 and not the opposite.

Does all this make sense?

Thank you for your attention.
 
Old 03-25-2016, 09:55 PM   #10
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Well, at some point it depends upon the application.

An application can explicitly state that it wants its end of a TCP socket to use address XXX.XXX.XXX.2. An application can also state, "I don't care what endpoint I'm using on this end, I just want to talk to (some other address)." Both scenarios use your routing tables in a different fashion.

I guess that I'd ask how do you know, exactly, that ssh will go over eth0? Is that your gateway interface? What is the output of "route -n"? How about "route -n"? (You should examine both of those before you post to ensure that we don't see things that you don't want to be seen. It might be easier if you run both without the -n flags.)

I think that you should run the arp command as root and see what your system has decided what your routing should be. Some of the routing logic will exist on whatever switch is between you and the greater internet.
 
Old 03-26-2016, 03:09 AM   #11
gda
Member
 
Registered: Oct 2015
Posts: 130

Original Poster
Rep: Reputation: 27
Hi again!

yes, eth0 is my gateway interface. Moreover I can assure you that before posting I checked several times the output of both route and arp commands without find any valid reason to explain the behavior I see.

But you are right I should have mention that.

Anyway this is the output of the "route -n"

Code:
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         xxx.xxx.xxx.129  0.0.0.0         UG    1      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
xxx.xxx.xxx.128  0.0.0.0         255.255.255.128 U     0      0        0 eth0
xxx.xxx.xxx.128  0.0.0.0         255.255.255.128 U     0      0        0 eth1
xxx.xxx.xxx.128  0.0.0.0         255.255.255.128 U     0      0        0 eth2
xxx.xxx.xxx.128  0.0.0.0         255.255.255.128 U     0      0        0 eth3
I think in this particular situation the output of the "arp" command is not so useful because on the server is stored only the arp table relative to the local subnet. As I'm trying to connect from a different subnet the relevant arp table is stored elsewhere (as you said on switch between the server and the greater network) where unfortunately I cannot access to.

Finally the ssh is configured to listen only on the ip assigned to eth0. So I suppose that (at least at server level!) all the ssh connections (incoming and outcoming) should go via eth0.

Really thanks for the help and patience!

Last edited by gda; 03-26-2016 at 03:44 AM.
 
Old 03-26-2016, 06:40 AM   #12
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Did you also use 255.255.255.128 for the netmask on your interfaces, or just the routing entries? I don't know what you're trying to achieve with this set-up, but it looks like the destination and netmask values of the routing entries for eth0-3 don't match their addresses. Also your default gateway doesn't appear to be in the same subnet as any of your interface addresses.

Obviously I don't have full information so I may be missing some critical information, but the whole set-up looks somewhat odd, though admittedly it will sort of work. I guess I'd just feel more comfortable if it had a xxx.xxx.xxx.0 rule in there to match the local interface addresses and wasn't routing local traffic through the default gw. (though that probably doesn't have any bearing on your issue, so apologies for the noise.).


If you're going to want to make specific protocols always use specific interfaces then I think you're probably going to have to delve into NAT and iptables 'mangle' rules, at which point you kind of get into a "is it worth the pain" sort of deal.

Last edited by GazL; 03-26-2016 at 07:39 AM.
 
Old 03-26-2016, 08:39 AM   #13
gda
Member
 
Registered: Oct 2015
Posts: 130

Original Poster
Rep: Reputation: 27
You are right!

I have made a bit of confusion while posting... Sorry for that.

The details of my network configuration:

All the 4 interface are in the subnet

xxx.xxx.xxx.128/25

with gw:xxx.xxx.xxx.129.

Actually the IPs associated to the interfaces are:

xxx.xxx.xxx.216 (eth0)
xxx.xxx.xxx.217 (eth1)
xxx.xxx.xxx.218 (eth2)
xxx.xxx.xxx.219 (eth3)

The IPs I wrote in my first post (xxx.xxx.xxx.2, xxx.xxx.xxx.3,...) were just a (not relevant!) example to describe the background configuration.

I apologize for the mess.

Last edited by gda; 03-26-2016 at 09:02 AM.
 
1 members found this post helpful.
Old 03-26-2016, 09:13 AM   #14
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
np, that kind of makes more sense now. Thanks for clarifying.
 
Old 03-29-2016, 09:44 AM   #15
gda
Member
 
Registered: Oct 2015
Posts: 130

Original Poster
Rep: Reputation: 27
Quote:
If you're going to want to make specific protocols always use specific interfaces then I think you're probably going to have to delve into NAT and iptables 'mangle' rules, at which point you kind of get into a "is it worth the pain" sort of deal.
Probably I miss something important (I'm not an expert in network theory!) but I think this would not solve my problem.

Let' suppose one client tries to connect via ssh to the server using the IP xxx.xxx.xxx.216 (for example typing "ssh user@xxx.xxx.xxx.216") . So to encapsulate the ssh packet it needs to know:

- Source MAC address
- Source IP
- Destination IP
- Destination MAC

The first three items in my case are supposed to be known. The only missing information is the destination MAC which should be obtained using ARP (sending out an ARP query packet to resolve an IP address to a MAC address). According to my knowledge, an ARP request is basically just a broadcast that says "whoever has IP address xxx.xxx.xxx.216, send me your MAC address". ARP tables are build up on the base of these requests and they are stored on routers and computers as well. If the client and the server are not in the same subnet (as in my case) the relevant ARP tables are stored somewhere on the routers between the two machines.

So it sounds that occasionally and for an unknown reason, the IP xxx.xxx.xxx.216 is not associated to the MAC address of eth0 within these ARP tables, but to a MAC address corresponding to another server interface. So, basically, the understanding of why this happens will fix my problem.

I can see only one reasons for which this could happen:

the server (occasionally!!) provides wrong MAC address to the ARP request looking for the MAC associated to the IP xxx.xxx.xxx.216. Basically the Arp reply should contains always the MAC associated to the IP xxx.xxx.xxx.216 (eth0) as long as this association does not change on the server somehow... Any explanation on how this could happen??? I have no idea? Driver problem? All my interfaces use 'e1000' driver.

I consider really unlikely an issue in the ARP cache of the router because in that case I would not be able to explain why this happens only for this particular server and not for the others ones on my subnet having similar configuration.

Am I missing (or misunderstanding) any other important thing??

Last edited by gda; 03-29-2016 at 12:38 PM.
 
  


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
Strange Ethernet problem w/Slackware 12.2 on Presario 2100 ATBolicky Linux - Networking 11 08-24-2009 02:11 PM
Please help me !!! ethernet 1 interface problem... blueapexkr Linux - Newbie 1 12-09-2008 03:33 AM
Slackware / Ethernet Network Interface Card (NIC) problem. dwengert Slackware 2 05-21-2008 09:30 PM
Strange Problem with Interface Taikon Linux - Networking 2 01-31-2007 09:13 PM
strange ethernet issue - route -n doesn't correspond to actual interface availability echowarpt Slackware 1 01-28-2007 09:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:43 PM.

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