2014-02-08 57 views
0

我尝试访问另一台机器上的Apache服务器(即使在本地主机上)。我用HTTP服务器的端口号

wireshark获取随机端口号vs 80的数据包的端口号。这是正确的。

但是与此同时,我试图在ip_rcv()中打印出内核中的端口号,其中tcph-> source和tcph-> dest。原来,这两个端口号是 也是随机的。

不知道我在做什么错,有人可以告诉我在哪里可以从内核获得正确的端口号?

+0

我不太明白你想在内核中做什么,为什么。 – tangrs

回答

0

你不能从任何内核获得的端口号,要设置一个Linux Web服务器的端口号执行下列操作,如果您有阿帕奇:

  • 如果你有Apache,然后去/etc/apache2/ports.conf并改变80为您选择所需数量的
  • 然后重新启动服务器service apache2 restart
  • 然后在你选择的Web浏览器去http://SERVER-IP:portnumber

注意:如果从80更改端口号,则必须在url/IP后输入新的端口号。

+0

我得到了解决方案: __be16 osport = 0,odport = 0; struct iphdr * iph =(struct iphdr *)skb_network_header(skb); const struct tcphdr * tcph =(struct tcphdr *)((__ u32 *)iph + iph- > ihl); osport = htons((unsigned short int)tcph-> source); odport = htons((unsigned short int)tcph-> dest); – billtian

相关问题