Select Primary (root) compartment à Networking à Virtual Cloud Networks à Primary VCN à Local Peering
Gateway
Click Create Local
Peering Gateway as shown in Figure 31
Figure 31 Create Local Peering Gateway
Figure 32 Create PrimaryLPG1 – Local Peering Gateway in Primary
compartment
Now switch to
Secondary compartment and create Local peering gateway as follows:
Select Secondary
compartment -> Networking -> Virtual Cloud Networks -> SecondaryVCN2 ->
Local Peering Gateway.
Click Create Local
Peering Gateway as shown in Figure 33
Figure 33 Create Local Peering Gateway
Figure 34 Create SecondaryLPG1 – Local Peering Gateway in
Secondary compartment
Confirm that the SecondaryLPG1 is created
successfully and status is Available as shown in Figure35
Figure 35 Secondary Local Peering Gateway creation confirmation
Switch to Primary (root) compartment à Networking à Virtual Cloud
Networks à Primary VCN à Local Peering Gateway à Click Establish Connection. (Figure 36 and 37
are for reference)
Figure 36 Establish Connection between Local Peering Gateways
Figure 37 Setup Connection with Secondary Local Peering Gateway
You need to
establish connection only once between two LPGs and it doesn’t really matter
which LPG you pick to establish the connection from.
Figure 38 Perring confirmation between Local Peering Gateways
So far, we have
created LPGs and bridged a connection between LPGs but the instances in the two
VCNs cannot communicate yet due to the Firewall restrictions. In this section
we will configure Route tables and modify Security Lists to ease Firewall restrictions
and allow network traffic from the instances to passthrough Local Peering
Gateway. In our example we are using default Route tables and we will modify
the default route table in our Primary & Secondary VCN to allow destination
LPG CIDR traffic to pass through.
Select Secondary
compartment à Networking à Virtual Cloud Networks à SecondaryVCN2 à Route Tables à Default Route
Table
Add new Route Rule to route network traffic from
SecondaryLPG1 to destination CIDR block 10.0.0.0/24 as shown in Figure 39.
Figure 39 Add Route rule to route Secondary LPG traffic
Figure 40 Route rule addition confirmation for SecondaryLPG1
traffic
Figure 41 Add Route rule to route Primary LPG traffic
Select Primary
(root) compartment à Networking à Virtual Cloud Networks à Primary VCN à Route Tables à Default Route
Table.
Add new Route Rule
to route network traffic from PrimaryLPG1 to destination CIDR block 20.0.0.0/24
as shown in Figure 42.
Figure 42 Add Route rule to allow PrimaryLPG1 traffic
Now edit Default security list in SecondaryVCN2
to allow all protocols from CIDR block range 10.0.0.0/24 into SecondaryVCN2.
Figure 43 Security List modification in SecondaryVCN2
Select Secondary
compartment Networking Virtual Cloud Networks SecondaryVCN2 à Default Security List à Add Rule.
Add rule to allow all protocols from CIDR block range 10.0.0.0/24 into
SecondaryVCN2 as shown in Figure 44.
Figure 44 Add security Rule in SecondaryVCN2
Now edit Default
security list in Primary VCN to allow all protocols from CIDR block range
20.0.0.0/24 into primary VCN.
Figure 45 Modify Security List in Primary VCN
Select Primary
(root) compartment à Networking à Virtual Cloud Networks à Primary VCN à Default Security List à Add Rule.
Add rule to allow
all protocols from CIDR block range 20.0.0.0/24 into Primary VCN as shown in Figure
46.
Figure 46 Add security Rule in Primary VCN
Note down the
public and Private IP addresses of instances in PrimaryVCN and SecondaryVCN.
Login into
PrimaryVM1 as opc user and ping the private IP address of the SecondaryVM1 you
should be able to see the packet response from SecondaryVM1.
Figure 47 PrimaryVM1 IP addresses
[opc@primaryvm1 ~]$ ifconfig -a
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9000
inet 10.0.0.2 netmask 255.255.255.0 broadcast 10.0.0.255
ether
02:00:17:01:9e:6d txqueuelen 1000 (Ethernet)
RX packets 56766 bytes 328814777 (313.5 MiB)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 48827 bytes 124483559 (118.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 0
(Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
[opc@primaryvm1 ~]$ ping 20.0.0.2
PING 20.0.0.2 (20.0.0.2) 56(84) bytes of data.
64 bytes from 20.0.0.2: icmp_seq=1 ttl=64 time=0.212 ms
64 bytes from 20.0.0.2: icmp_seq=2 ttl=64 time=0.175 ms
64 bytes from 20.0.0.2: icmp_seq=6 ttl=64 time=0.177 ms
64 bytes from 20.0.0.2: icmp_seq=7 ttl=64 time=0.140 ms
64 bytes from 20.0.0.2: icmp_seq=8 ttl=64 time=0.145 ms
^C
--- 20.0.0.2 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 6999ms
rtt min/avg/max/mdev = 0.140/0.173/0.212/0.025 ms
Figure 48 SecondaryVM1 IP addresses
[opc@secondaryvm1
~]$ ifconfig -a
ens3:
flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9000
inet 20.0.0.2 netmask 255.255.255.0 broadcast 20.0.0.255
ether 02:00:17:01:53:5a txqueuelen 1000 (Ethernet)
RX packets 57725 bytes 328343608 (313.1 MiB)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 54826 bytes 181204328 (172.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
lo:
flags=73<UP,LOOPBACK,RUNNING> mtu
65536
inet 127.0.0.1 netmask 255.0.0.0
loop
txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
[opc@secondaryvm1
~]$ ping 10.0.0.2
PING 10.0.0.2
(10.0.0.2) 56(84) bytes of data.
64 bytes from
10.0.0.2: icmp_seq=1 ttl=64 time=0.222 ms
64 bytes from
10.0.0.2: icmp_seq=2 ttl=64 time=0.172 ms
64 bytes from
10.0.0.2: icmp_seq=3 ttl=64 time=0.166 ms
64 bytes from
10.0.0.2: icmp_seq=4 ttl=64 time=0.205 ms
64 bytes from
10.0.0.2: icmp_seq=5 ttl=64 time=0.157 ms
64 bytes from
10.0.0.2: icmp_seq=13 ttl=64 time=0.171 ms
^C
--- 10.0.0.2 ping
statistics ---
13 packets
transmitted, 13 received, 0% packet loss, time 11999ms
rtt
min/avg/max/mdev = 0.137/0.172/0.222/0.027 ms
Figure 49 Inter instance
communication via LPGs
We will generate ssh rsa keys without any passphrase for simplicity
and then add the public key id_rsa.pub into PrimaryVM1’s ~/.ssh/authorized_keys
file to enable password less login for opc user.
[opc@secondaryvm1
~]$ pwd
/home/opc
[opc@secondaryvm1
~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key
(/home/opc/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in
/home/opc/.ssh/id_rsa.
Your public key has been saved in
/home/opc/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:iOniHDTl09z/2kc9X5cw8tia9RmfmrcmW9jPZq0GT+w
opc@secondaryvm1
The key's randomart image is:
+---[RSA 2048]----+
| |
| |
|
. |
| o =
o . o
|
| o = +
S =.o..|
| . o .
. ..+*++|
| o
. . +B.o@|
| o o
= .EBB|
|
o ..o*B=+|
+----[SHA256]-----+
[opc@secondaryvm1
~]$ cat .ssh/id_rsa.pub
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQCap+PEKhwVbvP05Gikv6toUq6POzUmuwgh8FrnILBkCmKfWLQRChmcUNlCvEG7Wqc2SUW6lefHhNpcIkrT/Q/TDwkhVN5HMupgU0oJZEP1fUH/xj365deQJrZPWCa1ZzPGEozj76kcqYOqPMVSbtc0O4znuyXvFeZBcwmFiwzp0LcAOeJlfvTKBXe0y3+7CHYgJzjMgfPZgPbMUu40LdBlHS3kEVkRwWlOSJFxjGrZyl0FbX74jHFQ1RDy/LYjXeZvZdyqjYdpwNw6t0LEFHjYAy50gOkrw9SDwsDR2QJOxXiZ7ccz0WoBSI2Hp9FQXmlnk7stWS0t9xNe2XevRdsF
opc@secondaryvm1
Either
scp public key or copy and paste into authorized_keys file in primaryVM1 host.
[opc@primaryvm1
~]$ vi .ssh/authorized_keys
[opc@secondaryvm1 ~]$ ssh 10.0.0.2
The
authenticity of host '10.0.0.2 (10.0.0.2)' can't be established.
Are
you sure you want to continue connecting (yes/no)? yes
Warning:
Permanently added '10.0.0.2' (ECDSA) to the list of known hosts.
Last login: Fri Feb 16 21:38:30 2018
from ool-18b8eaa0.dyn.optonline.net
Generate
SSH RSA keys on PrimaryVM1 and add the public key id_rsa.pub into
SecondaryVM1’s ~/.ssh/authorized_keys file to enable password less login for
opc user.
[opc@primaryvm1 ~]$ ssh-keygen -t rsa
Generating
public/private rsa key pair.
Enter
file in which to save the key (/home/opc/.ssh/id_rsa):
Enter
passphrase (empty for no passphrase):
Enter
same passphrase again:
Your
identification has been saved in /home/opc/.ssh/id_rsa.
Your
public key has been saved in /home/opc/.ssh/id_rsa.pub.
The
key fingerprint is:
SHA256:SNeDgqryhoIYc1w6983KFrU59ajye5RAEVnGqemYFzo
opc@primaryvm1
The
key's randomart image is:
+---[RSA
2048]----+
| o*o.
|
| .
o+o |
| . o.ooo
|
|
..o .*S* + |
|o.=
. E * + . |
|==
o . * + |
|*.. .+ + .
|
|... .o+oo
|
+----[SHA256]-----+
[opc@primaryvm1 ~]$ cat ~/.ssh/id_rsa.pub
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQDBeF90LFhO/QF/u0uEVnxKEX6z3Q09XZIjsPpN1F+RVZrJ47+9qNytPKFqg8OErUuBb5iUK9VyFG2fmLJQgGgARGZXy4SlEoW8GBq/CIQbHF5JLcDcWVrUuNTu2QbKZKD3bJq7+zG+P28YdLs8jDprVHhkKiNK1PPQpgnVLAGRYTbDhsAX9zO944FCCrbsKDVSVVdR1ySRryvAveU4j8r1HsjqgYvPzLb8Dmlhgnz9b336JGOicJ1Wy+AunHSdUAJgVg4gG6qJWA2M6Vi3ePUn5ImipAhJ0WGDRhbP/7Vz+51chiUPyceG2VnnFFSHuLQiuFrPm7iBPRvfuTysV2ir
opc@primaryvm1
[opc@primaryvm1 ~]$ vi .ssh/authorized_keys
[opc@primaryvm1 ~]$ ssh 20.0.0.2
The
authenticity of host '20.0.0.2 (20.0.0.2)' can't be established.
Are
you sure you want to continue connecting (yes/no)? yes
Warning:
Permanently added '20.0.0.2' (ECDSA) to the list of known hosts.
Last login: Fri Feb 16 21:38:32 2018
from ool-18b8eaa0.dyn.optonline.net