Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to route all outgoing requests for SSH (port 22) to mydynamicdns.afraid.org via wlan0 instead of eth0 when both are connected?

Since my IP is dynamic, I would like to use a name instead of IP.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Yes, you could mark all packets matches such policy, and control the route like this,

# Set mark for out going packets
iptables -t mangle -A OUTPUT -d mydynamicdns.afraid.org -j MARK --set-mark 1

# Route all packets with mark 1 through wlan0
ip rule add fwmark 1 table 1
ip route add XXX table 1 dev wlan0

P.S The rule would not work if DNS resolution fails

share|improve this answer
    
Thanks, I am using Ubuntu, will this work? Is IPTABLES a file that I can hand edit? –  Jorge Mar 3 '13 at 1:24
    
@Jorge it's a set of command –  warl0ck Mar 3 '13 at 1:41
    
Thanks, how can I see the rules I have added and/or delete them? –  Jorge Mar 3 '13 at 16:30
    
@Jorge ip rule; iptables -t mangle -L; ip route –  warl0ck Mar 4 '13 at 0:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.