Faelin Landy
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- title: Static Routes tags: Cisco IOS, networking, manual, reference, router, switch, technical --- <header> <h6>Static Routes</h6> > [toc] </header> --- # Types of Static Route The difference between an Ethernet multi-access network and a point-to-point serial network is that a point-to-point serial network has only one other device on that network, the router at the other end of the link. With Ethernet networks, there may be many different devices sharing the same multi-access network, including hosts and even multiple routers. :::success It is recommended that when the exit interface is an Ethernet network, that the static route includes a next-hop IP address. ::: ## Next-Hop (Inferred) Route In a next-hop static route, only the next-hop IP address is specified. The exit interface is derived from the routing table. ```pug R1(config)# ip route 172.16.1.0 255.255.255.0 172.16.2.2 R1(config)# ipv6 route 2001:db8:acad:1::/64 2001:db8:acad:2::2 ``` ## Directly Connected Route When configuring a static route, a directly connected static route uses the exit interface to specify the next-hop destination. ```pug R1(config)# ip route 172.16.1.0 255.255.255.0 s0/1/0 R1(config)# ipv6 route 2001:db8:cafe:1::/64 s0/1/0 ``` :::warning Using a next-hop address is generally recommended. Directly connected static routes should only be used with point-to-point serial interfaces, as in this example. ::: ## Fully Specified Route In a fully specified static route, both the exit interface and the next-hop IP address are specified. This form of static route is used when the exit interface is a multi-access interface and it is necessary to explicitly identify the next hop. The next hop must be directly connected to the specified exit interface. ```pug R1(config)# ip route 172.16.1.0 255.255.255.0 GigabitEthernet 0/0/1 172.16.2.2 R1(config)# ipv6 route 2001:db8:acad:1::/64 s0/1/0 fe80::2 ``` :::danger If the IPv6 static route uses an **IPv6 link-local** address as the next-hop address, you _must_ create a fully specified static route. IPv6 link-local addresses are not contained in the IPv6 routing table. ::: ## Default Static Route A default route is a static route that matches all packets. Instead of routers storing routes for all of the networks in the internet, they can store a single default route to represent any network that is not in the routing table. Default routes do not require any far-left bits to match against the destination IP address. A default route is used when no other routes in the routing table match the destination IP address of the packet: if a more specific match does not exist, then the default route is used as the Gateway of Last Resort. Default static routes are commonly used when connecting an edge router to a service provider network, or a stub router (a router with only one upstream neighbor router). ```pug R1(config)# ip route 0.0.0.0 0.0.0.0 172.16.2.2 R1(config)# ipv6 route ::/0 2001:db8:acad:2::2 ``` ## Floating Static Route Floating static routes are static routes that are used to provide a backup path to a primary static or dynamic route, in the event of a link failure. The floating static route is only used when the primary route is not available. To accomplish this, the floating static route is configured with a higher administrative distance than the primary route. If multiple paths to the destination exist, the router will choose the path with the lowest administrative distance. ```pug R1(config)# ip route 172.16.1.0 255.255.255.0 172.16.2.2 5 R1(config)# ipv6 route 2001:db8:acad:1::/64 2001:db8:acad:2::2 5 ``` :::info By default, static routes have an administrative distance of `1`, making them preferable to routes learned from dynamic routing protocols. In this way, the static route “floats” and is not used when the route with the better administrative distance is active. ::: This table lists the administrative distance default values of the protocols that Cisco supports: | Route Source | Distance | | ------------ | -------------:| | Connected interface | 0 | | Static route | 1 | | Enhanced Interior Gateway Routing Protocol<br>(EIGRP) summary route | 5 | | External Border Gateway Protocol (BGP) | 20 | | Internal EIGRP | 90 | | IGRP | 100 | | OSPF | 110 | | Intermediate System-to-<br>Intermediate System (IS-IS) | 115 | | Routing Information Protocol (RIP) | 120 | | Exterior Gateway Protocol (EGP) | 140 | | On Demand Routing (ODR) | 160 | | External EIGRP | 170 | | Internal BGP | 200 | | *Unknown* | 255 | :::success If the administrative distance is 255 or greater, the router does not believe the source of that route and does not install the route in the routing table. ::: ## Static Host Route A host route is an IPv4 address with a 32-bit mask, or an IPv6 address with a 128-bit mask. When an active interface on a router is configured with an IP address, a (local) host route is automatically added to the routing table. The local routes are marked with **L** in the output of the routing table. This is in addition to the connected route, designated with a **C** in the routing table, for the network address of the interface. A host route can be a manually configured **static route** to direct traffic to a specific destination device. The static route uses a destination IP address and a 255.255.255.255 (/32) mask for IPv4 host routes, and a /128 prefix length for IPv6 host routes. ```pug R1(config)# ip route 209.165.200.238 255.255.255.255 198.51.100.2 R1(config)# ipv6 route 2001:db8:acad:2::238/128 2001:db8:acad:1::2 ``` For IPv6 static routes, the next-hop address can be the link-local address of the adjacent router. ```pug Branch(config)# ipv6 route 2001:db8:acad:2::238/128 serial 0/1/0 fe80::2 ``` :::warning If an IPv6 local host route uses an **IPv6 link-local** address as the next-hop address, you _must_ create a fully specified static route. ::: # IPv4 Configuration Command IPv4 static routes are configured using the following global configuration command: ```pug Router(config)# ip route network-address subnet-mask { ip-address | exit-intf [ip-address]} [distance] ``` The **`ip route`** command parameters are described below: | Parameter | Description | | ------------------- | -------- | | <div class='mono'>*network-address*</div> | Identifies the destination IPv4 network address of the remote network to add to the routing table. | | <div class='mono'>*subnet-mask*</div> | <ul><li>Identifies the subnet mask of the remote network.</li><li>The subnet mask can be modified to summarize a group of networks and create a summary static route.</li></ul> | | <div class='mono'>*ip-address*</div> | <ul><li>Identifies the next-hop router IPv4 address.</li><li>Typically used with broadcast networks (i.e., Ethernet).</li><li>Could create a recursive static route where the router performs an additional lookup to find the exit interface.</li></ul> | | <div class='mono'>*exit-intf*</div> | <ul><li>Identifies the exit interface to forward packets.</li><li>Creates a directly connected static route.</li><li>Typically used in a point-to-point configuration.</li></ul> | | <div class='mono'>*exit-intf ip-address*</div> | Creates a fully specified static route because it specifies the exit interface and next-hop IPv4 address. | | <div class='mono'>*distance*</div> | <ul><li>Optional command that can be used to assign an administrative distance value between 1 and 255.</li><li>Typically used to configure a floating static route by setting an administrative distance that is higher than a dynamically learned route.</li></ul> | ## Default Static Route The command syntax for an IPv4 default static route is similar to any other IPv4 static route, except that the network address is 0.0.0.0 and the subnet mask is 0.0.0.0. The 0.0.0.0 0.0.0.0 in the route will match any network address. ```pug Router(config)# ip route 0.0.0.0 0.0.0.0 {ip-address | exit-intf} ``` :::success IPv4 default static routes are commonly referred to as quad-zero routes. ::: # IPv6 Configuration Command :::warning The **`ipv6 unicast-routing`** global configuration command must be configured to enable the router to forward IPv6 packets. ::: IPv6 static routes are configured using the following global configuration command: ```pug Router(config)# ipv6 route ipv6-prefix/prefix-length {ipv6-address | exit-intf [ipv6-address]} [distance] ``` Most of parameters are identical to the IPv4 version of the command. The **`ipv6 route`** command parameters are described below: | Parameter | Description | | ------------------- | -------- | | <div class='mono'>*ipv6-prefix*</div> | Identifies the destination IPv6 network address of the remote network to add to the routing table. | | <div class='mono'>*/prefix-length*</div> | Identifies the prefix length of the remote network. | | <div class='mono'>*ipv6-address*</div> | <ul><li>Identifies the next-hop router IPv6 address.</li><li>Typically used with broadcast networks (i.e., Ethernet).</li><li>Could create a recursive static route where the router performs an additional lookup to find the exit interface.</li></ul> | | <div class='mono'>*exit-intf*</div> | <ul><li>Identifies the exit interface to forward packets.</li><li>Creates a directly connected static route.</li><li>Typically used in a point-to-point configuration.</li></ul> | | <div class='mono'>*exit-intf ipv6-address*</div> | Creates a fully specified static route because it specifies the exit interface and next-hop IPv6 address. | | <div class='mono'>*distance*</div> | <ul><li>Optional command that can be used to assign an administrative distance value between 1 and 255.</li><li>Typically used to configure a floating static route by setting an administrative distance that is higher than a dynamically learned route.</li></ul> | ## Default Static Route The command syntax for an IPv6 default static route is similar to any other IPv6 static route, except that the ipv6-prefix/prefix-length is ::/0, which matches all routes. ```pug Router(config)# ipv6 route ::/0 {ipv6-address | exit-intf} ``` # Verify a Static Route ## IPv4 ### Display Static Routes in Routing Table ```pug R1# show ip route static | begin Gateway ! Gateway of last resort is not set ! 172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks ! S 172.16.1.0/24 [1/0] via 172.16.2.2 ! S 192.168.1.0/24 [1/0] via 172.16.2.2 ! S 192.168.2.0/24 [1/0] via 172.16.2.2 R1# ``` ### Display a Specific Network ```pug ! R1# show ip route 192.168.2.1 ! Routing entry for 192.168.2.0/24 ! Known via "static", distance 1, metric 0 ! Routing Descriptor Blocks: ! * 172.16.2.2 ! Route metric is 0, traffic share count is 1 R1# ``` ### Default Static Route ```pug R1# show ip route static | begin Gateway ! Gateway of last resort is 172.16.2.2 to network 0.0.0.0 ! ! S* 0.0.0.0/0 [1/0] via 172.16.2.2 R1# ``` ### Static Route Configurations ```pug R1# show running-config | section ip route ! ip route 172.16.1.0 255.255.255.0 172.16.2.2 ! ip route 192.168.1.0 255.255.255.0 172.16.2.2 ! ip route 192.168.2.0 255.255.255.0 172.16.2.2 R1# ``` ## IPv6 ### Display Static Routes in Routing Table ```pug R1# show ipv6 route static ! IPv6 Routing Table - default - 8 entries ! <...output truncated...> ! S 2001:DB8:ACAD:1::/64 [1/0] ! via 2001:DB8:ACAD:2::2 ! S 2001:DB8:CAFE:1::/64 [1/0] ! via 2001:DB8:ACAD:2::2 ! S 2001:DB8:CAFE:2::/64 [1/0] ! via 2001:DB8:ACAD:2::2 R1# ``` ### Display a Specific Network ```pug R1# show ipv6 route 2001:db8:cafe:2:: ! Routing entry for 2001:DB8:CAFE:2::/64 ! Known via "static", distance 1, metric 0 ! Route count is 1/1, share count 0 ! Routing paths: ! 2001:DB8:ACAD:2::2 ! Last updated 00:23:55 ago R1# ``` ### Default Static Route ```pug R1# show ipv6 route static | include ::/0 ! IPv6 Routing Table - default - 8 entries ! <...output truncated...> ! S ::/0 [1/0] ! via 2001:DB8:ACAD:2::2 R1# ``` ### Static Route Configurations ```pug R1# show running-config | section ipv6 route ! ipv6 route 2001:DB8:ACAD:1::/64 2001:DB8:ACAD:2::2 ! ipv6 route 2001:DB8:CAFE:1::/64 2001:DB8:ACAD:2::2 ! ipv6 route 2001:DB8:CAFE:2::/64 2001:DB8:ACAD:2::2 R1# ``` ## Test a Floating Static Route To simulate route failure, shut down an interface used exclusively by any dynamic or primary static route for the Destination router (R2). ```pug R2(config)# interface s0/1/0 R2(config-if)# shut ! *Sep 18 23:36:27.000: %LINK-5-CHANGED: Interface Serial0/1/0, changed state to administratively down ! *Sep 18 23:36:28.000: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1/0, changed state to down R2(config-if)# interface s0/1/1 R2(config-if)# shut ! *Sep 18 23:36:41.598: %LINK-5-CHANGED: Interface Serial0/1/1, changed state to administratively down ! *Sep 18 23:36:42.598: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1/1, changed state to down ``` A look at the IP routing tables of R1 verifies that the floating static default routes are now installed as the default routes and are pointing to an alternate link (R3) as the next-hop router. ```pug R1# show ip route static | begin Gateway Gateway of last resort is 10.10.10.2 to network 0.0.0.0 S* 0.0.0.0/0 [5/0] via 10.10.10.2 R1# show ipv6 route static | begin :: S ::/0 [5/0] via 2001:DB8:FEED:10::2 R1# ``` --- --- {%hackmd 7PGmjAHeTXak2VUM3iw5Wg %}

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully