LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-21-2018, 01:59 AM   #1
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Rep: Reputation: 57
How can iptables distinguish between packets coming in from one route versus another?


If packets are coming in through different interfaces eth1 and eth2, iptables can distinguish them with something like

-i eth1

If they are coming in through the same interface eth1 but from different servers at 10.0.0.2 and 10.0.0.3, they can be distinguished with something like

-s 10.0.0.2/32

What if packets originate from unknown IP's and subnets and pass through different gateways and all that you know is the IP of each of the gateways, 192.168.1.1 and 192.168.1.2, and that all packets come in through eth1?

Last edited by Ulysses_; 10-21-2018 at 02:05 AM.
 
Old 10-21-2018, 07:14 PM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
All packets sent over the internet or any network for that matter have a source and destination address. With this information every device knows how to send the packet on to it's final destination.
 
Old 10-22-2018, 01:40 AM   #3
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
But we do not know the source IP, and it can be the same source IP sending packets in both paths, how can we write an iptables command line at the receiving end that distinguishes one path from another, for example to drop packets from one path? If there were two nic's at the receiving end, one for each path, we'd write -i eth1. But there is only one.

Last edited by Ulysses_; 10-22-2018 at 01:49 AM.
 
Old 10-22-2018, 08:18 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Ahhh, same server (source), different routes. If they are coming in from a different immediate upstream router, you could use the source MAC. Otherwise, you might be able to distinguish the routes by the remaining TTL when the packets are received. That's going to be hard to implement and probably unreliable, but I don't know of any other way that the same packets arriving by different routes would differ.

Last edited by rknichols; 10-22-2018 at 08:20 AM.
 
1 members found this post helpful.
Old 10-22-2018, 12:37 PM   #5
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Not sure I understand your question 100%. What exactly are you trying to accomplish? Are you trying to block traffic from an unknown source or are you trying to only allow certain traffic from an unknown source?
 
Old 10-22-2018, 02:06 PM   #6
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
Looks like buying an nic is the best option. It's kinda complicated and open-ended what I am trying to accomplish (related to load balancing and smartphones) and I wouldn't be good at explaining it.
 
Old 10-22-2018, 05:05 PM   #7
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
A second NIC might not be the best option. Whatever you plan on doing on the second NIC you should be able to do on the first one too. It all comes down to what you are trying to accomplish.
 
  


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
Why static routes set using 'ip route add' and 'route add' commands are not used for routing packets within the same network? kanak@tetcos.com Linux - Networking 7 04-25-2017 05:52 AM
Route eth2 TCP packets to tun0 with IPTABLES & IP RULE/ROUTE Thireus Linux - Networking 4 05-09-2011 12:38 PM
LXer: The Coming War: ARM versus x86 LXer Syndicated Linux News 0 04-09-2010 01:40 PM
[SOLVED] 'route' versus 'inet_route': Slackware-12.0 rshepard Slackware 6 10-23-2007 03:40 PM
How can I distinguish a whole mail from TCP packets sunnyriver Linux - Networking 2 03-22-2004 11:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:25 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