2014-02-08 116 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

相關問題