Solved

Making routing decision based on destination port

Posted on 2004-11-02
189 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
Question by:Znasev
    2 Comments
     

    Author Comment

    by:Znasev
    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:
    Closed, 250 points refunded.

    modulo
    Community Support Moderator
    Experts Exchange
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    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…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    857 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now