[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Making routing decision based on destination port

Posted on 2004-11-02
2
Medium Priority
?
241 Views
Last Modified: 2010-03-18
Hello,

I have LAN connected to internet using two ISPs. I would like to route IRC traffic to one ISP using several public IP addresses and masquerade all other traffic to another ISP. My script is listed below. I can't connect to port 6667 and if a connection is established on another port via masqueraded interface, DCC is not working even if modprobe ip_conntrack_ftp, modprobe ip_conntrack_irc, modprobe ip_nat_ftp and modprobe ip_nat_irc
are present. Also ftp is not working.
Can somebody tell me what I am doing wrong ?
Thank you.

########################################

adsl-start

ISP1_IP="x.x.x.35"
ISP1_IP_RANGE="x.x.x.32/27"
ISP1_GW="x.x.x.33"
ISP1_IF="eth0"

LAN_IP="192.168.10.1"
LAN_IP_RANGE="192.168.10.0/24"
LAN_IF="eth1"

ISP2_IF="ppp0"
# ip address from ppp connection
ISP2_IP=$(/sbin/ifconfig ppp0 |grep inet|awk {'print $2'}|cut -d":" -f2)
# ppp connection gateway
ISP2_GW=$(/sbin/ifconfig ppp0 |grep inet|awk {'print $3'}|cut -d":" -f2)


ip address add x.x.x.34 dev $ISP1_IF
ip address add x.x.x.36 dev $ISP1_IF
ip address add x.x.x.37 dev $ISP1_IF

depmod -a
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ipt_MARK

iptables --flush
iptables -t nat --flush
iptables -t mangle --flush
iptables -t mangle -A PREROUTING -p tcp --dport 6667 -j MARK --set-mark 2

ip rule add prio 100 fwmark 2 lookup 100
ip route del default
ip route add default via $ISP1_GW table 100
ip route add default via $ISP2_GW
iptables -t nat -A POSTROUTING -o $ISP2_IF -s $LAN_IP_RANGE -j MASQUERADE
iptables -t nat -A POSTROUTING -o $ISP1_IF -s $LAN_IP_RANGE -j SNAT --to x.x.x.34-x.x.x.37

echo 1 > /proc/sys/net/ipv4/ip_forward

#########################################

0
Comment
Question by:Znasev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:Znasev
ID: 12475700
I found the solution myself.
The problem was in return path filter.

echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter

solves the problem.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12485532
Closed, 250 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question