轉自: 

http://welkinchen.pixnet.net/blog/post/48195274-%E9%9B%99%E7%B6%B2%E8%B7%AF%E6%90%AD%E9%85%8D%E9%9B%99%E7%B6%B2%E5%8D%A1

 

條件=>有兩個網卡跟兩個網路
用途=>設定網卡優先使用的網路
E.g. 脫離公司網路監控..... 跳脫網路下載限制.....

網路卡->『一般』->『內容』=>『TCP/IP』=>『內容』=>『進階』

調整 『預設閘道』跟 『介面計量』
//---------------------
優先權1的網路卡=>將裡面的『公制』(介面計量)設定為『1』
優先權2的網路卡=>將裡面的『公制』(介面計量)設定為『自動』
//---------------------
優先權1的網路卡=>將裡面的『公制』(介面計量)設定為較小的數字
優先權2的網路卡=>將裡面的『公制』(介面計量)設定為較大的數字
//---------------------

想更進一步了解~可直接手動設定 route table => 查詢 route

//*---------------------------
//*route 指令說明
//*---------------------------
Syntax:
----------
route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]

Parameters:
----------
[-f]:
清除所有閘道項目的路由表(但是不包含下列三種)。如果這個參數跟命令(Command)一起搭配(例如使用 add, change, or delete),表示執行命令前會先清除路由表。
1.主路由(host routes) => routes with a netmask of 255.255.255.255
2.環回網絡路由(loopback network route) => routes with a destination of 127.0.0.0 and a netmask of 255.0.0.0
3.多重播送路由(multicast route) => routes with a destination of 224.0.0.0 and a netmask of 240.0.0.0

[-p]:
只有跟命令 add 或 print 搭配才有用。搭配其它命令時可以忽略。
與命令add一起使用時,表示要保存此設定值。(預設不保存,電腦重開機後會失效。)
與命令print一起使用時,表示要顯示路由表。
Persistent routes 存放位置是在註冊表:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes

E.g.
-4:強制使用 IPv4。(route print -4)
-6:強制使用 IPv6。(route print -6)

[Command]:
包含以下命令
ADD       增加路由
CHANGE    修改目前路由
DELETE    刪除路由(表)
PRINT     列出目前路由(表)

[Destination]:
Specifies the network destination of the route. The destination can be an IP network address (where the host bits of the network address are set to 0), an IP address for a host route, or 0.0.0.0 for the default route.
路由的目標。目標可以是一個IP網段(IP network address:網段區域的值設成0),一個IP位址,也可以設定 0.0.0.0 使用預設路由。

[mask Netmask]:
Specifies the netmask (also known as a subnet mask) associated with the network destination.
子網路遮罩。(預設是 255.255.255.255)
(netmask 子網路遮罩)與(target 目標位址)的邏輯AND運算決定了負責的網域的大小。
IP:FF.FF.FF.FF(255.255.255.255)
E.g.
IP 192.168.1.0 網段,並且子網路遮罩為 255.255.255.0,表示前三組號碼為 NetID(不變的),而最後一組號碼為 HostID(唯一的)。
因此當 Netmask 設為 255.255.255.0 時,則 192.168.1.0 ~ 192.168.1.255 就屬於同一個網段內了。

[Gateway]:
Specifies the forwarding or next hop IP address over which the set of addresses defined by the network destination and subnet mask are reachable.
如果目的 IP 位址與 Netmask 作 AND 邏輯運算,剛好與 Network Destination 相同,封包就會經由此閘道IP傳送。
閘道(封包將傳送到的IP位址),Gateway的用途是連接兩個不同的網段。
若閘道出現"在連結上",表示連結目標與當前主機在同一網段,封包將直接傳送,不需經由路由器轉送。

[metric Metric]:
封包傳遞的優先權,數字愈低優先權愈高。(1~9999)
(路由表閘道選擇的順序)

[if Interface]:
指定送出封包的網路卡(ID:可使用十進制或十六進制(加上0x))。
若省略此參數時,送出封包的網路卡由閘道位址決定(gateway address)。
Interface 編號可由 route PRINT 界面清單查看

/? : Displays help at the command prompt.

------------------------------------------------------------
E.g.
加入路由路徑
route add 192.168.0.0 mask 255.255.0.0 192.168.1.1 if 0x2 metric 20

E.g.
修改現有路徑
route change 192.168.0.0 mask 255.255.0.0 192.168.1.1 if 0x2 metric 10
(change 只能用來修改閘道(或)優先權。)

E.g.
刪除路由路徑
route delete 192.168.0.0
route delete 192.168.0.0 mask 255.255.0.0
route delete 192.168.0.0 mask 255.255.0.0 8.8.8.8

E.g.
取代 default route
1. 直接刪除 0.0.0.0
route delete 0.0.0.0

2. 搶先優先權 metric
route add 0.0.0.0 mask 0.0.0.0 GatewayIP 
route add 0.0.0.0 mask 0.0.0.0 192.168.1.1 metric 10

E.g.
內外網可正常的連結表
===========================================================================
介面清單
 14...00 02 b3 3d d6 da ......Intel(R) PRO/100 S Server Adapter
 13...e0 3f 49 b2 ca b1 ......Realtek PCIe GBE Family Controller
===========================================================================
IPv4 路由表
------------------------------------------------------------
  網路目的地         網路遮罩           閘道  (網路卡IP)介面  優先權
     0.0.0.0          0.0.0.0  192.168.123.1     192.168.1.1      20  (第二閘道)(Realtek-13)
     0.0.0.0          0.0.0.0    10.5.63.254      10.5.56.78      50  (預設閘道)(Intel-14)
    10.0.0.0        255.0.0.0       在連結上      10.5.56.78     200  (鎖定10.x.x.x的網域)(Intel-14)
    10.5.0.0      255.255.0.0       在連結上      10.5.56.78     220  (鎖定10.5.x.x的網域)(Intel-14)
   10.5.86.0    255.255.255.0       在連結上      10.5.56.78     250  (鎖定10.5.86.x的網域)(Intel-14)
  10.5.1.126  255.255.255.255       在連結上      10.5.56.78     280  (鎖定特定IP)
  10.5.1.255  255.255.255.255       在連結上      10.5.56.78     280  (鎖定特定IP)
   127.0.0.0        255.0.0.0       在連結上       127.0.0.1     300  (鎖定本機回路)
------------------------------------------------------------
E.g.
------------------------------------------------------------
內部網段   10.x.x.x
子網路遮罩 255.0.0.0
預設閘道   10.5.63.254
第二閘道   192.168.123.1

Intel 為公司內部網卡(確保公司內部連線)
Realtek 為第二網卡

(DNS設定公司為第一選擇)

外部網段的封包傳送(路由),直接經由Realtek網路卡送往第二閘道處理。
(提升Realtek外網優先權)
route change 0.0.0.0 mask 0.0.0.0 192.168.123.1 if 13 metric 10
or
(降低Intel外網優先權)
route change 0.0.0.0 mask 0.0.0.0   10.5.63.254 if 14 metric 50

內部網段的封包傳送(路由),直接經由Intel網路卡送往預設閘道處理。
route add 10.0.0.0 mask 255.255.255.0 10.5.63.254 if 14 metric 200
------------------------------------------------------------

E.g.
------------------------------------------------------------
@echo off
@echo.
@echo 使用系統管理員執行
@echo ipconfig查看gateway
@echo.
REM 
REM route PRINT
REM 
REM route delete 0.0.0.0 mask 0.0.0.0 192.168.1.1
REM 
REM route add 0.0.0.0 mask 0.0.0.0 192.168.1.2 if 18 metric 10
REM route change 0.0.0.0 mask 0.0.0.0 192.168.1.2 if 18 metric 10
REM route change 0.0.0.0 mask 0.0.0.0 10.5.63.254 if 14 metric 50
REM 
REM set IF_PRI=14
REM set IF_SEC=18
REM set GW_PRI=10.5.63.254
REM set GW_SEC=192.168.1.1
REM route add 0.0.0.0 mask 0.0.0.0 %GW_SEC% if %IF_SEC% metric 10
REM route add 10.5.0.0 mask 255.255.0.0 %GW_PRI% if %IF_PRI% metric 100
REM 
route add 0.0.0.0 mask 0.0.0.0 192.168.1.1 if 18 metric 10
route add 10.5.0.0 mask 255.255.0.0 10.5.63.254 if 14 metric 100
pause
------------------------------------------------------------

arrow
arrow
    全站熱搜

    大喜婚攝 HKS 發表在 痞客邦 留言(0) 人氣()