linux中查询dns示例

 更新时间:2020年4月25日 17:42  点击:2119

dns.c

复制代码 代码如下:

/*
 * DNS Query Program on Linux
 *
 * Author : ismdeep@live.com
 *
 * */
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
#include<netinet/in.h>
#include<unistd.h> //getpid

//List of DNS Servers registered on the system
char dns_servers[10][100];
int dns_server_count = 0;
//Types of DNS resource records :)

#define T_A 1 //Ipv4 address
#define T_NS 2 //Nameserver
#define T_CNAME 5 // canonical name
#define T_SOA 6 /* start of authority zone */
#define T_PTR 12 /* domain name pointer */
#define T_MX 15 //Mail server

//Function Prototypes
void ngethostbyname (unsigned char* , int);
void ChangetoDnsNameFormat (unsigned char*,unsigned char*);
unsigned char* ReadName (unsigned char*,unsigned char*,int*);
void get_dns_servers();

//DNS header structure
struct DNS_HEADER
{
 unsigned short id; // identification number

 unsigned char rd :1; // recursion desired
 unsigned char tc :1; // truncated message
 unsigned char aa :1; // authoritive answer
 unsigned char opcode :4; // purpose of message
 unsigned char qr :1; // query/response flag

 unsigned char rcode :4; // response code
 unsigned char cd :1; // checking disabled
 unsigned char ad :1; // authenticated data
 unsigned char z :1; // its z! reserved
 unsigned char ra :1; // recursion available

 unsigned short q_count; // number of question entries
 unsigned short ans_count; // number of answer entries
 unsigned short auth_count; // number of authority entries
 unsigned short add_count; // number of resource entries
};

//Constant sized fields of query structure
struct QUESTION
{
 unsigned short qtype;
 unsigned short qclass;
};

//Constant sized fields of the resource record structure
#pragma pack(push, 1)
struct R_DATA
{
 unsigned short type;
 unsigned short _class;
 unsigned int ttl;
 unsigned short data_len;
};
#pragma pack(pop)

//Pointers to resource record contents
struct RES_RECORD
{
 unsigned char *name;
 struct R_DATA *resource;
 unsigned char *rdata;
};

//Structure of a Query
typedef struct
{
 unsigned char *name;
 struct QUESTION *ques;
} QUERY;

int main( int argc , char *argv[])
{
 unsigned char hostname[100];

 //Get the DNS servers from the resolv.conf file
 get_dns_servers();

 //Get the hostname from the terminal
 printf("Enter Hostname to Lookup : ");
 scanf("%s" , hostname);

 //Now get the ip of this hostname , A record
 ngethostbyname(hostname , T_A);

 return 0;
}

/*
 * Perform a DNS query by sending a packet
 * */
void ngethostbyname(unsigned char *host , int query_type)
{
 unsigned char buf[65536],*qname,*reader;
 int i , j , stop , s;

 struct sockaddr_in a;

 struct RES_RECORD answers[20],auth[20],addit[20]; //the replies from the DNS server
 struct sockaddr_in dest;

 struct DNS_HEADER *dns = NULL;
 struct QUESTION *qinfo = NULL;

 printf("Resolving %s" , host);

 s = socket(AF_INET , SOCK_DGRAM , IPPROTO_UDP); //UDP packet for DNS queries

 dest.sin_family = AF_INET;
 dest.sin_port = htons(53);
 dest.sin_addr.s_addr = inet_addr(dns_servers[0]); //dns servers

 //Set the DNS structure to standard queries
 dns = (struct DNS_HEADER *)&buf;

 dns->id = (unsigned short) htons(getpid());
 dns->qr = 0; //This is a query
 dns->opcode = 0; //This is a standard query
 dns->aa = 0; //Not Authoritative
 dns->tc = 0; //This message is not truncated
 dns->rd = 1; //Recursion Desired
 dns->ra = 0; //Recursion not available! hey we dont have it (lol)
 dns->z = 0;
 dns->ad = 0;
 dns->cd = 0;
 dns->rcode = 0;
 dns->q_count = htons(1); //we have only 1 question
 dns->ans_count = 0;
 dns->auth_count = 0;
 dns->add_count = 0;

 //point to the query portion
 qname =(unsigned char*)&buf[sizeof(struct DNS_HEADER)];

 ChangetoDnsNameFormat(qname , host);
 qinfo =(struct QUESTION*)&buf[sizeof(struct DNS_HEADER) + (strlen((const char*)qname) + 1)]; //fill it

 qinfo->qtype = htons( query_type ); //type of the query , A , MX , CNAME , NS etc
 qinfo->qclass = htons(1); //its internet (lol)

 printf("\nSending Packet...");
 if( sendto(s,(char*)buf,sizeof(struct DNS_HEADER) + (strlen((const char*)qname)+1) + sizeof(struct QUESTION),0,(struct sockaddr*)&dest,sizeof(dest)) < 0)
 {
  perror("sendto failed");
 }
 printf("Done");

 //Receive the answer
 i = sizeof dest;
 printf("\nReceiving answer...");
 if(recvfrom (s,(char*)buf , 65536 , 0 , (struct sockaddr*)&dest , (socklen_t*)&i ) < 0)
 {
  perror("recvfrom failed");
 }
 printf("Done");

 dns = (struct DNS_HEADER*) buf;

 //move ahead of the dns header and the query field
 reader = &buf[sizeof(struct DNS_HEADER) + (strlen((const char*)qname)+1) + sizeof(struct QUESTION)];

 printf("\nThe response contains : ");
 printf("\n %d Questions.",ntohs(dns->q_count));
 printf("\n %d Answers.",ntohs(dns->ans_count));
 printf("\n %d Authoritative Servers.",ntohs(dns->auth_count));
 printf("\n %d Additional records.\n\n",ntohs(dns->add_count));

 //Start reading answers
 stop=0;

 for(i=0;i<ntohs(dns->ans_count);i++)
 {
  answers[i].name=ReadName(reader,buf,&stop);
  reader = reader + stop;

  answers[i].resource = (struct R_DATA*)(reader);
  reader = reader + sizeof(struct R_DATA);

  if(ntohs(answers[i].resource->type) == 1) //if its an ipv4 address
  {
   answers[i].rdata = (unsigned char*)malloc(ntohs(answers[i].resource->data_len));

   for(j=0 ; j<ntohs(answers[i].resource->data_len) ; j++)
   {
    answers[i].rdata[j]=reader[j];
   }

   answers[i].rdata[ntohs(answers[i].resource->data_len)] = '\0';

   reader = reader + ntohs(answers[i].resource->data_len);
  }
  else
  {
   answers[i].rdata = ReadName(reader,buf,&stop);
   reader = reader + stop;
  }
 }

 //read authorities
 for(i=0;i<ntohs(dns->auth_count);i++)
 {
  auth[i].name=ReadName(reader,buf,&stop);
  reader+=stop;

  auth[i].resource=(struct R_DATA*)(reader);
  reader+=sizeof(struct R_DATA);

  auth[i].rdata=ReadName(reader,buf,&stop);
  reader+=stop;
 }

 //read additional
 for(i=0;i<ntohs(dns->add_count);i++)
 {
  addit[i].name=ReadName(reader,buf,&stop);
  reader+=stop;

  addit[i].resource=(struct R_DATA*)(reader);
  reader+=sizeof(struct R_DATA);

  if(ntohs(addit[i].resource->type)==1)
  {
   addit[i].rdata = (unsigned char*)malloc(ntohs(addit[i].resource->data_len));
   for(j=0;j<ntohs(addit[i].resource->data_len);j++)
   addit[i].rdata[j]=reader[j];

   addit[i].rdata[ntohs(addit[i].resource->data_len)]='\0';
   reader+=ntohs(addit[i].resource->data_len);
  }
  else
  {
   addit[i].rdata=ReadName(reader,buf,&stop);
   reader+=stop;
  }
 }

 //print answers
 printf("\nAnswer Records : %d \n" , ntohs(dns->ans_count) );
 for(i=0 ; i < ntohs(dns->ans_count) ; i++)
 {
  printf("Name : %s ",answers[i].name);

  if( ntohs(answers[i].resource->type) == T_A) //IPv4 address
  {
   long *p;
   p=(long*)answers[i].rdata;
   a.sin_addr.s_addr=(*p); //working without ntohl
   printf("has IPv4 address : %s",inet_ntoa(a.sin_addr));
  }

  if(ntohs(answers[i].resource->type)==5)
  {
   //Canonical name for an alias
   printf("has alias name : %s",answers[i].rdata);
  }

  printf("\n");
 }

 //print authorities
 printf("\nAuthoritive Records : %d \n" , ntohs(dns->auth_count) );
 for( i=0 ; i < ntohs(dns->auth_count) ; i++)
 {

  printf("Name : %s ",auth[i].name);
  if(ntohs(auth[i].resource->type)==2)
  {
   printf("has nameserver : %s",auth[i].rdata);
  }
  printf("\n");
 }

 //print additional resource records
 printf("\nAdditional Records : %d \n" , ntohs(dns->add_count) );
 for(i=0; i < ntohs(dns->add_count) ; i++)
 {
  printf("Name : %s ",addit[i].name);
  if(ntohs(addit[i].resource->type)==1)
  {
   long *p;
   p=(long*)addit[i].rdata;
   a.sin_addr.s_addr=(*p);
   printf("has IPv4 address : %s",inet_ntoa(a.sin_addr));
  }
  printf("\n");
 }
 return;
}

/*
 *
 * */
u_char* ReadName(unsigned char* reader,unsigned char* buffer,int* count)
{
 unsigned char *name;
 unsigned int p=0,jumped=0,offset;
 int i , j;

 *count = 1;
 name = (unsigned char*)malloc(256);

 name[0]='\0';

 //read the names in 3www6google3com format
 while(*reader!=0)
 {
  if(*reader>=192)
  {
   offset = (*reader)*256 + *(reader+1) - 49152; //49152 = 11000000 00000000 ;)
   reader = buffer + offset - 1;
   jumped = 1; //we have jumped to another location so counting wont go up!
  }
  else
  {
   name[p++]=*reader;
  }

  reader = reader+1;

  if(jumped==0)
  {
   *count = *count + 1; //if we havent jumped to another location then we can count up
  }
 }

 name[p]='\0'; //string complete
 if(jumped==1)
 {
  *count = *count + 1; //number of steps we actually moved forward in the packet
 }

 //now convert 3www6google3com0 to www.google.com
 for(i=0;i<(int)strlen((const char*)name);i++)
 {
  p=name[i];
  for(j=0;j<(int)p;j++)
  {
   name[i]=name[i+1];
   i=i+1;
  }
  name[i]='.';
 }
 name[i-1]='\0'; //remove the last dot
 return name;
}

/*
 * Get the DNS servers from /etc/resolv.conf file on Linux
 * */
void get_dns_servers()
{
 FILE *fp;
 char line[200] , *p;
 if((fp = fopen("/etc/resolv.conf" , "r")) == NULL)
 {
  printf("Failed opening /etc/resolv.conf file \n");
 }

 while(fgets(line , 200 , fp))
 {
  if(line[0] == '#')
  {
   continue;
  }
  if(strncmp(line , "nameserver" , 10) == 0)
  {
   p = strtok(line , " ");
   p = strtok(NULL , " ");

   //p now is the dns ip :)
   //????
  }
 }

 strcpy(dns_servers[0] , "208.67.222.222");
 strcpy(dns_servers[1] , "208.67.220.220");
}

/*
 * This will convert www.google.com to 3www6google3com
 * got it :)
 * */
void ChangetoDnsNameFormat(unsigned char* dns,unsigned char* host)
{
 int lock = 0 , i;
 strcat((char*)host,".");

 for(i = 0 ; i < strlen((char*)host) ; i++)
 {
  if(host[i]=='.')
  {
   *dns++ = i-lock;
   for(;lock<i;lock++)
   {
    *dns++=host[lock];
   }
   lock++; //or lock=i+1;
  }
 }
 *dns++='\0';
}

dns.c

复制代码 代码如下:

/*
 * DNS Query Program on Linux
 *
 * Author : ismdeep@live.com
 *
 * */
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
#include<netinet/in.h>
#include<unistd.h> //getpid

//List of DNS Servers registered on the system
char dns_servers[10][100];
int dns_server_count = 0;
//Types of DNS resource records :)

#define T_A 1 //Ipv4 address
#define T_NS 2 //Nameserver
#define T_CNAME 5 // canonical name
#define T_SOA 6 /* start of authority zone */
#define T_PTR 12 /* domain name pointer */
#define T_MX 15 //Mail server

//Function Prototypes
void ngethostbyname (unsigned char* , int);
void ChangetoDnsNameFormat (unsigned char*,unsigned char*);
unsigned char* ReadName (unsigned char*,unsigned char*,int*);
void get_dns_servers();

//DNS header structure
struct DNS_HEADER
{
 unsigned short id; // identification number

 unsigned char rd :1; // recursion desired
 unsigned char tc :1; // truncated message
 unsigned char aa :1; // authoritive answer
 unsigned char opcode :4; // purpose of message
 unsigned char qr :1; // query/response flag

 unsigned char rcode :4; // response code
 unsigned char cd :1; // checking disabled
 unsigned char ad :1; // authenticated data
 unsigned char z :1; // its z! reserved
 unsigned char ra :1; // recursion available

 unsigned short q_count; // number of question entries
 unsigned short ans_count; // number of answer entries
 unsigned short auth_count; // number of authority entries
 unsigned short add_count; // number of resource entries
};

//Constant sized fields of query structure
struct QUESTION
{
 unsigned short qtype;
 unsigned short qclass;
};

//Constant sized fields of the resource record structure
#pragma pack(push, 1)
struct R_DATA
{
 unsigned short type;
 unsigned short _class;
 unsigned int ttl;
 unsigned short data_len;
};
#pragma pack(pop)

//Pointers to resource record contents
struct RES_RECORD
{
 unsigned char *name;
 struct R_DATA *resource;
 unsigned char *rdata;
};

//Structure of a Query
typedef struct
{
 unsigned char *name;
 struct QUESTION *ques;
} QUERY;

int main( int argc , char *argv[])
{
 unsigned char hostname[100];

 //Get the DNS servers from the resolv.conf file
 get_dns_servers();

 //Get the hostname from the terminal
 printf("Enter Hostname to Lookup : ");
 scanf("%s" , hostname);

 //Now get the ip of this hostname , A record
 ngethostbyname(hostname , T_A);

 return 0;
}

/*
 * Perform a DNS query by sending a packet
 * */
void ngethostbyname(unsigned char *host , int query_type)
{
 unsigned char buf[65536],*qname,*reader;
 int i , j , stop , s;

 struct sockaddr_in a;

 struct RES_RECORD answers[20],auth[20],addit[20]; //the replies from the DNS server
 struct sockaddr_in dest;

 struct DNS_HEADER *dns = NULL;
 struct QUESTION *qinfo = NULL;

 printf("Resolving %s" , host);

 s = socket(AF_INET , SOCK_DGRAM , IPPROTO_UDP); //UDP packet for DNS queries

 dest.sin_family = AF_INET;
 dest.sin_port = htons(53);
 dest.sin_addr.s_addr = inet_addr(dns_servers[0]); //dns servers

 //Set the DNS structure to standard queries
 dns = (struct DNS_HEADER *)&buf;

 dns->id = (unsigned short) htons(getpid());
 dns->qr = 0; //This is a query
 dns->opcode = 0; //This is a standard query
 dns->aa = 0; //Not Authoritative
 dns->tc = 0; //This message is not truncated
 dns->rd = 1; //Recursion Desired
 dns->ra = 0; //Recursion not available! hey we dont have it (lol)
 dns->z = 0;
 dns->ad = 0;
 dns->cd = 0;
 dns->rcode = 0;
 dns->q_count = htons(1); //we have only 1 question
 dns->ans_count = 0;
 dns->auth_count = 0;
 dns->add_count = 0;

 //point to the query portion
 qname =(unsigned char*)&buf[sizeof(struct DNS_HEADER)];

 ChangetoDnsNameFormat(qname , host);
 qinfo =(struct QUESTION*)&buf[sizeof(struct DNS_HEADER) + (strlen((const char*)qname) + 1)]; //fill it

 qinfo->qtype = htons( query_type ); //type of the query , A , MX , CNAME , NS etc
 qinfo->qclass = htons(1); //its internet (lol)

 printf("\nSending Packet...");
 if( sendto(s,(char*)buf,sizeof(struct DNS_HEADER) + (strlen((const char*)qname)+1) + sizeof(struct QUESTION),0,(struct sockaddr*)&dest,sizeof(dest)) < 0)
 {
  perror("sendto failed");
 }
 printf("Done");

 //Receive the answer
 i = sizeof dest;
 printf("\nReceiving answer...");
 if(recvfrom (s,(char*)buf , 65536 , 0 , (struct sockaddr*)&dest , (socklen_t*)&i ) < 0)
 {
  perror("recvfrom failed");
 }
 printf("Done");

 dns = (struct DNS_HEADER*) buf;

 //move ahead of the dns header and the query field
 reader = &buf[sizeof(struct DNS_HEADER) + (strlen((const char*)qname)+1) + sizeof(struct QUESTION)];

 printf("\nThe response contains : ");
 printf("\n %d Questions.",ntohs(dns->q_count));
 printf("\n %d Answers.",ntohs(dns->ans_count));
 printf("\n %d Authoritative Servers.",ntohs(dns->auth_count));
 printf("\n %d Additional records.\n\n",ntohs(dns->add_count));

 //Start reading answers
 stop=0;

 for(i=0;i<ntohs(dns->ans_count);i++)
 {
  answers[i].name=ReadName(reader,buf,&stop);
  reader = reader + stop;

  answers[i].resource = (struct R_DATA*)(reader);
  reader = reader + sizeof(struct R_DATA);

  if(ntohs(answers[i].resource->type) == 1) //if its an ipv4 address
  {
   answers[i].rdata = (unsigned char*)malloc(ntohs(answers[i].resource->data_len));

   for(j=0 ; j<ntohs(answers[i].resource->data_len) ; j++)
   {
    answers[i].rdata[j]=reader[j];
   }

   answers[i].rdata[ntohs(answers[i].resource->data_len)] = '\0';

   reader = reader + ntohs(answers[i].resource->data_len);
  }
  else
  {
   answers[i].rdata = ReadName(reader,buf,&stop);
   reader = reader + stop;
  }
 }

 //read authorities
 for(i=0;i<ntohs(dns->auth_count);i++)
 {
  auth[i].name=ReadName(reader,buf,&stop);
  reader+=stop;

  auth[i].resource=(struct R_DATA*)(reader);
  reader+=sizeof(struct R_DATA);

  auth[i].rdata=ReadName(reader,buf,&stop);
  reader+=stop;
 }

 //read additional
 for(i=0;i<ntohs(dns->add_count);i++)
 {
  addit[i].name=ReadName(reader,buf,&stop);
  reader+=stop;

  addit[i].resource=(struct R_DATA*)(reader);
  reader+=sizeof(struct R_DATA);

  if(ntohs(addit[i].resource->type)==1)
  {
   addit[i].rdata = (unsigned char*)malloc(ntohs(addit[i].resource->data_len));
   for(j=0;j<ntohs(addit[i].resource->data_len);j++)
   addit[i].rdata[j]=reader[j];

   addit[i].rdata[ntohs(addit[i].resource->data_len)]='\0';
   reader+=ntohs(addit[i].resource->data_len);
  }
  else
  {
   addit[i].rdata=ReadName(reader,buf,&stop);
   reader+=stop;
  }
 }

 //print answers
 printf("\nAnswer Records : %d \n" , ntohs(dns->ans_count) );
 for(i=0 ; i < ntohs(dns->ans_count) ; i++)
 {
  printf("Name : %s ",answers[i].name);

  if( ntohs(answers[i].resource->type) == T_A) //IPv4 address
  {
   long *p;
   p=(long*)answers[i].rdata;
   a.sin_addr.s_addr=(*p); //working without ntohl
   printf("has IPv4 address : %s",inet_ntoa(a.sin_addr));
  }

  if(ntohs(answers[i].resource->type)==5)
  {
   //Canonical name for an alias
   printf("has alias name : %s",answers[i].rdata);
  }

  printf("\n");
 }

 //print authorities
 printf("\nAuthoritive Records : %d \n" , ntohs(dns->auth_count) );
 for( i=0 ; i < ntohs(dns->auth_count) ; i++)
 {

  printf("Name : %s ",auth[i].name);
  if(ntohs(auth[i].resource->type)==2)
  {
   printf("has nameserver : %s",auth[i].rdata);
  }
  printf("\n");
 }

 //print additional resource records
 printf("\nAdditional Records : %d \n" , ntohs(dns->add_count) );
 for(i=0; i < ntohs(dns->add_count) ; i++)
 {
  printf("Name : %s ",addit[i].name);
  if(ntohs(addit[i].resource->type)==1)
  {
   long *p;
   p=(long*)addit[i].rdata;
   a.sin_addr.s_addr=(*p);
   printf("has IPv4 address : %s",inet_ntoa(a.sin_addr));
  }
  printf("\n");
 }
 return;
}

/*
 *
 * */
u_char* ReadName(unsigned char* reader,unsigned char* buffer,int* count)
{
 unsigned char *name;
 unsigned int p=0,jumped=0,offset;
 int i , j;

 *count = 1;
 name = (unsigned char*)malloc(256);

 name[0]='\0';

 //read the names in 3www6google3com format
 while(*reader!=0)
 {
  if(*reader>=192)
  {
   offset = (*reader)*256 + *(reader+1) - 49152; //49152 = 11000000 00000000 ;)
   reader = buffer + offset - 1;
   jumped = 1; //we have jumped to another location so counting wont go up!
  }
  else
  {
   name[p++]=*reader;
  }

  reader = reader+1;

  if(jumped==0)
  {
   *count = *count + 1; //if we havent jumped to another location then we can count up
  }
 }

 name[p]='\0'; //string complete
 if(jumped==1)
 {
  *count = *count + 1; //number of steps we actually moved forward in the packet
 }

 //now convert 3www6google3com0 to www.google.com
 for(i=0;i<(int)strlen((const char*)name);i++)
 {
  p=name[i];
  for(j=0;j<(int)p;j++)
  {
   name[i]=name[i+1];
   i=i+1;
  }
  name[i]='.';
 }
 name[i-1]='\0'; //remove the last dot
 return name;
}

/*
 * Get the DNS servers from /etc/resolv.conf file on Linux
 * */
void get_dns_servers()
{
 FILE *fp;
 char line[200] , *p;
 if((fp = fopen("/etc/resolv.conf" , "r")) == NULL)
 {
  printf("Failed opening /etc/resolv.conf file \n");
 }

 while(fgets(line , 200 , fp))
 {
  if(line[0] == '#')
  {
   continue;
  }
  if(strncmp(line , "nameserver" , 10) == 0)
  {
   p = strtok(line , " ");
   p = strtok(NULL , " ");

   //p now is the dns ip :)
   //????
  }
 }

 strcpy(dns_servers[0] , "208.67.222.222");
 strcpy(dns_servers[1] , "208.67.220.220");
}

/*
 * This will convert www.google.com to 3www6google3com
 * got it :)
 * */
void ChangetoDnsNameFormat(unsigned char* dns,unsigned char* host)
{
 int lock = 0 , i;
 strcat((char*)host,".");

 for(i = 0 ; i < strlen((char*)host) ; i++)
 {
  if(host[i]=='.')
  {
   *dns++ = i-lock;
   for(;lock<i;lock++)
   {
    *dns++=host[lock];
   }
   lock++; //or lock=i+1;
  }
 }
 *dns++='\0';
}

[!--infotagslink--]

相关文章

  • Cloudflare国内自选IP节点整理收录

    一般来说为了达到隐藏自身 IP,我们都会选择一些 CDN 服务,目前用的最多的免费 CDN 是 Cloudflare。但是正常情况下 Cloudflare 是不能自己选择IP,有时候分配给我们的 IP 可能表现不佳,也只能将就着用。但是我们都希望可以用上 CF 比较快的 IP。那么自选IP,就显得很必要了。...2022-09-23
  • 在linux中使用包管理器安装node.js

    网上文章中,在linux下安装node.js都是使用源码编译,其实node的github上已经提供了各个系统下使用各自的包管理器(package manager)安装node.js的方法。...2015-03-15
  • Linux中grep命令详解

    grep命令是Linux系统中最重要的命令之一,功能是从文本文件或管道数据流中筛选匹配的行和数据,如果再配合正则表达式,功能十分强大,是Linux运维人员必备的命令,这篇文章主要介绍了Linux中grep详解,需要的朋友可以参考下...2023-02-15
  • Linux安装Pytorch1.8GPU(CUDA11.1)的实现

    这篇文章主要介绍了Linux安装Pytorch1.8GPU(CUDA11.1)的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-25
  • 详解Linux环境变量配置全攻略

    这篇文章主要介绍了Linux环境变量配置全攻略,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-03-31
  • Linux 下使用shell脚本定时维护数据库的案例

    这篇文章主要介绍了Linux 下使用shell脚本定时维护数据库,本文通过案例分析给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-07-11
  • linux服务器快速卸载安装node环境(简单上手)

    这篇文章主要介绍了linux服务器快速卸载安装node环境(简单上手),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-02-22
  • 2022年最新Cloudflare免费自选IP教程(非Partner)

    写在开头众所周知,CF在去年底大规模禁用Host API key,使得Partner自选法失效.但最近,Cloudflare为所有计划添加了100个SaaS域免费额度(以前$2一个).经过一番摸索,这个船新的...2022-09-23
  • Linux下升级安装python3.8并配置pip及yum的教程

    这篇文章主要介绍了Linux下升级安装python3.8并配置pip及yum的教程,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下...2020-05-02
  • Linux下安装mysql-8.0.20的教程详解

    这篇文章主要介绍了Linux下安装mysql8.0.20的教程,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-05-25
  • linux下源码安装mysql5.6.20教程

    这篇文章主要为大家详细介绍了linux下源码安装mysql5.6.20教程的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2017-01-15
  • Linux zabbix agent部署及配置方法详解

    这篇文章主要介绍了Linux zabbix agent部署及配置方法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-08-21
  • Linux下统计当前文件夹下的文件个数、目录个数

    这篇文章主要介绍了Linux下统计当前文件夹下的文件个数、目录个数,本文使用ls命令配合管理、grep命令实现统计需求,需要的朋友可以参考下...2020-07-11
  • Linux环境下nginx搭建简易图片服务器

    这篇文章主要介绍了Linux环境下nginx搭建简易图片服务器,需要的朋友可以参考下...2016-01-27
  • Linux CentOS MySQL数据库安装配置教程

    这篇文章主要为大家详细介绍了Linux CentOS MySQL数据库的安装配置教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2017-05-19
  • linux网络配置工具的使用

    这篇文章主要介绍了linux网络配置工具的使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-03-31
  • Linux下semop等待信号时出现Interrupted System Call错误(EINTR)解决方法

    本篇文章是对在Linux下semop等待信号时出现Interrupted System Call错误(EINTR)的解决方法进行了详细的分析介绍,需要的朋友参考下...2020-04-25
  • Linux下常用压缩格式的压缩与解压方法详解

    这篇文章主要介绍了Linux下常用压缩格式的压缩与解压方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-07-11
  • golang DNS服务器的简单实现操作

    这篇文章主要介绍了golang DNS服务器的简单实现操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-05-01
  • Fedora14 Linux系统安装Golang开发环境笔记

    这篇文章主要介绍了Fedora14 Linux系统安装Golang开发环境笔记,本文讲解了2种安装方法,需要的朋友可以参考下...2020-05-01