Working with Static Routes

Hands-On Lab

 

Photo of Michael Christian

Michael Christian

Course Development Director in Content

Length

01:00:00

Difficulty

Intermediate

In this learning activity, you will need to create a script that modifies the routing table, to prohibit connectivity to google.com. You'll also add an entry to use 10.0.1.20 as the gateway for the 10.0.8.0/24 subnet.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Working with Static Routes

Introduction

In this hands-on lab, you will need to create a script that modifies the routing table to prohibit connectivity to google.com. You'll also add an entry to use 10.0.1.20 as the gateway for the 10.0.8.0/24 subnet.

Solution

  1. Begin by logging in to the lab server using the credentials provided on the hands-on lab page:

    ssh cloud_user@PUBLIC_IP_ADDRESS

  2. Become the root user:

    sudo su -

View the routing table, and prohibit connectivity to google.com.

  1. You can view the routing table using the following command:

    ip route show

  2. You should install the bind-utils package which includes the host command, to get the IPs associated with google.com.

    host google.com

  3. Once you have the IP address(es), you can prohibit connectivity to them using the following command:

    ip route add prohibit <IP_ADDRESS>

Add an entry for the 10.0.8.0/24 network to use 10.0.1.20 as the gateway

  1. Add the following entry:

    ip route add 10.0.8.0/24 via 10.0.1.20

Write a script that creates both entries

  1. Using a text editor like vim, create and edit the file /home/cloud_user/routes.sh :

    #!/bin/bash
    
    ip route add prohibit <GOOGLE_IP>
    ip route add 10.0.8.0/24 via 10.0.1.20

Conclusion

Congratulations — you've completed this hands-on lab!