0

Actually I am using Ubuntu 22.04 with two ethernet as one with static ip address and 10 Mbps speed, whereas other ethernet has dynamic ip and 600 Mbps speed. I want to use ssh in static ethernet and manage downloads via dynamic port. Suggest some ways.

>ip route
-default via XX.XX.XX.41 dev eno1 proto static metric 100`
-default via 10.0.0.6 dev ens20 proto static metric 101
-10.0.0.0/8 dev ens20 proto kernel scope link src 10.0.13.64 metric 101
-XX.XX.XX.40/28 dev eno1 proto kernel scope link src XX.XX.XX.43 metric 100
-169.254.0.0/16 dev eno1 scope link metric 1000
-172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown

As metric 100 is my static and being the lower value all pass through that only if I alter the metric of 10.0.0.0 as 100 I am facing a break in ssh via static.

2
  • Your question does not make much sense, starting from the 600Mbps speed which is not a known speed setting. Commented Aug 12 at 16:27
  • May be, i am not good at networking, My second ethernet has connected to Gigabits per Second router switch with internet speed of 2.5/10 G. but i have attained approximate max speed of 600Mbps. But my question is not regarding speed of ISP, regarding ssh via static and download via high speed internet. Thanks for spending your time to put comment as "question does not make much sense."
    – pugazh
    Commented Aug 13 at 14:13

1 Answer 1

0

In such a case, you could use policy based routing using iptables and iproute.

To do so you can do the following

For SSH:
echo "100 ssh_link" >> /etc/iproute2/rt_tables
iptables -A PREROUTING -t mangle -m tcp -p tcp --dport 22 -j MARK --set-mark 100
ip route add default via $SSH_GATEWAY table ssh_link
ip rule add fwmark 100 table ssh_link

For the rest of the traffic:
echo "200 default_link" >> /etc/iproute2/rt_tables
ip route add default via $DEFAULT_GATEWAY table default_link
ip rule add priority 200 table default_link

Then to check your configuration:
ip route show table ssh_link
ip route show table default_link

This would seperate your SSH traffic from the rest of your traffic based on different gateways provided.

3
  • Thanks @venator!!! Nice way, but this policy manages the outgoing port as -dport, when this rule is enabled it works fine and good. The major drawback is it delays the incoming ssh as it takes too much time to response and ping shows approximately 60% - 80% loss for that static ip. I have tried for managing incoming packets forwarding with -sport but it totally cut off the incoming ssh. My Actual need is to get in the server via static which is totally disturbed here. Hopefully i think you may have solution for this also... Thanks in advance!!
    – pugazh
    Commented Aug 14 at 6:52
  • @pugazh in fact, i didn't actually understand the thing you are trying to do exactly. could you elaborate it so that I could help you better?
    – venator
    Commented Aug 16 at 20:46
  • I don't know, whether i am conveying properly. I am having Dell R720 Server with two ethernet connection. I want to access that from remotely via ssh through one of the ethernet(say 1) having static IP and low internet speed. And i have to download roughly 100GB files daily via another ethernet(say 2) with dynamic IP and I have adjusted metrices accordingly as metric is lower for ethernet 2 and downloading is happening through that but ssh to machine is delayed with 5 to 6 attempts. This delay also occured in you policy based routing also. I hope i have explained as per knowledge.
    – pugazh
    Commented Aug 18 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .