Senin, 31 Maret 2008

Configuring the Default Route

You can see two dynamic (D) kernel (K) routes, which have been added automatically when the addresses were added:

[MikroTik] ip route> print                                                    
Flags: X - disabled, I - invalid, D - dynamic, R - rejected
# TYPE DST-ADDRESS NEXTHOP-S... GATEWAY DISTANCE INTERFACE
0 D connect 192.168.0.0/24 A 0.0.0.0 0 Local
1 D connect 10.1.1.0/24 A 0.0.0.0 0 Public
[MikroTik] ip route> print detail
Flags: X - disabled, I - invalid, D - dynamic, R - rejected
0 D dst-address=192.168.0.0/24 gateway=0.0.0.0 nexthop-state=A
preferred-source=192.168.0.254 interface=Local distance=0 type=connect

1 D dst-address=10.1.1.0/24 gateway=0.0.0.0 nexthop-state=A
preferred-source=10.1.1.12 interface=Public distance=0 type=connect

[MikroTik] ip route>

These routes show, that IP packets with destination to 10.1.1.0/24 would be sent through the interface Public, whereas IP packets with destination to 192.168.0.0/24 would be sent through the interface Local. However, you need to specify where the router should forward packets, which have destination other than networks connected directly to the router. This is done by adding the default route (destination 0.0.0.0, netmask 0.0.0.0). In this case it is the ISP's gateway 10.1.1.254, which can be reached through the interface Public:

[MikroTik] ip route> add gateway=10.1.1.254      
[MikroTik] ip route> print
Flags: X - disabled, I - invalid, D - dynamic, R - rejected
# TYPE DST-ADDRESS NEXTHOP-S... GATEWAY DISTANCE INTERFACE
0 static 0.0.0.0/0 A 10.1.1.254 1 Public
1 D connect 192.168.0.0/24 A 0.0.0.0 0 Local
2 D connect 10.1.1.0/24 A 0.0.0.0 0 Public
[MikroTik] ip route>

Here, the default route is listed under #0. As we see, the gateway 10.1.1.254 can be reached through the interface 'Public'. If the gateway would have been specified incorrectly, the value for the argument 'interface' would be unknown. Note, that you cannot add two routes to the same destination, i.e., destination-address/netmask! It applies to the default routes as well. Instead, you can enter multiple gateways for one destination. For more information on IP routes, please read the relevant topic in the Manual.

If you have added an unwanted static route accidentally, use the 'remove' command to delete the unneeded one. Do not remove the dynamic (D) routes! They are added automatically and should not be deleted 'by hand'. If you happen to, then reboot the router, the route will show up again.