2007/06/04

有線無線共舞 Work with LAN and WLAN under WinXP

以我的網路環境為例,有線是公司線路,無線是 ADSL 線路。要有線無線共舞,則必須修改 routing table, 底下您只需要做最後一步,也就是第四步即可,前三步僅提供您驗證環境與我的差異性。若您有看到最後的話,第三步通常是在開機時已經同時啟動有線無線,那麼也可以透過改變 default gateway 的方式來達到目的,請看到最後面即可知道作法。

一、只有 LAN 的狀態

C:\>ipconfig

Windows IP Configuration


Ethernet adapter 區域連線:

Connection-specific DNS Suffix . : liteon.com
IP Address. . . . . . . . . . . . : 10.1.198.242
Subnet Mask . . . . . . . . . . . : 255.255.254.0
Default Gateway . . . . . . . . . : 10.1.199.254

C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x40002 ...00 15 c5 0b 66 fd ...... Broadcom NetXtreme 57xx Gigabit Controller -
Packet Scheduler Miniport
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.1.199.254 10.1.198.242 20
10.1.198.0 255.255.254.0 10.1.198.242 10.1.198.242 20
10.1.198.242 255.255.255.255 127.0.0.1 127.0.0.1 20
10.255.255.255 255.255.255.255 10.1.198.242 10.1.198.242 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
224.0.0.0 240.0.0.0 10.1.198.242 10.1.198.242 20
255.255.255.255 255.255.255.255 10.1.198.242 10.1.198.242 1
Default Gateway: 10.1.199.254
===========================================================================

二、只有無線網路的狀態

C:\>ipconfig

Windows IP Configuration


Ethernet adapter 無線網路:

Connection-specific DNS Suffix . : lan
IP Address. . . . . . . . . . . . : 192.168.123.139
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.123.1

C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x50002 ...00 16 6f 5f c2 99 ...... Intel(R) PRO/Wireless 2915ABG Network Connec
tion - Packet Scheduler Miniport
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.123.1 192.168.123.139 25
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.123.0 255.255.255.0 192.168.123.139 192.168.123.139 25
192.168.123.139 255.255.255.255 127.0.0.1 127.0.0.1 25
192.168.123.255 255.255.255.255 192.168.123.139 192.168.123.139 25
224.0.0.0 240.0.0.0 192.168.123.139 192.168.123.139 25
255.255.255.255 255.255.255.255 192.168.123.139 192.168.123.139 1
Default Gateway: 192.168.123.1
===========================================================================

三、同時有線與無線並存的狀態

C:\>ipconfig

Windows IP Configuration


Ethernet adapter 區域連線:

Connection-specific DNS Suffix . : liteon.com
IP Address. . . . . . . . . . . . : 10.1.198.28
Subnet Mask . . . . . . . . . . . : 255.255.254.0
Default Gateway . . . . . . . . . : 10.1.199.254

Ethernet adapter 無線網路:

Connection-specific DNS Suffix . : lan
IP Address. . . . . . . . . . . . : 192.168.123.139
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.123.1

C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x60002 ...00 15 c5 0b 66 fd ...... Broadcom NetXtreme 57xx Gigabit Controller -
Packet Scheduler Miniport
0x60003 ...00 16 6f 5f c2 99 ...... Intel(R) PRO/Wireless 2915ABG Network Connec
tion - Packet Scheduler Miniport
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.1.199.254 10.1.198.28 20
0.0.0.0 0.0.0.0 192.168.123.1 192.168.123.139 25
10.1.198.0 255.255.254.0 10.1.198.28 10.1.198.28 20
10.1.198.28 255.255.255.255 127.0.0.1 127.0.0.1 20
10.255.255.255 255.255.255.255 10.1.198.28 10.1.198.28 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.123.0 255.255.255.0 192.168.123.139 192.168.123.139 25
192.168.123.139 255.255.255.255 127.0.0.1 127.0.0.1 25
192.168.123.255 255.255.255.255 192.168.123.139 192.168.123.139 25
224.0.0.0 240.0.0.0 10.1.198.28 10.1.198.28 20
224.0.0.0 240.0.0.0 192.168.123.139 192.168.123.139 25
255.255.255.255 255.255.255.255 10.1.198.28 10.1.198.28 1
255.255.255.255 255.255.255.255 192.168.123.139 192.168.123.139 1
Default Gateway: 10.1.199.254
===========================================================================

四、先啟動有線,同時命令如下:

route delete 0.0.0.0
route add 10.1.0.0 mask 255.255.0.0 10.1.198.254

(註:上面 ipconfig 有線部份有提到 gateway)

之後再啟動無線後,狀態如下:

C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0xa0002 ...00 15 c5 0b 66 fd ...... Broadcom NetXtreme 57xx Gigabit Controller -
Packet Scheduler Miniport
0xa0003 ...00 16 6f 5f c2 99 ...... Intel(R) PRO/Wireless 2915ABG Network Connec
tion - Packet Scheduler Miniport
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.123.1 192.168.123.139 25
10.1.0.0 255.255.0.0 10.1.199.254 10.1.198.28 1
10.1.198.0 255.255.254.0 10.1.198.28 10.1.198.28 20
10.1.198.28 255.255.255.255 127.0.0.1 127.0.0.1 20
10.255.255.255 255.255.255.255 10.1.198.28 10.1.198.28 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.123.0 255.255.255.0 192.168.123.139 192.168.123.139 25
192.168.123.139 255.255.255.255 127.0.0.1 127.0.0.1 25
192.168.123.255 255.255.255.255 192.168.123.139 192.168.123.139 25
224.0.0.0 240.0.0.0 10.1.198.28 10.1.198.28 20
224.0.0.0 240.0.0.0 192.168.123.139 192.168.123.139 25
255.255.255.255 255.255.255.255 10.1.198.28 10.1.198.28 1
255.255.255.255 255.255.255.255 192.168.123.139 192.168.123.139 1
Default Gateway: 192.168.123.1
===========================================================================

注意到上面的 default gateway 已經改變成無線出去,而公司網路則透過 10.1.199.254 出去。

若要在開機時,已經同時啟動有線無線的情況下,也就是在第三點的狀況下,可以透過移除 0.0.0.0 之後再加入 0.0.0.0 的方式,也就是說,M$ 作業系統的 routing table 裡的 default gateway 就是指這個,因此如下語法可以加在第三點後面,就等於第四點:

route delete 0.0.0.0
route add 0.0.0.0 mask 0.0.0.0 192.168.123.1

0 意見: