![路由表使用哪个范围](https://linux22.com/image/591613/%E8%B7%AF%E7%94%B1%E8%A1%A8%E4%BD%BF%E7%94%A8%E5%93%AA%E4%B8%AA%E8%8C%83%E5%9B%B4.png)
我有 2 个接口。一个用于 WAN,另一个用于 Internet(这个没有国家互联网交换中心路由)。我通常会从我所在地区的同行那里找到 IP,然后在亚太互联网络信息中心。我只使用了 2 个字段,互联网和路线。
例如我搜索这个 IP XXX.YYY.7.117。在 apnic 上搜索这个,我发现以下两个字段。
inetnum: XXX.YYY.0.0 - XXX.YYY.31.255
route: XXX.YYY.7.0/24
我想要的是将这些 IP(inetnum)的所有流量传递到 WAN 接口。如果我计算范围,我会发现 CIDR 表示法XXX.YYY.0.0/19
。因此XXX.YYY.0.0/19
包含在 inetnum 范围内找到的所有 IP。但路由有XXX.YYY.7.0/24
。两者不同。将其添加到路由表时应该使用哪一个?
以下哪个命令可以满足我的目的?
route add -net `XXX.YYY.0.0/19` gw MY_IP dev WAN
route add -net `XXX.YYY.7.0/24` gw MY_IP dev WAN
答案1
当我查找 58.97.129.36 时,前缀长度没有任何问题……APNIC 将此列为阻止/17
。因此,您应该将此路由添加为/17
适当的 WAN/MAN 连接。
您确实应该考虑在 WAN 接口上设置静态默认值,然后在 MAN 上运行 BGP,使用动态协议管理路由要容易得多。这需要真正的路由器(而不是您现在正在使用的主机级路由),但我认为从长远来看,您将拥有一个更易于维护的网络。
$ gwhois -h whois.arin.net 58.97.129.36
Process query: '58.97.129.36'
Querying whois.arin.net:43 with whois.
Querying whois.apnic.net:43 with whois.
% [whois.apnic.net node-3]
% Whois data copyright terms http://www.apnic.net/db/dbcopyright.html
inetnum: 58.97.128.0 - 58.97.255.255
netname: BANGLALION-WIMAX-BD
descr: Silver Tower (16 & 18th Floor)
country: BD
admin-c: BCLn1-AP
tech-c: BCLn1-AP
status: ALLOCATED PORTABLE
remarks: Used for WiMAX
mnt-by: APNIC-HM
mnt-lower: MAINT-BANGLALION-WIMAX-BD
mnt-routes: MAINT-BANGLALION-WIMAX-BD
mnt-irt: IRT-BANGLALION-WIMAX-BD
remarks: -+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+
remarks: This object can only be updated by APNIC hostmasters.
remarks: To update this object, please contact APNIC
remarks: hostmasters and include your organisation's account
remarks: name in the subject line.
remarks: -+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+
changed: [email protected] 20110107
source: APNIC
route: 58.97.128.0/17
descr: Route Object for 58.97.128.0.0/17
origin: AS45904
country: BD
remarks: New /17 block of Banglalion WiMAX
mnt-lower: MAINT-BANGLALION-WIMAX-BD
mnt-routes: MAINT-BANGLALION-WIMAX-BD
mnt-by: MAINT-BANGLALION-WIMAX-BD
changed: [email protected] 20110117
source: APNIC
role: BANGLALION COMMUNICATIONS LTD - network administr
address: Silver Tower (16 & 18th Floor), 52 Gulshan Avenue, Gulshan, Dhaka-1212. Bangladesh.
country: BD
phone: +88028816349
fax-no: +8802-9885647
e-mail: [email protected]
admin-c: BCLn1-AP
tech-c: AHC2-AP
nic-hdl: BCLn1-AP
mnt-by: MAINT-BANGLALION-WIMAX-BD
changed: [email protected] 20090831
source: APNIC
changed: [email protected] 20100825
--
To resolve one of the above handles: whois -h whois.arin.net HANDLE
OTOH offical handles should be recognised directly.
Please report errors or misfits via the debian bug tracking system.
$ gwhois -h whois.arin.net 123.200.7.22
Process query: '123.200.7.22'
Querying whois.arin.net:43 with whois.
Querying whois.apnic.net:43 with whois.
% [whois.apnic.net node-2]
% Whois data copyright terms http://www.apnic.net/db/dbcopyright.html
inetnum: 123.200.0.0 - 123.200.31.255
netname: LINK3
descr: Link3 Technologies Ltd.
descr: Internet Service Provider, Dhaka, Bangladesh
country: BD
admin-c: SP349-AP
tech-c: SP349-AP
mnt-by: APNIC-HM
mnt-lower: MAINT-BD-LINK3
mnt-routes: MAINT-BD-LINK3
status: ALLOCATED PORTABLE
remarks: -+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+
remarks: This object can only be updated by APNIC hostmasters.
remarks: To update this object, please contact APNIC
remarks: hostmasters and include your organisation's account
remarks: name in the subject line.
remarks: -+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+
changed: [email protected] 20070111
source: APNIC
route: 123.200.7.0/24
descr: route object for 123.200.7.0/24
country: BD
origin: AS23688
mnt-lower: MAINT-BD-LINK3
mnt-routes: MAINT-BD-LINK3
mnt-by: MAINT-BD-LINK3
changed: [email protected] 20110829
source: APNIC
person: Sajjid Pasha
address: Bulu Ocean Tower, 17th Floor,
address: 40, Kemal Ataturk Avenue, Banani,
address: Dhaka 1213
address: Bangladesh
country: BD
phone: +88-02-9894500
fax-no: +88-02-9888642
e-mail: [email protected]
nic-hdl: SP349-AP
mnt-by: MAINT-BD-LINK3
changed: [email protected] 20101127
source: APNIC
--
To resolve one of the above handles: whois -h whois.arin.net HANDLE
OTOH offical handles should be recognised directly.
Please report errors or misfits via the debian bug tracking system.
$ telnet route-views.oregon-ix.net
Trying 128.223.51.103...
Connected to route-views.oregon-ix.net.
Escape character is '^]'.
**********************************************************************
Oregon Exchange BGP Route Viewer
route-views.oregon-ix.net / route-views.routeviews.org
route views data is archived on http://archive.routeviews.org
This hardware is part of a grant from Cisco Systems.
Please contact [email protected] if you have questions or
comments about this service, its use, or if you might be able to
contribute your view.
This router has views of the full routing tables from several ASes.
The list of ASes is documented under "Current Participants" on
http://www.routeviews.org/.
**************
route-views.routeviews.org is now using AAA for logins. Login with
username "rviews". See http://routeviews.org/aaa.html
**********************************************************************
User Access Verification
Username: rviews
route-views>sh ip route 123.200.7.22
Routing entry for 123.200.0.0/21
Known via "bgp 6447", distance 20, metric 0
Tag 1239, type external
Last update from 144.228.241.130 1d21h ago
Routing Descriptor Blocks:
* 144.228.241.130, from 144.228.241.130, 1d21h ago
Route metric is 0, traffic share count is 1
AS Hops 7
Route tag 1239
route-views>