Skip to content

Allows wildcard host names as subnets#735

Merged
brianmay merged 2 commits intosshuttle:masterfrom
mangano-ito:allows-wildcard-hosts
Feb 10, 2022
Merged

Allows wildcard host names as subnets#735
brianmay merged 2 commits intosshuttle:masterfrom
mangano-ito:allows-wildcard-hosts

Conversation

@mangano-ito
Copy link
Contributor

sshuttle can't accept a wildcard host as a subnet option now:

❯ sshuttle --remote mangano-ito@remote --verbose "*.blogspot.com"

usage: sshuttle [-l [ip:]port] -r [user@]sshserver[:port] <subnets...>
sshuttle: error: argument IP/MASK[:PORT[-PORT]]...: '*.blogspot.com' is not a valid address/mask:port format

getaddrinfo resolves them like normal ones so we may want to handle those cases.
This pull request allows the option parser to accept that kind of host name:

❯ ./run --remote mangano-ito@remote --verbose "*.blogspot.com"

Starting sshuttle proxy (version 1.0.6.dev139+g4e43af7.d20220118).
c : Subnets to forward through remote host (type, IP, cidr mask width, startPort, endPort):
c :   (<AddressFamily.AF_INET6: 30>, '2404:6800:4004:81e::2001', 128, 0, 0)
c :   (<AddressFamily.AF_INET: 2>, '172.217.175.65', 32, 0, 0)

The result shows *.blogspot.com is resolved as in my following nslookup answers:

❯ nslookup -query=a "*.blogspot.com" 8.8.8.8

Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
*.blogspot.com	canonical name = blogspot.l.googleusercontent.com.
Name:	blogspot.l.googleusercontent.com
Address: 172.217.175.65
❯ nslookup -query=aaaa "*.blogspot.com" 8.8.8.8

Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
*.blogspot.com	canonical name = blogspot.l.googleusercontent.com.
blogspot.l.googleusercontent.com	has AAAA address 2404:6800:4004:81e::2001

Thank you,

@brianmay
Copy link
Member

brianmay commented Feb 10, 2022

Will just note here that this means *.blogspot.com will get translated literally as a DNS lookup for *.blogspot.com. It does not mean we will forward all traffic for anything under the blogspot.com domain (which might be nice but probably difficult to implement efficiently).

@brianmay brianmay merged commit bfd6f5d into sshuttle:master Feb 10, 2022
@mangano-ito mangano-ito deleted the allows-wildcard-hosts branch February 14, 2022 01:27
@alexeyOnGitHub
Copy link

what would you recommend for subnets like "*.amazonaws.com"? is there a way to configure sshuttle to route only AWS-related requests? there are multiple IP ranges for AWS (https://ip-ranges.amazonaws.com/ip-ranges.json) , so it would be hard to track them all a config file for sshuttle.

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