Code Monkey home page Code Monkey logo

dnsparse's Introduction

Linux下重写DNS解析函数(getaddrinfo)
  • 这段时间发现这个函数getaddrinfo不好用,而且会莫名其妙获取不到的ip地址,因此按照DNS的格式重新写了函数。
  • DNS的文件格式可以参考这篇博客(已经找不到原作者了)http://biancheng.dnbcw.info/win2003/345723.html
  • 期间会用到抓包工具,wireshark,其应用请自行搜索
说明
  • MyDNS.c是主要的实现,MyDNS.h当然是头文件
  • Maic中将实现的DNSSend和DNSRecv的应用
  • 在linux下运行gcc MyDNS.c Main.c (懒得写Makefile了)然后./a.out 域名(什么域名都可以) 就可以在打印中看到获取到ip地址
  • 本代码中发送的DNS服务器是网关192.168.1.1,要是你的网关不是这个,请替换成你自己的网关。或者直接替换至8.8.8.8或114.114.114.114中也可
抓包说明
  • 如下示的Domain数据就是我们要发送的数据。详细请参考代码 sendbuf.png
  • 如下示的Domain数据就是我们要解析的数据。详细请参考代码 recvbuffer.png

dnsparse's People

Contributors

wangzg123 avatar wang-zg avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.