Options

static and default route

cb3dwacb3dwa Member Posts: 80 ■■□□□□□□□□
these are the only questions i struggle with would any one offer any tips on how to remember format etc

thanks

Comments

  • Options
    martell1000martell1000 Member Posts: 389
    in a static route you need to define where you want to go and how you are going to get there.
    eg you want to go to the 192.168.2.0 network using interface 10.1.1.1 you go

    ip route 192.168.2.0 255.255.255.0 10.1.1.1

    a default route is just a static route using zeros as wildcards followed by the route you wanna take in our case:

    ip route 0.0.0.0 0.0.0.0 10.1.1.1



    you can also define the interface instead of an ip address:

    ip route 0.0.0.0 0.0.0.0 serial 0/0
    And then, I started a blog ...
  • Options
    SharkDiverSharkDiver Member Posts: 844
    I am not sure exactly what you are asking, but I'll try to answer.

    A static route is created using the following format.
    ip route x.x.x.x y.y.y.y z.z.z.z
    or
    ip route x.x.x.x y.y.y.y (interface type) z/z

    The x.x.x.x is the ip address of the network or the host
    The y.y.y.y is the subnet mask
    The z.z.z.z is the next-hop address

    If you want to create static route to host 192.168.1.1 by sending traffic to the router with ip address 10.10.10.10, you would enter
    ip route 192.168.1.1 255.255.255.255 10.10.10.10
    That tells your router to send all traffic bound for 192.168.1.1 with a subnet mask of 255.255.255.255 to the next-hop of 10.10.10.10

    If you want all traffic bound for the entire 192.168.1.x network, you would change it to
    ip route 192.168.1.0 255.255.255.0 10.10.10.10

    You can also choose which interface you want the traffic to exit your router, rather than typing the next-hop address of the next router.

    To send all traffic for network 192.168.1.x out of your Serial 0/1 interface, you would type:
    ip route 192.168.1.0 255.255.255.0 serial 0/1

    All of the above are static routes.
    If you want to create a default static route, you would simply type:
    ip route 0.0.0.0 0.0.0.0 10.10.10.10
    or
    ip route 0.0.0.0 0.0.0.0 serial 0/1

    These would send any traffic that doesn't have a specific entry in the routing table to next-hop address 10.10.10.10 or out of interface serial 0/1.

    I hope that helps. If you were looking for something else, please elaborate.
  • Options
    cb3dwacb3dwa Member Posts: 80 ■■□□□□□□□□
    thats grate,

    what about when its 0.0.0.0 255.255.255.255 129.234.2.1?
  • Options
    SharkDiverSharkDiver Member Posts: 844
    Wow! Good question.

    I can only make an educated guess on this one.

    Using what I know about subnet masks, I would think that the IP address could be almost anything if the subnet mask was 0.0.0.0, because the mask would mean to pay attention to no bits in the address. I would think that:
    255.255.255.255 0.0.0.0 129.234.2.1 would still send all traffic that didn't match a more specific route to next-hop address 129.234.2.1.

    Your scenario is the opposite however.

    Being that the subnet mask 255.255.255.255 indicates a host, I would assume that 0.0.0.0 255.255.255.255 would specify a host with the IP address 0.0.0.0. Since I don't believe that any traffic would ever be going to a host at 0.0.0.0, I would think this command would do nothing.

    Anyone else have a take on this?
  • Options
    fsanyeefsanyee Member Posts: 171
    cb3dwa wrote: »
    thats grate,

    what about when its 0.0.0.0 255.255.255.255 129.234.2.1?

    It doesn't make any sense.
  • Options
    Forsaken_GAForsaken_GA Member Posts: 4,024
    SharkDiver wrote: »
    Wow! Good question.

    Using what I know about subnet masks, I would think that the IP address could be almost anything if the subnet mask was 0.0.0.0, because the mask would mean to pay attention to no bits in the address. I would think that:
    255.255.255.255 0.0.0.0 129.234.2.1 would still send all traffic that didn't match a more specific route to next-hop address 129.234.2.1.

    No. That's an invalid subnet mask. Your prefix has to match your mask.

    Rack7R1(config)#ip route 255.255.255.255 0.0.0.0 155.7.0.5
    %Inconsistent address and mask

    (I changed the next hop IP to something that's actually in my routing table, in case the command actually took)

    For example, you cannot specify ip route 192.168.12.0 255.0.0.0 192.168.1.1

    You're only using 8 bits for masking in that example, but you're trying to define at least 24 bits in the prefix. In the above example, the mask would need to be 255.255.255.0 or the prefix would need to be 192.0.0.0 in order for the router to accept the command.

    In particular ,trying to route to 255.255.255.255 isn't going to work because it's a broadcast address.

    Rack7R1(config)#ip route 255.255.255.255 255.255.255.255 155.7.0.5
    %Invalid destination prefix

    And this holds true for anything above the class C space -

    Rack7R1(config)#ip route 223.255.255.252 255.255.255.252 155.7.0.5
    Rack7R1(config)#ip route 224.0.0.0 255.0.0.0 155.7.0.5
    %Invalid destination prefix

    As you can see, I can route to the very top of the Class C defined space, but the second I try to get into Class D (which is multicast space), the router is smart enough to tell me im an idiot.
    thats grate,

    what about when its 0.0.0.0 255.255.255.255 129.234.2.1?

    Surprisingly, this takes - again, I'm changing the next hop to something in my routing table so it'll actually show up

    Rack7R1(config)#ip route 0.0.0.0 255.255.255.255 155.7.0.5
    Rack7R1(config)#do sh ip ro | i 0.0
    S 0.0.0.0/32 [1/0] via 155.7.0.5

    So let's see what happens when I try to use it. Since I'm routing that prefix towards Router 5, I went ahead and defined an IP on a new loopback on R5.

    Rack7R5#sh ip int b | i Loop
    Loopback0 150.7.5.5 YES NVRAM up up
    Loopback100 129.234.2.1 YES manual up up
    Rack7R5#

    So let's see what happens when I try to actually use it -

    Rack7R1#ping 129.234.2.1

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 129.234.2.1, timeout is 2 seconds:
    .....
    Success rate is 0 percent (0/5)
    Rack7R1#trace 129.234.2.1

    Type escape sequence to abort.
    Tracing the route to 129.234.2.1

    1 * * *
    2 * * *
    3 *
    Rack7R1#
    Rack7R1#
    Rack7R1#debug ip pack
    Rack7R1#debug ip packet det
    Rack7R1#debug ip packet detail
    IP packet debugging is on (detailed)
    Rack7R1#ping 129.234.2.1

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 129.234.2.1, timeout is 2 seconds:

    *Mar 1 03:28:13.620: IP: s=150.7.1.1 (local), d=129.234.2.1, len 100, unroutable
    *Mar 1 03:28:13.624: ICMP type=8, code=0.
    *Mar 1 03:28:15.623: IP: s=150.7.1.1 (local), d=129.234.2.1, len 100, unroutable
    *Mar 1 03:28:15.623: ICMP type=8, code=0
    *Mar 1 03:28:16.272: IP: s=155.7.146.1 (local), d=224.0.0.5 (FastEthernet0/0), len 76, sending broad/multicast, proto=89
    *Mar 1 03:28:16.276: IP: s=155.7.13.1 (local), d=224.0.0.5 (Serial1/1), len 80, sending broad/multicast, proto=89.
    *Mar 1 03:28:16.829: IP: s=155.7.13.3 (Serial1/1), d=224.0.0.5, len 80, rcvd 0, proto=89
    *Mar 1 03:28:17.627: IP: s=150.7.1.1 (local), d=129.234.2.1, len 100, unroutable
    *Mar 1 03:28:17.627: ICMP type=8, code=0.
    *Mar 1 03:28:19.626: IP: s=150.7.1.1 (local), d=129.234.2.1, len 100, unroutable
    *Mar 1 03:28:19.626: ICMP type=8, code=0.
    *Mar 1 03:28:21.629: IP: s=150.7.1.1 (local), d=129.234.2.1, len 100, unroutable
    *Mar 1 03:28:21.629: ICMP type=8, code=0.
    Success rate is 0 percent (0/5)
    Rack7R1#

    Nothing it says the prefix is unroutable.

    Alright, so what if I change it to a proper default route -

    Rack7R1(config)#no ip route 0.0.0.0 255.255.255.255 155.7.0.5
    Rack7R1(config)#ip route 0.0.0.0 0.0.0.0 155.7.0.5
    Rack7R1(config)#do ping 129.234.2.1

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 129.234.2.1, timeout is 2 seconds:
    !!!!!

    Works just fine.

    So yeah, defining an all 0's prefix with a 32 bit mask is essentially meaningless, as nothing can be addressed as 0.0.0.0, so nothing will ever get routed directly to it.
  • Options
    SharkDiverSharkDiver Member Posts: 844
    Forsaken,

    Good catch. I was speaking more theoretically. I wasn't really thinking about whether the router would accept the command.
    Thanks, for the clarification.
Sign In or Register to comment.