LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-18-2017, 02:53 AM   #1
hyperion10
LQ Newbie
 
Registered: Sep 2017
Posts: 6

Rep: Reputation: Disabled
forward to same IP over diferent interface


I'm not sure what i'm attempting is possible but from what i've read so far it's plausable

what i'm attempting is to route all traffic going out on port 62010 via eth2 and all traffic to out on port 34010 on eth3. The destination ip is the same (10.71.241.121) (and reachable by both interfaces if you set the route)

eth0 10.175.29.52 MGMT
eth2 10.71.231.2/25 GW 10.71.231.222
eth3 10.71.241.3/25 GW 10.71.241.254
dst IP:10.71.241.121

What i've done is setup a routing table as follows

IP rules
[root@hyperion ~]# cat /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
2 eth2OUT
3 eth3OUT

[root@hyperion ~]# ip rule list
0: from all lookup local
32762: from all fwmark 0x2 lookup eth3OUT
32763: from all fwmark 0x1 lookup eth2OUT
32766: from all lookup main
32767: from all lookup default

[root@hyperion ~]# ip route show table eth3OUT
10.71.241.121 via 10.71.241.254 dev eth3
default via 10.71.241.254 dev eth3
[root@hyperion ~]# ip route show table eth2OUT
10.71.241.121 via 10.71.231.222 dev eth2
default via 10.71.231.222 dev eth2


IPtables
789 iptables -A OUTPUT -p tcp --dport 62010 -t mangle -j MARK --set-mark 1
790 iptables -A OUTPUT -p tcp --dport 34010 -t mangle -j MARK --set-mark 2

[root@hyperion ~]# iptables -t mangle -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
MARK tcp -- anywhere anywhere tcp dpt:62010 MARK set 0x1
MARK tcp -- anywhere anywhere tcp dpt:34010 MARK set 0x2

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination

pretty sure thats all the config i need but still not joy:-



[root@hyperion ~]# telnet 10.71.241.121 62010
Trying 10.71.241.121...
telnet: connect to address 10.71.241.121: Connection timed out
[root@hyperion ~]# telnet 10.71.241.121 34010
Trying 10.71.241.121...
telnet: connect to address 10.71.241.121: Connection timed out

TCPDUMP
Still out via the default route i.e the MGMt address
07:45:34.161371 IP 10.175.29.52.44567 > 10.71.241.121.62010: Flags [S], seq 2992185250, win 14600, options [mss 1460,nop,nop,TS val 3536716705 ecr 0,nop,wscale 10], length 0
07:46:12.440551 IP 10.175.29.52.45850 > 10.71.241.121.34010: Flags [S], seq 2237464079, win 14600, options [mss 1460,nop,nop,TS val 3536754984 ecr 0,nop,wscale 10], length 0

Can anyone see what i'm missing here?

Last edited by hyperion10; 09-18-2017 at 02:55 AM.
 
Old 09-18-2017, 04:37 AM   #2
hyperion10
LQ Newbie
 
Registered: Sep 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
ok i've found the bit of config i was missing :-

/etc/sysctl.conf

net.ipv4.conf.default.rp_filter = 2
net.ipv4.conf.all.rp_filter = 2
net.ipv4.ip_forward = 1

for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 >| $f ; done

So it appears to be working now however the source always appears to be the eth0 MGMT address
 
Old 09-18-2017, 04:51 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,413

Rep: Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540
Quote:
Originally Posted by hyperion10 View Post
So it appears to be working now however the source always appears to be the eth0 MGMT address
Go read up on POSTROUTING / SNAT
 
Old 09-18-2017, 11:46 AM   #4
lsalab
LQ Newbie
 
Registered: Jan 2009
Posts: 24

Rep: Reputation: 3
Quote:
Originally Posted by TenTenths View Post
Go read up on POSTROUTING / SNAT
Also, keep in mind that you should set the 'src' in your routing tables.
 
Old 09-19-2017, 03:48 AM   #5
hyperion10
LQ Newbie
 
Registered: Sep 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
Go read up on POSTROUTING / SNAT
Thanks, I've added the following lines to resolve the final issue

iptables -A POSTROUTING -p tcp -m tcp --dport 34010 -j SNAT --to-source 10.71.241.121
iptables -A POSTROUTING -p tcp -m tcp --dport 64010 -j SNAT --to-source 10.71.241.121
 
Old 09-19-2017, 10:24 AM   #6
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
Can I ask a question, what do you plan on accomplishing with this setup? You should never have 2 interfaces on the same network unless they are port-channeled somehow. the switch spanning-tree should shut one of those ports off otherwise.
 
Old 09-20-2017, 04:11 AM   #7
hyperion10
LQ Newbie
 
Registered: Sep 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
i dont have 2 interfaces on the same network

Last edited by hyperion10; 09-20-2017 at 06:24 AM.
 
Old 09-20-2017, 01:23 PM   #8
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
Quote:
Originally Posted by hyperion10 View Post
i dont have 2 interfaces on the same network
You are correct sir. Sorry.

What was the fix since you marked this as resolved?
 
  


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
how to forward port to interface mfoley Linux - Networking 15 07-30-2015 01:28 AM
Forward packets from a tunnel interface dushyant26 Linux - Networking 1 08-16-2010 09:04 AM
DNS diferent responde for diferent zones joangopan Linux - Server 2 09-07-2007 10:53 PM
Forward all packets on interface james.farrow Linux - Networking 3 02-20-2007 09:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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