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

Skip DNS resolution to connect to IP. #2331

Open
normalllll opened this issue Jun 24, 2024 · 3 comments
Open

Skip DNS resolution to connect to IP. #2331

normalllll opened this issue Jun 24, 2024 · 3 comments
Labels
S-needs-more-info Status: More information is required to understand the issue.

Comments

@normalllll
Copy link

Can I skip DNS and use IP directly to access a domain name?
I noticed this issue #561 mentioned DNS bypass.

Like this resolve does not working.

    let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 443);

    let client = reqwest::ClientBuilder::new().
        resolve("example.com", addr).
        tls_sni(false).
        use_rustls_tls().
        build().unwrap();

    client.request(reqwest::Method::GET, "https://example.com").send().await;
    ...
    ...

I saw this place using hyper::Request::builder, but it passed the uri argument directly.
image

Then it returns the result for example.com instead of 127.0.0.1

<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
        
    }
    div {
        width: 600px;
        margin: 5em auto;
        padding: 2em;
        background-color: #fdfdff;
        border-radius: 0.5em;
        box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
    }
    a:link, a:visited {
        color: #38488f;
        text-decoration: none;
    }
    @media (max-width: 700px) {
        div {
            margin: 0 auto;
            width: auto;
        }
    }
    </style>    
</head>

<body>
<div>
    <h1>Example Domain</h1>
    <p>This domain is for use in illustrative examples in documents. You may use this
    domain in literature without prior coordination or asking for permission.</p>
    <p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
</body>
</html>

@seanmonstar
Copy link
Owner

I'm not sure I understand. Does ClientBuilder::resolve(domain, ip) not work?

@seanmonstar seanmonstar added the S-needs-more-info Status: More information is required to understand the issue. label Jun 25, 2024
@normalllll
Copy link
Author

Yes, he doesn't work.

The expected behavior is to send a request to 127.0.0.1, but in fact, it still requests example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-more-info Status: More information is required to understand the issue.
Projects
None yet
Development

No branches or pull requests

3 participants
@seanmonstar @normalllll and others