4

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.

5

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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