茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1664624 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_00104.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

微軟帝國 : [分享]如何在 Windows 2008 Server 上不用 Firewall 阻擋特定 IP

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15766
[分享]如何在 Windows 2008 Server 上不用 Firewall 阻擋特定 IP
冷日在工作中碰上了一個需求:
阻擋 Server 與特定 IP 的通訊!

本來很直覺得想說使用 Firewall 處理不就好了!?
但後來發現該 Windows Server 因為 AD Policy 而無法調整 Firewall 設定!

第一時間想到的平日我們 Crack Software 的 Hosts 檔案。
一般那些註冊機不都會改寫 Windows 下 System32 內 Drivers 中 etc 裡面的 hosts 檔案來防止向註冊 Server 報到嗎?
現實是:hosts 只能檔 NS!無法阻擋 IP!

其次想到的方案是 Route。
簡單來說,透過增加 Static Route 讓我們 Server 和特定 IP 的機器走錯的網路卡 Routing 不就繞不到了嗎?
結果是:因為主力網卡對其他網段(0.0.0.0)的連線不能阻擋,所以第一時間 route 不到的時候,她就走 0.0.0.0 的 gateway 過去了!

最後,才想到了 ARP。
希望可以透過 Windows ARP 的 IP 實際位址轉譯表格作怪來迫使與特定 IP 的通訊被我們打斷。
答案是:破壞了 ARP 設定後,只要網卡 Refresh 一次,她就還是會對所有 Interface 進行一次測試,然後就跑去可以通的界面了!

結論:
先新增 Static Route,逼特定 IP 的 Routing 走到錯誤的路線。
在破壞 ARP 讓某些 IP 只會看錯誤的 Interface。
這樣才達成我預期的目標!在這裡跟大家分享一下經驗! 水草舞
後面附上一些當年找到的資訊供大家參考! 好心情
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15766
[轉貼]Windows 2008 Server Create a Static Route

Create a Static Route

Applies To: Windows Server 2008 R2

Creating a static route informs the router of a specified network, the address of the gateway that serves as the next hop, and the interface to use to forward packets sent to that network.

Membership in the local Administrators group, or equivalent, is the minimum required to complete this procedure.

To create an IPv4 static route
  1. In the RRAS MMC snap-in, expand IPv4, right-click Static Routes, and then click New Static Route.

  2. In the Interface list, select the interface that should be used to forward packets to the network for which you are creating the route.

  3. In Destination, type the Internet Protocol version 4 (IPv4) address of the network.


  4. In Network mask, type the network mask that corresponds to the network address.

  5. In Gateway, type the IPv4 address of the router that serves as the next hop for forwarded packets.

  6. In Metric, type the number that reflects the cost of using this route. Typically, this value is the number of routers between this server and the destination network. When RRAS must select between multiple valid routes, the route with the lowest metric is the one selected.

  7. Click OK to save your changes. The new route appears in Static Routes.

To create an IPv6 static route
  1. In the RRAS MMC snap-in, expand IPv6, right-click Static Routes, and then click New Static Route.


  2. In the Interface list, select the interface that should be used to forward packets to the network for which you are creating the route.

  3. In Destination, type the Internet Protocol version 6 (IPv6) network address of the network using a format similar to 21DA:D3:0:2F3B::.

  4. In Prefix length, type the number of bits in the destination address that represent the network address. This value is typically 64, but can also be a value less than 64 when creating a summarized route.

  5. In Gateway, type the IPv6 address of the router that serves as the next hop for forwarded packets.

  6. In Metric, type the number that reflects the cost of using this route. Typically, this value is the number of routers between this server and the destination network. When RRAS must select between multiple valid routes, the route with the lowest metric is the one selected.


  7. Click OK to save your changes. The new route appears in Static Routes.

Additional references


原文出處: Microsoft TechNet - Create a Static Route
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15766
[轉貼]Windows 2008 Server Add a Static Route

Add a Static Route

Published: April 30, 2010

Updated: April 30, 2010

Applies To: Windows Server 2008, Windows Server 2008 R2

Membership in the local Administrators group, or equivalent, is the minimum required to complete this procedure.

  1. Open the Routing and Remote Access MMC snap-in.

  2. In the console tree, expand the router name, and then expand IPv4.

  3. Under IPv4, right-click Static Routes, and then click New Static Route.

  4. In the IPv4 Static Route dialog box, select the interface that you want to use for the route.

  5. Enter the destination, network mask, and metric.


    If you are configuring a default static route, use the following values for the destination, network mask, and metric:

    • In Destination, type 0.0.0.0.

    • In Network mask, type 0.0.0.0.

    • In Metric, type 1.

  6. In Gateway, do one of the following:

    • If you selected a demand-dial interface, Gateway is unavailable. Select the Use this route to initiate demand-dial connections check box to initiate a demand-dial connection for traffic matching the route.

    • If the interface for this route is a LAN connection, such as Ethernet or token ring, type the IP address of the router interface that is on the same network segment as the LAN interface.

  1. Open the Routing and Remote Access MMC snap-in.

  2. In the console tree, expand the router name, and then expand IPv6.

  3. Under IPv6, right-click Static Routes, and then click New Static Route.

  4. In the IPv6 Static Route dialog box, select the interface that you want to use for the route.

  5. Enter the destination, prefix length, and metric.

    If you are configuring a default static route, use the following values for the destination, prefix length, and metric:

    • In Destination, type ::.

    • In Prefix length, type ::/0.

    • In Metric, type 1.


  6. In Gateway, do one of the following:

    • If you selected a demand-dial interface, Gateway is unavailable. Select the Use this route to initiate demand-dial connections check box to initiate a demand-dial connection for traffic matching the route.

    • If the interface for this route is a LAN connection, such as Ethernet or token ring, type the IP address of the router interface that is on the same network segment as the LAN interface.


原文出處: Microsoft TechNet - Add a Static Route
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15766
[轉貼]描述的位址解析通訊協定 (ARP) 快取在 Windows Vista TCP/IP 實作中的行為
描述的位址解析通訊協定 (ARP) 快取在 Windows Vista TCP/IP 實作中的行為

重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。如果您發現錯誤,並想要協助我們進行改善,請填寫本篇文章下方的問卷。

檢視原始英文文章:949589

簡介
本文中的位址解析通訊協定 (ARP) 快取在 Windows Vista TCP/IP 實作中的行為。

更多的資訊
在 Windows Vista 中已經變更 ARP 快取行為。Windows Vista 中的 TCP/IP 堆疊實作遵守 RFC4861 (「 近鄰搜索通訊協定 ip 第 6 版 [Ipv6] 中的) 的 IPv4 和 IPv6 芳鄰探索程序。

ArpCacheLife 和 ArpCacheMinReferencedLife 登錄項目會決定在 Windows XP 和 Windows Server 2003 中,如何維護 ARP 快取。這些登錄項目不再套用到 Windows Vista 中。

在新的 Windows Vista TCP/IP 堆疊實作中,主機會建立芳鄰快取項目,鄰居快取中沒有相符的項目時。IPv4 的 ARP 快取項目是芳鄰快取項目的範例。芳鄰快取中成功建立的項目之後,如果項目符合特定條件的項目可以變更為"Reachable"的狀態。如果項目中的"Reachable"的狀態,則 Windows Vista TCP/IP 主機不要傳送 ARP 要求到網路。因此,Windows Vista TCP/IP 主機會使用快取中的資訊。如果未使用的項目,它會停留在 「 Reachable 」 狀態,超過它的 「 連線時間] 值,項目就會變成 「 過時 」 的狀態。如果有項目中的 「 過時 」 的狀態時,Windows Vista TCP/IP 主機必須傳送 ARP 要求到達的目的地。

"可執行到的時間"值的計算方式如下︰
連線時間 = BaseReachable 時間 × (MIN_RANDOM_FACTOR 到 MAX_RANDOM_FACTOR 之間的隨機值)
RFC 提供下列的計算的結果。
BaseReachable 時間 30000 毫秒 (ms)
MIN_RANDOM_FACTOR 0.5
MAX_RANDOM_FACTOR 1.5
因此,「 連線時間] 值位於 15 秒 (30 × 0.5 秒) 和 45 秒 (30 × 1.5 秒) 之間。如果項目不是介於 15 到 45 秒的時間,則它會變成 「 過時 」 的狀態。然後,主應用程式必須傳送 ARP 要求的 IPV4 網路任何 IP 資料包傳送至該目的地時。

若要查看目前的 「 連線時間] 值,請依照下列步驟執行︰

按一下 [開始] 型別
在開始搜尋的cmd方塊,然後再按一下 [程式集] 清單中的命令。
如果您接到提示輸入系統管理員密碼或確認的提示,請輸入您的密碼,或按一下 [繼續]。
在命令提示字元中,輸入下列命令︰
netsh 介面 ipv4 顯示介面
範例結果︰
    Idx  Met   MTU   State        Name---  ---  -----  -----------  -------------------
      1   50 4294967295  connected    Loopback Pseudo-Interface 1
      9   20   1500  connected    Local Area Connection

在步驟 2 中 「 本機區域連線 」 Idx 為 9。因此,您也可以在命令提示字元中輸入下列命令來顯示介面 9:
netsh 介面 ipv4 顯示介面 9
範例結果︰
    Interface Local Area Connection Parameters----------------------------------------------
    IfLuid                             : ethernet_7
    IfIndex                            : 9
    Compartment Id                     : 1
    State                              : connected
    Metric                             : 20
    Link MTU                           : 1500 bytes
     Reachable Time                     : 19000 ms  Base Reachable Time : 30000 ms Retransmission Interval : 1000 ms
    DAD Transmits : 3 Site Prefix Length : 64 Site Id : 1 Forwarding : disabled
    Advertising : disabled Neighbor Discovery : enabled Neighbor Unreachability
    Detecion : enabled Router Discovery : dhcp Managed Address Configuration :
    enabled Other Stateful Configuration : enabled Weak Host Sends : disabled Weak
    Host Receives : disabled Use Automatic Metric : enabled Ignore Default routes :
    disabled

您可以在命令提示字元中輸入下列的範例命令來變更"BaseReachable 時間"值︰
netsh 介面的 ipv4 設定介面 9 basereachable = 60000
若要查看 [步驟 4 的結果,請在命令提示字元中輸入下列命令︰
netsh 介面 ipv4 顯示介面 9
範例結果︰
    Interface Local Area Connection Parameters----------------------------------------------
    IfLuid                             : ethernet_7
    IfIndex                            : 9
    Compartment Id                     : 1
    State                              : connected
    Metric                             : 20
    Link MTU                           : 1500 bytes
    Reachable Time                     : 61500 ms
     Base Reachable Time                : 60000 ms  Retransmission Interval : 1000 ms DAD Transmits : 3 Site Prefix
    Length : 64 Site Id : 1 Forwarding : disabled Advertising : disabled Neighbor
    Discovery : enabled Neighbor Unreachability Detecion : enabled Router Discovery
    : dhcp Managed Address Configuration : enabled Other Stateful Configuration :
    enabled Weak Host Sends : disabled Weak Host Receives : disabled Use Automatic
    Metric : enabled Ignore Default routes : disabled

注意"基底存取時間"值已變更為 60000 毫秒。
您可以增加芳鄰快取限制在命令提示字元輸入下列命令︰
netsh 介面的 ipv4 設定通用的 neighborcachelimit = 4096
注意預設的鄰居快取限制為 256。

如需有關芳鄰快取項目狀態的詳細資訊,請造訪下列網站︰
http://www.ietf.org/rfc/rfc2461.txt
如需有關 TCP/IP 登錄值為 Windows Vista 及 Windows Server 2008,請造訪下列網站︰
http://download.microsoft.com/download/c/2/6/c26893a6-46c7-4b5c-b287-830216597340/TCPIP_Reg.doc
本文將所述之產品製造協力廠商均與 Microsoft 無關。Microsoft 不對這些產品之其他相關效能或可靠性作出任何擔保或默示。

Microsoft 提供協力廠商連絡資訊,以協助您尋找技術支援。此連絡資訊可能會變更不另行通知。Microsoft 不保證此第三方連絡資訊的正確性。

原文出處:Microsoft Support - 描述的位址解析通訊協定 (ARP) 快取在 Windows Vista TCP/IP 實作中的行為
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15766
[轉貼]Windows 常用網路指令 arp 指令用法

[ cmd ] Windows 常用網路指令 arp 指令用法

接續 windows 常用網路指令 nbtstat 找 MAC 此篇,紀錄一下 arp 指令用法ψ(._. )>

C:\>arp -?

顯示和修改位址解析通訊協定 (ARP) 使用的 IP 對
實際位址轉譯表格。

ARP -s inet_addr eth_addr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr] [-v]

  -a
            質詢目前的通訊協定資料來顯示目前的
                ARP 項目。如果指定 inet_addr,只會顯示指定電腦的
                IP 及實體位址。如果有多個網路介面使用 ARP,便會顯示每個 ARP表格的項目。
  -g            與 -a 相同。
  -v            以詳細資訊模式顯示目前的 ARP 項目。
                 將會顯示所有無效項目和回路介面上的項目。
  inet_addr     指定網際網路位址。
  -N if_addr    顯示 if_addr 指定之網路介面的 ARP項目。
  -d            刪除 inet_addr 指定的主機。使用萬用字元 * 取代 inet_addr 可刪除所有主機。
  -s            新增主機並將網際網路位址 inet_addr 與實體位址 eth_addr 相關聯。
                 實體位址是 6 個以連字號分隔的十六進位位元組。
                 該項目永久不變。
  eth_addr      指定實體位址。
  if_addr       如果存在,這會指定介面的網際網路位址,應修改此介面的位址轉譯表格。
                如果不存在,將會使用第一個適用的介面。
範例:
  >
arp -s 157.55.85.212   00-aa-00-62-c6-09  .... 新增靜態項目。
  > arp -a                                    .... 顯示 ARP 表格。


英文說明C:\>arp -?
Displays and modifies the IP-to-Physical address translation tables used by
address resolution protocol (ARP).

ARP -s inet_addr eth_addr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr]

  -a
            Displays current ARP entries by interrogating the current
                protocol data.  If inet_addr is specified, the IP and Physical
                addresses for only the specified computer are displayed.  If
                more than one network interface uses ARP, entries for each ARP
                table are displayed.
  -g            Same as -a.
  inet_addr     Specifies an internet address.
  -N if_addr    Displays the ARP entries for the network interface specified
                by if_addr.
  -d            Deletes the host specified by inet_addr. inet_addr may be
                wildcarded with * to delete all hosts.
  -s            Adds the host and associates the Internet address inet_addr
                with the Physical address eth_addr.  The Physical address is
                given as 6 hexadecimal bytes separated by hyphens. The entry
                is permanent.
  eth_addr      Specifies a physical address.
  if_addr       If present, this specifies the Internet address of the
                interface whose address translation table should be modified.
                If not present, the first applicable interface will be used.
Example:
  >
arp -s 157.55.85.212   00-aa-00-62-c6-09  .... Adds a static entry.
  > arp -a                                    .... Displays the arp table.

原文出處:[ cmd ] Windows 常用網路指令 arp 指令用法 - Evil-M$
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15766
[轉貼]Windows 上 ARP 緩存更新延遲導致修改 IP 地址後不能連通

Windows上ARP緩存更新延遲導致修改IP地址後不能連通(僅Windows7)

2012-12-13 07:44

在開發過程中,一些工具具備修改其他設備IP地址的功能。
修改IP地址的實現方式有:1)通過IP地址A連接過去修改IP地址B;2)通過IP地址A連接過去修改IP地址A。
這兩種方式,都涉及到ARP緩存的更新。
ARP(Address Resolution Protocol)協議是連接IP層與物理層的一種協議,ARP協議負責將網絡層的IP地址轉換為鏈路層的MAC地址,因為鏈路層最終是通過MAC地址發送數據包的。
關於OSI的7層以及他們之間的各種協議,請參考 OSI Model

在操作系同實現層面,都會緩存ARP表,紀錄該機器訪問過的IP地址與MAC地址的關聯,當網絡層的應用向某個IP地址發送包的時候,系統API會使用ARP協議將IP地址轉換為MAC地址然後發送出去。
ARP之所以要緩存是為了效率考慮,如果每次數據包發送都去查找一遍IP地址與MAC地址的映射關係,對性能的消耗是很大的。
所以在操作系統層面都會對ARP做緩存,然後通過自己的機制刷新它。

我們遇到的問題是,Windows機器連接到了一台設備,我們的工具在Windows上運行,去修改該設備的IP地址,將IP地址從A修改為B。

修改完成之後我們去ping這個B IP地址,發現不能立刻ping通,需要ping接近1分鐘。

這裡就是Widnwos7上面的ARP緩存在搗鬼,因為windows機器上的arp緩存紀錄的是修改之前的IP地址A與設備的網卡MAC地址的映射關係,而現在去ping IP地址B,按照理解是能夠ping通的,因為windows機器上的ARP緩存中該IP地址不存在,應當去刷新ARP緩存。
不過好像Windows7上面,沒有這種機制。貌似一定要等到系統觸發的ARP緩存刷新。

後來我們手動執行 arp -d IP_ADDR,將老的arp紀錄刪除,然後再ping,就可以正常了。

這個問題不直到是否算windows7的bug?因為在XP上是沒有這種問題的。


原文出處: Windows上ARP缓存更新延迟导致修改IP地址后不能连通(仅Windows7) – 运维派
前一個主題 | 下一個主題 | 頁首 | | |



Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|