TWI392290B - Router and method of setting ip addresses of the router - Google Patents

Router and method of setting ip addresses of the router Download PDF

Info

Publication number
TWI392290B
TWI392290B TW98132803A TW98132803A TWI392290B TW I392290 B TWI392290 B TW I392290B TW 98132803 A TW98132803 A TW 98132803A TW 98132803 A TW98132803 A TW 98132803A TW I392290 B TWI392290 B TW I392290B
Authority
TW
Taiwan
Prior art keywords
address
router
data machine
private
packet
Prior art date
Application number
TW98132803A
Other languages
Chinese (zh)
Other versions
TW201112693A (en
Inventor
hong-jian Guo
Yang Liu
Original Assignee
Hon Hai Prec Ind Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hon Hai Prec Ind Co Ltd filed Critical Hon Hai Prec Ind Co Ltd
Priority to TW98132803A priority Critical patent/TWI392290B/en
Publication of TW201112693A publication Critical patent/TW201112693A/en
Application granted granted Critical
Publication of TWI392290B publication Critical patent/TWI392290B/en

Links

Description

路由器及其IP位址設置方法 Router and its IP address setting method

本發明涉及一種網路設備及網路構建方法,尤其涉及一種路由器及其IP位址設置方法。 The invention relates to a network device and a network construction method, in particular to a router and an IP address setting method thereof.

路由器(Router)用於連接多個位於不同網段的、邏輯上分開的網路。所謂不同網段的、邏輯上分開的網路代表一個單獨的網路或者子網。當資料從一個子網傳輸到另一個子網時,可透過路由器來完成。 A router is used to connect multiple logically separated networks on different network segments. So-called logically separate networks of different network segments represent a single network or subnet. When data is transferred from one subnet to another, it can be done through the router.

大部分的路由器上有兩種類型的埠,分別是廣域網路(Wide Area Network,WAN)埠和局域網路(Local Area Network,LAN)埠。WAN埠用來連接外部網路,如ADSL(Asymmetric Digital Subscriber Line,非對稱數位用戶線路)數據機(又稱modem)、光纖等各種接入線路。LAN埠用來連接內部網路,主要與局域網路中的交換機、集線器或個人電腦(Personal Computer ,PC)相連。 There are two types of ports on most routers, namely Wide Area Network (WAN) and Local Area Network (LAN). The WAN port is used to connect to external networks, such as ADSL (Asymmetric Digital Subscriber Line) data machines (also known as modems), optical fibers, and other access lines. The LAN port is used to connect to the internal network, and is mainly connected to a switch, a hub or a personal computer (PC) in the LAN.

通常,很多用戶的PC都是透過路由器連接一個數據機,再連接到網際網路的。一般來說,路由器及數據機內置有設備製造商提供的私有IP(Internet Protocol,網際協定)位址。該路由器及數據機的私有IP位址可以被修改。在實際使用時,需要將路由器的WAN埠連接數據機的LAN埠,將路由器的LAN埠連接到各個PC,再將數據機的電話線(Line)埠透過電話線連接到網際網路。數據機的Line埠使用網路運營商所提供的靜態或動態公網公 有IP位址,而數據機的LAN埠使用其內置的私有IP位址。利用數據機的LAN埠的IP位址可以組建起包括路由器及各個PC在內的局域網路。路由器WAN埠使用的IP位址需要用戶設置。路由器的LAN埠可以使用其內置的私有IP位址。為正確連接到網際網路,路由器WAN埠的IP位址需要與數據機的LAN埠使用的IP位址處於相同網段而與該路由器LAN埠使用的IP位址處於不同網段。 Usually, many users' PCs connect to a modem through a router and then connect to the Internet. In general, routers and modems have built-in private IP (Internet Protocol) addresses provided by device manufacturers. The private IP address of the router and modem can be modified. In actual use, it is necessary to connect the WAN of the router to the LAN of the data machine, connect the LAN port of the router to each PC, and connect the telephone line of the data machine to the Internet through the telephone line. The line of the data machine uses the static or dynamic public network provided by the network operator. There is an IP address, and the LAN of the modem uses its built-in private IP address. The LAN address of the data plane's LAN port can be used to form a LAN path including a router and each PC. The IP address used by the router WAN requires user settings. The LAN port of the router can use its built-in private IP address. To properly connect to the Internet, the IP address of the router's WAN port needs to be on the same network segment as the IP address used by the modem's LAN port and on the different network segment used by the router's LAN port.

目前,對數據機和路由器進行管理時,需要用戶逐一登錄到數據機及路由器上,逐一地對其IP位址進行修改與設置,這無疑給用戶造成了很大的麻煩。 At present, when managing data machines and routers, users need to log in to the data machine and router one by one, and modify and set their IP addresses one by one, which undoubtedly causes great trouble to the user.

鑒於以上內容,有必要提出一種路由器及其IP位址設置方法,其可以自動設置路由器WAN埠與LAN埠的IP位址。 In view of the above, it is necessary to propose a router and its IP address setting method, which can automatically set the IP address of the router WAN埠 and LAN埠.

一種路由器IP位址設置方法,用於根據與網路相連的數據機的私有IP位址,設置與該數據機相連的路由器的WAN埠及LAN埠的IP位址。該方法包括:向上行廣播DHCP DISCOVER封包;在該DHCP DISCOVER封包得到了數據機的回應時,接收該數據機發送過來的DHCP OFFER封包;根據接收的DHCP OFFER封包解析出數據機的私有IP位址;及根據解析出來的數據機的私有IP位址設置路由器的WAN埠IP位址,使其與上述數據機的私有IP位址處於同一網段,及設置路由器的LAN埠的IP位址,使其與上述數據機的私有IP位址處於不同網段。 A router IP address setting method for setting a WAN port and a LAN port IP address of a router connected to the data machine according to a private IP address of a data machine connected to the network. The method includes: broadcasting a DHCP DISCOVER packet upward; receiving a DHCP OFFER packet sent by the data machine when the DHCP DISCOVER packet is received by the data machine; parsing the private IP address of the data machine according to the received DHCP OFFER packet And setting the router's WAN埠IP address according to the parsed private IP address of the data machine to be in the same network segment as the private IP address of the above data machine, and setting the IP address of the router's LAN port, so that It is on a different network segment than the private IP address of the above data machine.

一種路由器,其透過一個數據機與網路相連。該路由器包括:IP位址搜索模組,用於向上行廣播DHCP DISCOVER封包;資料包接收模組,用於當收到上述數據機對該DHCP DISCOVER封包的響應時接收該數據機發送過來的DHCP OFFER封包;IP位址解析模組,用於根據上述接收的DHCP OFFER封包解析出數據機的私有IP位址;IP位址設置模組,用於根據數據機的私有IP位址設置路由器的WAN埠的IP位址,使其與上述數據機的私有IP位址處於同一網段,及設置路由器的LAN埠的IP位址,使其與上述數據機的私有IP位址處於不同網段。 A router that is connected to a network through a modem. The router includes an IP address search module for broadcasting DHCP upwards. a DISCOVER packet; a data packet receiving module, configured to receive a DHCP OFFER packet sent by the data machine when receiving the response of the data machine to the DHCP DISCOVER packet; and an IP address resolution module, configured to receive the DHCP according to the foregoing The OFFER packet parses out the private IP address of the data machine; the IP address setting module is used to set the IP address of the router's WAN port according to the private IP address of the data machine to make it with the private IP address of the above data machine. In the same network segment, and set the IP address of the router's LAN port to be on a different network segment than the private IP address of the above data machine.

相較於習知技術,本發明所提供之路由器及其IP位址設置方法可以自動探測數據機的私有IP位址,並根據該數據機的私有IP位址自動設置路由器的WAN埠與LAN埠的IP位址,極大方便了用戶。 Compared with the prior art, the router provided by the present invention and its IP address setting method can automatically detect the private IP address of the data machine, and automatically set the WAN and LAN of the router according to the private IP address of the data machine. The IP address is very convenient for the user.

參閱圖1所示,係利用路由器及數據機將個人電腦連接到網路的硬體架構圖。多台個人電腦3連接到路由器2的局域網路(Local Area Network,LAN)埠21上。路由器2的廣域網路(Wide Area Network,WAN)埠20與數據機1的LAN埠11相連。數據機1的電話線(Line)埠10透過一條電話線與網路4相連。所述數據機1可以是ADSL(Asymmetrical Digital Subscriber Loop,非對稱數位用戶環線)數據機。所述網路4可以是網際網路。 Referring to Figure 1, a hardware architecture diagram of a personal computer connected to a network using a router and a data machine. A plurality of personal computers 3 are connected to a local area network (LAN) 埠 21 of the router 2. The Wide Area Network (WAN) 埠 20 of the router 2 is connected to the LAN 埠 11 of the data machine 1. The telephone line 10 of the data set 1 is connected to the network 4 via a telephone line. The data machine 1 may be an ADSL (Asymmetric Digital Subscriber Loop) data machine. The network 4 can be the internet.

參閱圖2所示,係本發明路由器較佳實施例中路由器2的功能模組圖。所述路由器2的功能模組包括IP位址搜索模組22、判斷模組23、資料包接收模組24、IP位址解析模組25、IP位址設置模組26、列表獲取模組27及IP位址驗 證模組28。所述各模組是完成特定功能的各個程式段,比軟體程式本身更適合於描述軟體在電腦中的執行過程,因此本發明對軟體程式的描述都以模組描述。 Referring to FIG. 2, it is a functional block diagram of the router 2 in the preferred embodiment of the router of the present invention. The function module of the router 2 includes an IP address search module 22, a determination module 23, a data packet receiving module 24, an IP address resolution module 25, an IP address setting module 26, and a list obtaining module 27. And IP address verification Certificate module 28. Each of the modules is a program segment that performs a specific function, and is more suitable for describing the execution process of the software in the computer than the software program itself. Therefore, the description of the software program in the present invention is described by a module.

上述路由器2中還包括一個儲存單元29。該儲存單元29內儲存有一個IP位址列表。該IP位址列表中包括數據機1的LAN埠11常用的IP位址。該常用的IP位址包括,但不限於,192.168.1.1,192.168.2.1,192.168.1.254,10.0.0.1,172.16.254.1。 The above router 2 further includes a storage unit 29. A storage list of IP addresses is stored in the storage unit 29. The IP address list includes the IP addresses commonly used by the LAN 11 of the data machine 1. The commonly used IP addresses include, but are not limited to, 192.168.1.1, 192.168.2.1, 192.168.1.254, 10.0.0.1, 172.16.2254.1.

所述的IP位址搜索模組22用於向上行廣播DHCP(Dynamic Host Configuration Protocol,動態主機分配協定)DISCOVER封包。所述上行是指由用戶端向網路方向的資訊發送。該DHCP DISCOVER封包內可能包括來源位址0.0.0.0,目的位址255.255.255.255,及該路由器2的MAC(Media Access Control,介質訪問控制)位址。當路由器2第一次透過數據機1連接到網路的時候,其不知道自己屬於哪一個網路,即不知道數據機1的LAN埠11的IP位址,所以以廣播DHCP DISCOVER封包的方式詢問數據機1的LAN埠11的IP位址。 The IP address search module 22 is configured to broadcast a DHCP (Dynamic Host Configuration Protocol) DISCOVER packet to the uplink. The uplink refers to information transmission by the UE to the network direction. The DHCP DISCOVER packet may include a source address of 0.0.0.0, a destination address of 255.255.255.255, and a MAC (Media Access Control) address of the router 2. When Router 2 connects to the network through the data machine 1 for the first time, it does not know which network it belongs to, that is, it does not know the IP address of the LAN port 11 of the data machine 1, so it broadcasts the DHCP DISCOVER packet. The IP address of the LAN port 11 of the data machine 1 is interrogated.

所述的判斷模組23用於判斷上述DHCP DISCOVER封包是否得到了數據機1的回應,以及在沒有得到數據機1回應的情況下判斷廣播該DHCP DISCOVER封包的次數是否超過了一個預設值。路由器2將第一個DHCP DISCOVER封包廣播出去之後,在規定時間內若沒有得到數據機1的回應,路由器2會根據上述的預設值廣播多次。所述預設值可以是4次。如果一直都沒有得到數據機1的回應,路由器2 會顯示錯誤資訊,宣告DHCP DISCOVER失敗。 The determining module 23 is configured to determine whether the DHCP DISCOVER packet has received a response from the data machine 1, and determine whether the number of times the DHCP DISCOVER packet is broadcast exceeds a preset value without receiving a response from the data machine 1. After the router 2 broadcasts the first DHCP DISCOVER packet, if the response of the data machine 1 is not obtained within the specified time, the router 2 broadcasts multiple times according to the preset value. The preset value may be 4 times. If you have not received a response from modem 1, router 2 An error message will be displayed, indicating that the DHCP DISCOVER failed.

所述的資料包接收模組24用於當收到數據機1的響應時接收數據機1發送過來的DHCP OFFER封包。該DHCP OFFER封包內包括有數據機1的LAN埠11的IP位址。 The data packet receiving module 24 is configured to receive the DHCP OFFER packet sent by the data machine 1 when receiving the response of the data machine 1. The DHCP OFFER packet includes the IP address of the LAN port 11 of the data machine 1.

所述的IP位址解析模組25用於根據上述接收的DHCP OFFER封包解析出數據機1的LAN埠11的IP位址。 The IP address resolution module 25 is configured to parse the IP address of the LAN port 11 of the data machine 1 according to the received DHCP OFFER packet.

所述的IP位址設置模組26用於根據上述解析出來的數據機1的LAN埠11的IP位址設置路由器2的WAN埠20的IP位址,使其與數據機1的LAN埠11的IP位址處於同一網段,及設置路由器2的LAN埠21的IP位址,使其與數據機1的LAN埠11的IP位址處於不同網段。 The IP address setting module 26 is configured to set the IP address of the WAN port 20 of the router 2 to the LAN port 11 of the data machine 1 according to the IP address of the LAN port 11 of the parsed data machine 1 described above. The IP address is in the same network segment, and the IP address of the LAN port 21 of the router 2 is set to be in a different network segment from the IP address of the LAN port 11 of the data machine 1.

所述的列表獲取模組27用於當廣播DHCP DISCOVER封包的次數超過了所述預設值之後仍然沒有收到數據機1的回應時,獲取儲存單元29中的IP位址列表。 The list obtaining module 27 is configured to obtain the IP address list in the storage unit 29 when the response of the data machine 1 is not received after the number of times the DHCP DISCOVER packet is broadcasted exceeds the preset value.

所述的IP位址驗證模組28用於向上行發送多個ARP(Address Resolution Protocol,位址解析協議)封包,逐一驗證上述IP位址列表中的IP位址是否為數據機1的LAN埠11的IP位址。其中,每一個ARP中包括一個IP位址列表中的IP位址。向上行發送ARP封包,可以查詢數據機1的LAN埠11是否使用該ARP封包中的IP位址。所述的IP位址驗證模組28還用於判斷某個ARP封包是否得到了數據機1的回復,並在收到了數據機1對某個ARP封包的回復時,確定數據機1的LAN埠11的IP位址為該ARP封包中的IP位址。該IP位址驗證模組28還用於在沒有收到數據機1 對任何一個ARP封包的回復時,假設該數據機1的LAN埠11的IP位址為一個默認的IP位址。 The IP address verification module 28 is configured to send a plurality of ARP (Address Resolution Protocol) packets to the uplink, and verify whether the IP address in the IP address list is the LAN of the data machine 1 one by one. 11 IP address. Each ARP includes an IP address in an IP address list. Sending an ARP packet to the upstream device can query whether the LAN port 11 of the data machine 1 uses the IP address in the ARP packet. The IP address verification module 28 is further configured to determine whether an ARP packet has received a reply from the data machine 1, and when the data machine 1 receives a reply to an ARP packet, determine the LAN of the data machine 1. The IP address of 11 is the IP address in the ARP packet. The IP address verification module 28 is also used to receive the data machine 1 When replying to any ARP packet, it is assumed that the IP address of the LAN port 11 of the data machine 1 is a default IP address.

上述的IP位址設置模組26還用於根據上述確定的或者假設的數據機1的LAN埠11的IP位址設置路由器2的WAN埠20的IP位址,使其與數據機1的LAN埠11的IP位址處於同一網段,及設置路由器2的LAN埠21的IP位址,使其與數據機1的LAN埠11的IP位址處於不同網段。 The IP address setting module 26 is further configured to set the IP address of the WAN port 20 of the router 2 to the LAN of the data machine 1 according to the IP address of the LAN 埠 11 of the determined or assumed data machine 1 described above. The IP address of 埠11 is in the same network segment, and the IP address of the LAN 埠21 of the router 2 is set to be in a different network segment from the IP address of the LAN 埠11 of the data machine 1.

參閱圖3所示,係本發明路由器2的IP位址設置方法較佳實施例的方法流程圖。 Referring to FIG. 3, it is a flowchart of a method of a preferred embodiment of the IP address setting method of the router 2 of the present invention.

步驟S10,IP位址搜索模組22向上行廣播DHCP DISCOVER封包。該DHCP DISCOVER封包內可能包括來源位址0.0.0.0,目的位址255.255.255.255,及該路由器2的MAC位址。 In step S10, the IP address search module 22 broadcasts a DHCP DISCOVER packet upward. The DHCP DISCOVER packet may include a source address of 0.0.0.0, a destination address of 255.255.255.255, and a MAC address of the router 2.

步驟S11,判斷模組23判斷上述DHCP DISCOVER封包是否得到了數據機1的回應。若沒有得到數據機1的回應,則流程進入步驟S15。否則,若得到了數據機1的回應時,流程進入步驟S12。 In step S11, the determining module 23 determines whether the DHCP DISCOVER packet has received a response from the data machine 1. If the response from the data machine 1 is not obtained, the flow advances to step S15. Otherwise, if a response from the data machine 1 is obtained, the flow advances to step S12.

在步驟S12中,資料包接收模組24接收數據機1發送過來的DHCP OFFER封包。該DHCP OFFER封包內包括有數據機1的LAN埠11的IP位址。 In step S12, the packet receiving module 24 receives the DHCP OFFER packet sent by the data machine 1. The DHCP OFFER packet includes the IP address of the LAN port 11 of the data machine 1.

步驟S13,IP位址解析模組25根據上述接收的DHCP OFFER封包解析出數據機1的LAN埠11的IP位址。 In step S13, the IP address resolution module 25 parses the IP address of the LAN port 11 of the data machine 1 based on the received DHCP OFFER packet.

步驟S14,IP位址設置模組26根據上述解析出來的數據機 1的LAN埠11的IP位址設置路由器2的WAN埠20的IP位址,使其與數據機1的LAN埠11的IP位址處於同一網段,及設置路由器2的LAN埠21的IP位址,使其與數據機1的LAN埠11的IP位址處於不同網段。 Step S14, the IP address setting module 26 is based on the parsed data machine. The IP address of the LAN port 11 of 1 sets the IP address of the WAN port 20 of the router 2 so that it is in the same network segment as the IP address of the LAN port 11 of the data machine 1, and sets the IP address of the LAN port 21 of the router 2. The address is placed on a different network segment than the IP address of the LAN port 11 of the data machine 1.

在步驟S15中,判斷模組23進一步判斷廣播該DHCP DISCOVER封包的次數是否超過了一個預設值。所述預設值可以是4次。若沒有超過所述預設值,則流程返回步驟S10,重新向上行廣播DHCP DISCOVER封包。否則,若超過了所述預設值時,流程進入步驟S16。 In step S15, the determining module 23 further determines whether the number of times the DHCP DISCOVER packet is broadcast exceeds a preset value. The preset value may be 4 times. If the preset value is not exceeded, the flow returns to step S10 to broadcast the DHCP DISCOVER packet again. Otherwise, if the preset value is exceeded, the flow proceeds to step S16.

在步驟S16中,列表獲取模組27獲取儲存單元29中的IP位址列表。如上所述,該IP位址列表中包括數據機1的LAN埠11常用的IP位址。該常用的IP位址包括,但不限於,192.168.1.1,192.168.2.1,192.168.1.254,10.0.0.1,172.16.254.1。 In step S16, the list acquisition module 27 acquires the IP address list in the storage unit 29. As described above, the IP address list includes the IP address commonly used by the LAN 11 of the data machine 1. The commonly used IP addresses include, but are not limited to, 192.168.1.1, 192.168.2.1, 192.168.1.254, 10.0.0.1, 172.16.2254.1.

步驟S17,IP位址驗證模組28向上行發送多個ARP封包,逐一驗證上述IP位址列表中的IP位址是否為數據機1的LAN埠11的IP位址。其中,每一個ARP封包中包括IP位址列表中的一個IP位址。 In step S17, the IP address verification module 28 sends a plurality of ARP packets to the uplink, and verifies whether the IP address in the IP address list is the IP address of the LAN port 11 of the data machine 1 one by one. Each of the ARP packets includes an IP address in the IP address list.

步驟S18,IP位址驗證模組28進一步判斷某一個ARP封包是否得到了數據機1的回復。若某一個ARP封包得到了數據機1的回復,則流程進入步驟S19。否則,在沒有收到數據機1對任何一個ARP封包的回復時,流程進入步驟S20。 In step S18, the IP address verification module 28 further determines whether a certain ARP packet has received a reply from the data machine 1. If an ARP packet receives a reply from the data machine 1, the flow advances to step S19. Otherwise, when the reply of the data machine 1 to any one of the ARP packets is not received, the flow advances to step S20.

在步驟S19中,IP位址驗證模組28確定數據機1的LAN埠 11的IP位址為該ARP封包中的IP位址。 In step S19, the IP address verification module 28 determines the LAN of the data machine 1. The IP address of 11 is the IP address in the ARP packet.

在步驟S20中,IP位址驗證模組28假設該數據機1的LAN埠II的IP位址為一個默認的IP位址。 In step S20, the IP address verification module 28 assumes that the IP address of the LAN 埠 II of the data machine 1 is a default IP address.

在步驟S14中,IP位址設置模組26根據上述確定的或者假設的數據機1的LAN埠11的IP位址設置路由器2的WAN埠20的IP位址,使其與數據機1的LAN埠11的私有IP位址處於同一網段,及設置路由器2的LAN埠21的IP位址,使其與數據機1的LAN埠11的IP位址處於不同網段。 In step S14, the IP address setting module 26 sets the IP address of the WAN port 20 of the router 2 to the LAN of the data machine 1 based on the IP address of the LAN port 11 of the determined or assumed data machine 1 described above. The private IP address of the port 11 is in the same network segment, and the IP address of the LAN port 21 of the router 2 is set to be in a different network segment from the IP address of the LAN port 11 of the data machine 1.

綜上所述,本發明符合發明專利要件,爰依法提出專利申請。惟,以上所述者僅為本發明之較佳實施例,本發明之範圍並不以上述實施例為限,舉凡熟悉本案技藝之人士援依本發明之精神所作之等效修飾或變化,皆應涵蓋於以下申請專利範圍內。 In summary, the present invention complies with the requirements of the invention patent and submits a patent application according to law. The above is only the preferred embodiment of the present invention, and the scope of the present invention is not limited to the above-described embodiments, and equivalent modifications or variations made by those skilled in the art in light of the spirit of the present invention are It should be covered by the following patent application.

1‧‧‧數據機 1‧‧‧Data machine

10‧‧‧電話線口 10‧‧‧ telephone line

11‧‧‧局域網口 11‧‧‧ LAN port

2‧‧‧路由器 2‧‧‧ router

20‧‧‧廣域網口 20‧‧‧ wide area network port

21‧‧‧局域網口 21‧‧‧ LAN port

22‧‧‧IP位址搜索模組 22‧‧‧IP address search module

23‧‧‧判斷模組 23‧‧‧Judgement module

24‧‧‧資料包接收模組 24‧‧‧ Packet Receiver Module

25‧‧‧IP位址解析模組 25‧‧‧IP address resolution module

26‧‧‧IP位址設置模組 26‧‧‧IP address setting module

27‧‧‧列表獲取模組 27‧‧‧List Acquisition Module

28‧‧‧IP位址驗證模組 28‧‧‧IP address verification module

29‧‧‧儲存單元 29‧‧‧Storage unit

3‧‧‧電腦1~N 3‧‧‧Computer 1~N

4‧‧‧網路 4‧‧‧Network

圖1係利用路由器及數據機將個人電腦連接到網路的硬體架構圖。 Figure 1 is a hardware architecture diagram of a PC and a modem to connect a personal computer to the network.

圖2係本發明路由器較佳實施例中路由器的功能模組圖。 2 is a functional block diagram of a router in a preferred embodiment of the router of the present invention.

圖3係本發明路由器IP位址設置方法較佳實施例的方法流程圖。 3 is a flow chart of a method for a preferred embodiment of a router IP address setting method of the present invention.

2‧‧‧路由器 2‧‧‧ router

22‧‧‧IP位址搜索模組 22‧‧‧IP address search module

23‧‧‧判斷模組 23‧‧‧Judgement module

24‧‧‧資料包接收模組 24‧‧‧ Packet Receiver Module

25‧‧‧IP位址解析模組 25‧‧‧IP address resolution module

26‧‧‧IP位址設置模組 26‧‧‧IP address setting module

27‧‧‧列表獲取模組 27‧‧‧List Acquisition Module

28‧‧‧IP位址驗證模組 28‧‧‧IP address verification module

29‧‧‧儲存單元 29‧‧‧Storage unit

Claims (8)

一種路由器IP位址設置方法,該方法根據與網路相連接的數據機的私有IP位址,設置與該數據機相連的路由器的廣域網路埠及局域網路埠的IP位址,其包括:路由器向上行廣播DHCP DISCOVER封包;在上述DHCP DISCOVER封包得到了數據機的回應時,接收該數據機發送過來的DHCP OFFER封包;根據接收的DHCP OFFER封包解析出數據機的私有IP位址;設置路由器的廣域網路埠IP位址,使其與數據機的私有IP位址處於同一網段,及設置路由器的局域網路埠的IP位址,使其與數據機的私有IP位址處於不同網段;當路由器廣播DHCP DISCOVER封包的次數超過了一個預設值之後仍然沒有收到數據機的回應時,獲取該路由器中儲存的IP位址列表;路由器向上行發送多個ARP封包,其中,每一個ARP封包中包括IP位址列表中的一個IP位址;當某一個ARP封包得到了數據機的回復時,確定該數據機的私有IP位址為該ARP封包中的IP位址;及設置路由器的廣域網路埠的IP位址,使其與上述確定的數據機的私有IP位址處於同一網段,及設置路由器的局域網路埠的IP位址,使其與上述確定的數據機的私有IP位址處於不同網段。 A router IP address setting method, which sets a wide area network of a router connected to the data machine and an IP address of a local area network router according to a private IP address of the data machine connected to the network, including: a router Broadcasting a DHCP DISCOVER packet to the upstream; receiving a DHCP OFFER packet sent by the data machine when the DHCP DISCOVER packet is received by the data machine; parsing the private IP address of the data machine according to the received DHCP OFFER packet; setting the router The WAN IP address is in the same network segment as the private IP address of the data machine, and the IP address of the LAN path of the router is set to be in a different network segment from the private IP address of the data machine; After the router broadcasts the DHCP DISCOVER packet more than a preset value and still does not receive a response from the data machine, it obtains a list of IP addresses stored in the router; the router sends multiple ARP packets to the uplink, wherein each ARP packet Include an IP address in the IP address list; when an ARP packet gets a reply from the data machine, determine the private I of the data machine The P address is the IP address in the ARP packet; and the IP address of the router's WAN is set to be in the same network segment as the private IP address of the determined data machine, and the router's local area network is set. The IP address is on a different network segment than the private IP address of the data machine identified above. 如申請專利範圍第1項所述之路由器IP位址設置方法,其中,所述的IP位址列表中的IP位址包括:192.168.1.1,192.168.2.1,192.168.1.254,10.0.0.1,及 172.16.254.1。 The method for setting a router IP address according to the first aspect of the patent application, wherein the IP address in the IP address list includes: 192.168.1.1, 192.168.2.1, 192.168.1.254, 10.0.0.1, and 172.16.254.1. 如申請專利範圍第1項所述之路由器IP位址設置方法,還包括:在沒有收到數據機對任何一個ARP封包的回復時,假設該數據機的私有IP位址為一個默認的IP位址;及設置路由器的廣域網路埠的IP位址,使其與上述假設的數據機的私有IP位址處於同一網段,及設置路由器的局域網路埠的IP位址,使其與上述假設的數據機的私有IP位址處於不同網段。 The method for setting the IP address of the router according to Item 1 of the patent application includes: when the reply of the data machine to any ARP packet is not received, the private IP address of the data machine is assumed to be a default IP address. Address; and set the IP address of the router's WAN to be in the same network segment as the hypothetical data machine's private IP address, and set the IP address of the router's LAN path to make the above assumptions The private IP address of the modem is on a different network segment. 一種路由器,其透過一個數據機與網路相連,該路由器包括:IP位址搜索模組,用於向上行廣播DHCP DISCOVER封包;資料包接收模組,用於當收到上述數據機對該DHCP DISCOVER封包的響應時接收該數據機發送過來的DHCP OFFER封包;IP位址解析模組,用於根據上述接收的DHCP OFFER封包解析出數據機的私有IP位址;列表獲取模組,用於當廣播DHCP DISCOVER封包的次數超過一個預設值之後仍然沒有收到數據機的回應時,獲取儲存於該路由器中的一個IP位址列表;IP位址驗證模組,用於向上行發送多個ARP封包,其中,每一個ARP封包中包括IP位址列表中的一個IP位址,以逐一驗證上述IP位址列表中的IP位址是否為數據機的私有IP位址;及IP位址設置模組,用於根據數據機的私有IP位址設置路 由器的廣域網路埠的IP位址,使其與上述數據機的私有IP位址處於同一網段,及設置路由器的局域網路埠的IP位址,使其與上述數據機的私有IP位址處於不同網段。 A router is connected to a network through a data machine, the router includes: an IP address search module for broadcasting a DHCP DISCOVER packet upward; and a data packet receiving module, configured to receive the DHCP when receiving the data machine The response of the DISCOVER packet is received by the DHCP OFFER packet sent by the data machine; the IP address resolution module is configured to parse the private IP address of the data machine according to the received DHCP OFFER packet; the list obtaining module is used when Obtaining an IP address list stored in the router when the number of times the DHCP DISCOVER packet is broadcast exceeds a preset value, and the IP address verification module is configured to send multiple ARPs to the uplink. The packet, wherein each ARP packet includes an IP address in the IP address list to verify whether the IP address in the IP address list is a private IP address of the data machine one by one; and the IP address setting mode Group, used to set the path based on the private IP address of the modem The IP address of the WAN of the router is in the same network segment as the private IP address of the above data machine, and the IP address of the router's LAN path is set to be the private IP address of the above data machine. On different network segments. 如申請專利範圍第4項所述之路由器,還包括:判斷模組,用於判斷上述DHCP DISCOVER封包是否得到了數據機的回應,以及在沒有得到數據機回應的情況下判斷廣播該DHCP DISCOVER封包的次數是否超過了所述預設值。 The router of claim 4, further comprising: a determining module, configured to determine whether the DHCP DISCOVER packet has received a response from the data machine, and determine to broadcast the DHCP DISCOVER packet without receiving a response from the data machine. Whether the number of times exceeds the preset value. 如申請專利範圍第5項所述之路由器,還包括:儲存單元,用於儲存所述包括多個IP位址的IP位址列表。 The router of claim 5, further comprising: a storage unit, configured to store the IP address list including multiple IP addresses. 如申請專利範圍第6項所述之路由器,其中,所述的IP位址列表中的IP位址包括:192.168.1.1,192.168.2.1,192.168.1.254,10.0.0.1,及172.16.254.1。 The router according to claim 6, wherein the IP address in the IP address list includes: 192.168.1.1, 192.168.2.1, 192.168.1.254, 10.0.0.1, and 172.16.254.1. 如申請專利範圍第4項所述之路由器,其中,當某個ARP封包得到了數據機的回復時,所述IP位址驗證模組確定該ARP封包中的IP位址為數據機的私有IP位址,及若沒有任何一個ARP封包得到了數據機的回復,則所述IP位址驗證模組假設該數據機的私有IP位址為一個默認的IP位址。 The router of claim 4, wherein when an ARP packet receives a reply from the data machine, the IP address verification module determines that the IP address in the ARP packet is a private IP address of the data machine. The address, and if no ARP packet is received by the modem, the IP address verification module assumes that the private IP address of the modem is a default IP address.
TW98132803A 2009-09-29 2009-09-29 Router and method of setting ip addresses of the router TWI392290B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW98132803A TWI392290B (en) 2009-09-29 2009-09-29 Router and method of setting ip addresses of the router

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW98132803A TWI392290B (en) 2009-09-29 2009-09-29 Router and method of setting ip addresses of the router

Publications (2)

Publication Number Publication Date
TW201112693A TW201112693A (en) 2011-04-01
TWI392290B true TWI392290B (en) 2013-04-01

Family

ID=44909339

Family Applications (1)

Application Number Title Priority Date Filing Date
TW98132803A TWI392290B (en) 2009-09-29 2009-09-29 Router and method of setting ip addresses of the router

Country Status (1)

Country Link
TW (1) TWI392290B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6931018B1 (en) * 2001-03-16 2005-08-16 At&T Corp. Local network router and method of routing IP data packets
US20070025372A1 (en) * 2005-08-01 2007-02-01 Manrique Brenes Remote management of a bridge device
US7548523B2 (en) * 2004-06-30 2009-06-16 Qualcomm Incorporated Dynamic configuration of IP for a terminal equipment attached to a wireless device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6931018B1 (en) * 2001-03-16 2005-08-16 At&T Corp. Local network router and method of routing IP data packets
US7548523B2 (en) * 2004-06-30 2009-06-16 Qualcomm Incorporated Dynamic configuration of IP for a terminal equipment attached to a wireless device
US20070025372A1 (en) * 2005-08-01 2007-02-01 Manrique Brenes Remote management of a bridge device

Also Published As

Publication number Publication date
TW201112693A (en) 2011-04-01

Similar Documents

Publication Publication Date Title
CN102025792B (en) Router and IP address setting method thereof
US7986649B2 (en) Method, apparatus and system for virtual network configuration and partition handover
WO2015117337A1 (en) Method and apparatus for setting network rule entry
US20060280189A1 (en) Residential gateway discovery
WO2010139238A1 (en) Method and device for implementing mac-forced forwarding
US8005083B1 (en) Applying differentiated services within a cable network using customer-aware network router
EP2362587B1 (en) Method and apparatus for realizing ARP request broadcasting limitation
US9973399B2 (en) IPV6 address tracing method, apparatus, and system
US20080101363A1 (en) Method, system and apparatus for supporting ssm forwarding in ethernet
CN102377669B (en) Method for sending message and switch
WO2006114053A1 (en) A method, system and apparatus for preventing from counterfeiting the mac address
WO2010072096A1 (en) Method and broadband access device for improving the security of neighbor discovery in ipv6 environment
US20140215047A1 (en) Packet Learning Method, Apparatus, and System
CN106713039B (en) Ethernet port identification method and device and router
JP4361803B2 (en) Method and apparatus for borrowing parameters for network address translator configuration
US8335917B2 (en) System for binding a device to a gateway to regulate service theft through cloning
CA2774281C (en) User access method, system, access server, and access device
WO2008151548A1 (en) A method and apparatus for preventing the counterfeiting of the network-side media access control (mac) address
WO2017088101A1 (en) Network access information acquiring method, and router
BR112016009822B1 (en) UNION ROUTER FOR RECEIVING PACKETS FROM A LOCAL AREA NETWORK AND SEND THEM OVER AN AGGREGATE LINK AND METHOD OF INSTALLING A UNION ROUTER IN A LOCAL AREA NETWORK
WO2014153860A1 (en) Network access method, gateway and system
WO2007006200A1 (en) A method and system for realizing the access management of the network devices
CN107995124B (en) Traffic scheduling method and device
WO2009097757A1 (en) Method and corresponding device for deploying link layer discovery protocol (lldp) management address
CN100525179C (en) Method for preventing IP address leakage