Skip to content

firewall: Allow overriding the TTL#606

Merged
brianmay merged 1 commit intosshuttle:masterfrom
vkareh:override-nat-ttl
Mar 4, 2021
Merged

firewall: Allow overriding the TTL#606
brianmay merged 1 commit intosshuttle:masterfrom
vkareh:override-nat-ttl

Conversation

@vkareh
Copy link
Contributor

@vkareh vkareh commented Mar 2, 2021

In instances where a cluster pod in a local VM needs to access a server
that is sshuttle'd from the host, since the packets arriving at the host
already made a hop, their TTL is 63 and so get ignored by sshuttle.
Allowing an override of the firewall TTL rule allows the packets to go
through.

@vkareh vkareh force-pushed the override-nat-ttl branch 2 times, most recently from c2f6944 to 0f2713a Compare March 2, 2021 12:40
@brianmay
Copy link
Member

brianmay commented Mar 3, 2021

I think you might have missed the lines that set this for outgoing packets:

https://github.com/sshuttle/sshuttle/blob/master/sshuttle/server.py#L194
https://github.com/sshuttle/sshuttle/blob/master/sshuttle/server.py#L251

The more I see this code, the more I wonder if it should be simply deleted. It seems a horrible way to allow ssh to run on the localhost. Which seems a strange thing to do (but requested). And I can't help but think there should be a better way of doing this.

@sbueringer
Copy link

sbueringer commented Mar 3, 2021

Just wanted to comment on the use case.

We have the same issue. Our use case is running a container in a container with docker-in-docker. sshuttle is running on the outer container. So we basically run into the exact same issue. Deleting the TTL rule is a valid workaround for me because in my use case I don't want to run sshuttle client and server on the same "host"/network namespace (I guess container in my case).

I'm no iptables expert by any means. I saw that calico is solving a similar use case by marking packages. But I have no idea if this would also work in this case as replacement for the TTL "match".

In instances where a cluster pod in a local VM needs to access a server
that is sshuttle'd from the host, since the packets arriving at the host
already made a hop, their TTL is 63 and so get ignored by sshuttle.
Allowing an override of the firewall TTL rule allows the packets to go
through.
@vkareh vkareh force-pushed the override-nat-ttl branch from 0f2713a to a667184 Compare March 3, 2021 18:26
@vkareh
Copy link
Contributor Author

vkareh commented Mar 3, 2021

@brianmay

I think you might have missed the lines that set this for outgoing packets [...]

Yes, thanks! I've updated the PR to include them

@vkareh
Copy link
Contributor Author

vkareh commented Mar 3, 2021

@sbueringer

Deleting the TTL rule is a valid workaround for me

Yes, I tested this and it works for me as well, but I feel that other users might have a valid scenario needing the TTL rule, so removing it seems unnecessarily disruptive for this PR. My use case is running an openshift cluster inside a local VM that connects to another (sshuttled) openshift cluster. Setting the TTL to 64 allows those clusters to talk to one another. Setting it to 65 allows both the VM'd cluster and my host system/browser to connect to the remote cluster.

@sbueringer
Copy link

@vkareh yeah deleting the rule is definitely just a temporary workaround. A permanent solution would be great.

@brianmay brianmay merged commit 167a57e into sshuttle:master Mar 4, 2021
skuhl added a commit to skuhl/sshuttle that referenced this pull request Jul 12, 2021
Previously, it was possible to run sshuttle locally without using ssh
and connecting to a remote server. In this configuration, traffic was
redirected to the sshuttle server running on the localhost. However,
the firewall needed to distinguish between traffic leaving the
sshuttle server and traffic that originated from the machine that
still needed to be routed through the sshuttle server. The TTL of the
packets leaving the sshuttle server were manipulated to indicate to
the firewall what should happen. The TTL was adjusted for all packets
leaving the sshuttle server (even if it wasn't necessary because the
server and client were running on different machines).

Changing the TTL caused trouble and some machines, and
the --ttl option was added as a workaround to change how the TTL was
set for traffic leaving sshuttle. All of this added complexity to the
code for a feature (running the server on localhost) that is likely
only used for testing and rarely used by others.

This commit updates the associated documentation, but doesn't fully
fix the ipfw method since I am unable to test that.

This change will also make sshuttle fail to work if -r is used to
specify a localhost. Pull request sshuttle#610 partially addresses that issue.

For example, see: sshuttle#240, sshuttle#490, sshuttle#660, sshuttle#606.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants