I realize that rsync uses port 22 as its destination port (as I use -e SSH to encrypt my channel), but then, as I would expect, the source port seems to be a random numbered port well above 1000. I would like to not rate limit it using the --bwlimit=LIMIT flag but instead specify local transfer port the connection establishes. Then using my router, automatically lower the transfer priority of all packets with that SRC port. Hopefully making it not slow down my normal web activities on other ports while its transferring.

I already know how to set the QoS on my router, I just need to know how to force a source port for Rsync. And I already know about the --port=PORT option, but that sets the DST port, not the SRC port on the packets... I guess the real question is this: is there any way to specify source port for just rsync NOT for all ssh connections. Anyone have any ideas?

link|improve this question
FYI, SSH has been the default transport since 2004 (rsync 2.6.0). You don't need to specify it if you use host:path addresses. – grawity Apr 7 '11 at 18:19
feedback

1 Answer

up vote 0 down vote accepted

You cannot do this directly, but...

Possible solutions and alternative ideas:

  • QoS by DSCP class or IPv4 type-of-service. Recent versions of the ssh client have an option IPQoS. You could specify this specifically for rsync, or globally for all non-interactive sessions. (Older ssh versions have it hardcoded at "lowdelay" (interactive) and "throughput" (non-interactive).)

  • ssh ProxyCommand option, using netcat or socat to create the TCP connection. For example, a proxy command of socat tcp:%h:%p,bind=192.168.0.1:4242 stdio will always connect from the specified address:port pair. This is the closest answer to your question ("specify rsync source port"), but probably not the best solution for QoS.

  • QoS by IP address. You can assign a second IP address to your computer, and tell rsync to use it for transfers (ssh option BindAddress). It's a messy hack, though, but can be applied to all programs.


All ssh options listed above can be specified:

  • through rsync; -e "ssh -oIPQoS=cs2"

  • through an alias defined in ~/.ssh/config:

    Host myserver-qos
        Hostname myserver
        IPQoS cs2
    
    $ rsync /path myserver-qos:/path
    
link|improve this answer
I'm sorry, I didn't realize that this question was on SuperUser, and haven't been back here in awhile. I appreciate your answer, and it does look like you have done a really good job elucidating the possible workarounds for this issue. Thank you – dynamphorous May 12 '11 at 15:42
feedback

Your Answer

 
or
required, but never shown

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