Configuring static routes on Juniper

After having a complete detail about the difference between the routing table and the forwarding table, it is time to learn how to configure static routes on the Juniper device.

I do have 2 Juniper routers connected to each other on the ge-0/0/2 interfaces. Each router has a loopback interface acting as a network on each device.

The goal of this LAB is to be able to ping from 1.1.1.1 to 2.2.2.2 and vice versa. Without doing any routing, whenever the packet comes from 1.1.1.1 to R1 router asking to go to 2.2.2.2, then R1 will check if his forwarding table that there is no entry to 2.2.2.2 and will drop the packet. Same happens on R2 if 2.2.2.2 want to reach to 1.1.1.1, it will drop the packet.

Let’s start by putting IP addresses on R1 then on R2:

root@R1# set interfaces ge-0/0/2 unit 0 family inet address 192.168.12.1/24

[edit]

root@R1# set interfaces lo0 unit 0 family inet address 1.1.1.1/32

[edit]

root@R1# commit

commit complete

[edit]

root@R1#

 

root@R2# set interfaces ge-0/0/2 unit 0 family inet address 192.168.12.2/24

root@R2# set interfaces lo0 unit 0 family inet address 2.2.2.2/32

[edit]

root@R2# commit

Both R1 and R2 have the IP addresses configured on them.

Let’s ping from R1 to R2 on its IP address 192.168.12.2 to check if there is reachability.

root@R1# run ping 192.168.12.2

PING 192.168.12.2 (192.168.12.2): 56 data bytes

64 bytes from 192.168.12.2: icmp_seq=0 ttl=64 time=27.382 ms

64 bytes from 192.168.12.2: icmp_seq=1 ttl=64 time=5.586 ms

64 bytes from 192.168.12.2: icmp_seq=2 ttl=64 time=2.446 ms

64 bytes from 192.168.12.2: icmp_seq=3 ttl=64 time=5.046 ms

64 bytes from 192.168.12.2: icmp_seq=4 ttl=64 time=5.008 ms

64 bytes from 192.168.12.2: icmp_seq=5 ttl=64 time=2.425 ms

^C

— 192.168.12.2 ping statistics —

6 packets transmitted, 6 packets received, 0% packet loss

round-trip min/avg/max/stddev = 2.425/7.982/27.382/8.766 ms

[edit]

root@R1#

The ping is working perfectly.

Now we need to start configuring the static routes. The 1st static route that I need to configure is on R1 to say that anything that want to go to 2.2.2.2/32 then send it to the next hope of the router (the gateway) which is the IP address 192.168.12.2 of interface ge-0/0/2

Let’s do that:

root@R1# edit routing-options

[edit routing-options]

root@R1# set static route 2.2.2.2/32 next-hop 192.168.12.2

[edit routing-options]

root@R1# show

static {

route 2.2.2.2/32 next-hop 192.168.12.2;

}

[edit routing-options]

root@R1# commit

commit complete

[edit routing-options]

root@R1#

Now R1 has a static route to reach 2.2.2.2 but the ping will not work because R1 will send the ping packet to 2.2.2.2, then R2 has to answer back to 1.1.1.1 with a ping reply but he does not know anything about 1.1.1.1, then R2 will drop the packet. So we have to create a route back from R2, you got it?

I will use a default static route on R2 to say that if you want to go to anywhere, your gateway is R1.

root@R2# edit routing-options

[edit routing-options]

root@R2# set static route 0.0.0.0/0 next-hop 192.168.12.1

[edit routing-options]

root@R2# show

static {

route 0.0.0.0/0 next-hop 192.168.12.1;

}

[edit routing-options]

root@R2# commit

commit complete

[edit routing-options]

root@R2#

Excellent!

Both routers have now the routes configure, let’s try to ping from 1.1.1.1 to 2.2.2.2 and see if it will work:

root@R1> ping source 1.1.1.1 2.2.2.2

PING 2.2.2.2 (2.2.2.2): 56 data bytes

64 bytes from 2.2.2.2: icmp_seq=0 ttl=64 time=9.284 ms

64 bytes from 2.2.2.2: icmp_seq=1 ttl=64 time=2.891 ms

64 bytes from 2.2.2.2: icmp_seq=2 ttl=64 time=5.249 ms

64 bytes from 2.2.2.2: icmp_seq=3 ttl=64 time=3.851 ms

64 bytes from 2.2.2.2: icmp_seq=4 ttl=64 time=5.564 ms

^C

— 2.2.2.2 ping statistics —

5 packets transmitted, 5 packets received, 0% packet loss

round-trip min/avg/max/stddev = 2.891/5.368/9.284/2.183 ms

root@R1>

I made a ping on R1 to come from the source IP 1.1.1.1 and to go to 2.2.2.2 and I got a reply.

Let’s do now from R2:

root@R2> ping source 2.2.2.2 1.1.1.1

PING 1.1.1.1 (1.1.1.1): 56 data bytes

64 bytes from 1.1.1.1: icmp_seq=0 ttl=64 time=2.645 ms

64 bytes from 1.1.1.1: icmp_seq=1 ttl=64 time=2.134 ms

64 bytes from 1.1.1.1: icmp_seq=2 ttl=64 time=4.632 ms

64 bytes from 1.1.1.1: icmp_seq=3 ttl=64 time=6.079 ms

^C

— 1.1.1.1 ping statistics —

4 packets transmitted, 4 packets received, 0% packet loss

round-trip min/avg/max/stddev = 2.134/3.872/6.079/1.579 ms

root@R2>

Also from R2, I can ping from the IP address 2.2.2.2 to the IP address of 1.1.1.1.

This means that our routing is working perfectly 😊

This is all what I wanted to show in this lesson, hope you enjoyed it and see you in the upcoming one.

Course Content

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

About