Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to always look up and use the hostname of the public IP #75

Open
jetmore opened this issue Dec 1, 2023 · 2 comments
Open
Milestone

Comments

@jetmore
Copy link
Owner

jetmore commented Dec 1, 2023

This was requested via email by stembera.jan0#seznam.cz. I initially rejected it but after seeing how easy it is to do with DNS and thinking about it a bit, this is actually a pretty good fit for the proposed MUA mode

work around for now:

# get my public IP
dig +short myip.opendns.com @resolver1.opendns.com

# Then flip this around to get the public hostname for that IP:
dig +short -x `dig +short myip.opendns.com @resolver1.opendns.com`

# then strip the trailing period off of the response:
dig +short -x `dig +short myip.opendns.com @resolver1.opendns.com` | sed 's/\.$//'

if you saved that in a shell script you could then add "--helo `get-public-hostname.pl`" to the swaks command line
@jetmore jetmore added this to the MUA milestone Dec 1, 2023
@jetmore
Copy link
Owner Author

jetmore commented Dec 2, 2023

Jan refined this

dig @ns.sslip.io txt ip.sslip.io +short | sed 's/:/-/g' | sed 's/"//g' | sed 's/$/.sslip.io/'

This returns something like 1.2.3.4.sslip.io. This means there could be yet another path for what someone wants the hostname to be:

  • The local hostname (the current default)
  • A manually specificed hostname (current --helo option)
  • (public) Any valid hostname, as long as the remote host will be able to validate it with dns) (the sslio.io option in this comment)
  • (public) The correct hostname (PTR) for the IP the remote host will see, even if it isn't valid (meaning, even if we got the hostname from the IP, but that hostname doesn't actually resolve to that IP) (this is the myip.opendns.com option in the first coment)
  • (private) I haven't fleshed this one out, but it's worth noting that the private-private path would likely use different DNS, so the public options could actually make things worse

@jetmore
Copy link
Owner Author

jetmore commented Dec 2, 2023

One way to implement this would be to look at the IP we're connecting to (after we make the connection, since we might not have an IP before the connection) and, if it's RFC1918, use the local hostname as we always have. But if it's not, then use the "find my public hostname" method above. This might be too clever though. And I don't think there's an rfc1918 equiv for ipv6.

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

No branches or pull requests

1 participant