본문 바로가기

Ubuntu

VirtualBox, Ubuntu로 삼각형 네트웍 환경 구성하기

source: https://www.brianlinkletter.com/2016/07/how-to-use-virtualbox-to-emulate-a-network/

※ 위 source에 있는 내용은 Ubuntu 16.04를 기반으로 합니다. 필자는 Ubuntu 18.04에서 구성하여, script 를 조금 수정하였습니다. 

먼저 알아야 할 사항

글 쓰는 배경

Linux 또는 Ubuntu에서 시스템 설정이나 네트워킹 시험을 해야할 경우가 있습니다. 그때 여러대의 시스템을 생성하여 연결해야 하는데, source에 명시한 구성이 꽤 매력적입니다. 따라서 source에 있는 내용을 거의 그대로 복사하여 따라하며 이해하고, 그 과정을 메모해 놓으려 합니다. 시간이 지나면서 자주 잊어버려 필자가 직접 복사/수정한 내용이 필요하다고 생각했습니다. 

시스템환경

VMHOST: Macbook Big Sur 

VM Software: VirtualBox 6.1

VM instance OS: Ubuntu 18.04

전체 과정

1. 네트웍 다이어그램을 작성합니다. 

2. 필요한 VM instance를 6개를 생성합니다. 

3. VMHOST에서 각 VM instance로 접근할 수 있는 management network을 구성합니다.

4. 각 VM instance 네트웍 링크를 설정합니다.

5. VM instance를 모두 켜고 network interface에 IP address를 설정합니다. 

6. r1, r2, r3에 routing protocol을 설정하여 pc1, pc2, pc3가 서로 접속할 수 있도록 합니다. 

1. 네트웍 다이어그램을 작성합니다. 

아래 네트웍 다이어그램의 장점은 

  • VirtualBox 안에서 여러 개의 VM instance를 만들어 시험할 수 있는 구성
  • VM instance 사이에 local host에서 remote host에 연결하는 것을 시험할 수 있는 구성
  • Server - Client 환경을 시험해 볼 수 있는 구성
  • r1, r2, r3에서 dynamic routing protocol을 설정하여 VM instance 사이에 reachability를 시험할 수 있는 구성

등 여러 가지입니다. 

 

VM의 default network interface enp0s8은 모두 인터넷 연결을 위한 management network으로 이용합니다. 즉 VMHOST에서 각 VM instance로 접근하기 위한 network interface 입니다. 

Figure1. Topology

설정이나 연결할 때 헷갈리지 않게 VM instance마다, VirtualBox interface, network type, network name, IP address, ssh host port를 테이블에 정리해 놓으면 좋습니다. 

 

중요한 사항은 구성도에서 같은 링크(선)를 갖는 Adapter(Interface)는 같은 name을 설정해야 합니다. 가령 r1의 adapter4(enp0s10)과 r3의 adapter3(enp0s9)은 같은 name net-13을 이용합니다. 그래야 VirtualBox 내부 네트웍에서 이들을 동일 링크로 설정해 줍니다. 

figure2. interface configuration table

2. 필요한 VM instance를 6개를 생성합니다

깨끗하게 만들어 놓은 VM instance 1개를 base instance로 이용합니다. base instance는 다음과 같이 구성하였습니다. 

  • Memory: 4GB
  • Disk: 20GB
  • Adapter1: NAT
  • Guest OS: Ubutun 18.04

 

해당 instance를 선택하고 Machine > Clone을 선택합니다. 

 

새로운 이름을 정합니다. 구성도에 따라 pc1, pc2, pc3, r1, r2, r3를 생성합니다. 아래 그림은 pc1 으로 정한 예입니다. 

 

복제를 하는 방법은 2가지가 있습니다. Full clone은 parent instance와 완전히 독립적입니다. parent instance의 virtual disk file에 접근하지 않습니다. Linked Clone은 parent instance의 virtual disk file을 이용하며, 변화된 내용만 자기 virtual disk file에 저장합니다. Linked clone으로 생성한 instance의 virtual disk image (VDI) 파일은 parent instance의 VDI 파일을 남겨 두고 다른 시스템으로 이동할 수 없습니다. 

 

필자는 같은 VMHOST에서만 이용하므로 Linked Clone으로 instance pc1, pc2, pc3, r1, r2, r3를 생성합니다. 

pc1, pc2, pc3, r1, r2, r3를 생성한 결과입니다. 

3. VMHOST에서 각 VM instance로 접근할 수 있는 management network을 구성합니다

VM instance를 모두 Power OFF 합니다. 그리고 Figure3. interface configuration table을 참고합니다.

figure3. interface configuration table

이 과정을 이해하기 위해서는 Macbook / Virtualbox에 Ubuntu 18.04 설치에서 "9. VMHOST인 맥북에서 ssh 로 로그인할 수 있게 port forwarding 설정하기"를 먼저 읽어보면 좋습니다. 

 

PC1 > Network > Adapter1 (enp0s3) > Advanced > Port Forwarding 을 선택하고 다음과 같이 추가합니다. 

Name Protocol Host IP Host Port Guest IP Guest Port
ssh     14001   22

PC2 > Network > Adapter1 (enp0s3) > Advanced > Port Forwarding 을 선택하고 다음과 같이 추가합니다.

Name Protocol Host IP Host Port Guest IP Guest Port
ssh     14002   22

PC3 > Network > Adapter1 (enp0s3) > Advanced > Port Forwarding 을 선택하고 다음과 같이 추가합니다.

Name Protocol Host IP Host Port Guest IP Guest Port
ssh     14003   22

R1 > Network > Adapter1 (enp0s3) > Advanced > Port Forwarding 을 선택하고 다음과 같이 추가합니다.

Name Protocol Host IP Host Port Guest IP Guest Port
ssh     14011   22

R2 > Network > Adapter1 (enp0s3) > Advanced > Port Forwarding 을 선택하고 다음과 같이 추가합니다.

Name Protocol Host IP Host Port Guest IP Guest Port
ssh     14012   22

R3 > Network > Adapter1 (enp0s3) > Advanced > Port Forwarding 을 선택하고 다음과 같이 추가합니다.

Name Protocol Host IP Host Port Guest IP Guest Port
ssh     14013   22

 

VM instance를 모두 Start 합니다. 그리고 VMHOST인 맥북에서 각 VM instance로 아래와 같이 ssh 로그인을 시도합니다. 

chrisjang@chrismac2 ~ % ssh salsal@localhost -p14001         # pc1으로 ssh 로그인

 

 

그 결과 아래와 같이 로그인할 수 있습니다. salsal 이라는 username은 base 이미지에 생성해 놓은 username입니다. 

pc2, pc3, r1, r2, r3에 대해서도 동일하게 시도합니다. 이제부터는 VMHOST인 맥북 Terminal에서 모든 instance pc1, pc2, pc3, r1, r2, r3로 ssh 로그인할 수 있습니다. 

chrisjang@chrismac2 ~ % ssh salsal@localhost -p14001         # pc1으로 ssh 로그인

chrisjang@chrismac2 ~ % ssh salsal@localhost -p14002        # pc2으로 ssh 로그인

chrisjang@chrismac2 ~ % ssh salsal@localhost -p14003        # pc3으로 ssh 로그인

chrisjang@chrismac2 ~ % ssh salsal@localhost -p14011        # r1으로 ssh 로그인

chrisjang@chrismac2 ~ % ssh salsal@localhost -p14012        # r2으로 ssh 로그인

chrisjang@chrismac2 ~ % ssh salsal@localhost -p14013        # r3으로 ssh 로그인

 

4. 각 VM instance 네트웍 링크를 설정합니다

figure2. interface configuration table을 참고합니다. 

 

모든 instance를 base image에서 복제하였으므로 Adapter (enp0s3)은 모두 Network Type은 NAT으로 설정되어 있습니다. 이 interface는 management network 역할로 VMHOST와 통신하기 위한 용도로 그대로 유지합니다. instance pc1, pc2, pc3, r1, r2, r3를 모두 부팅해 보니 enp0s3의 IP address는 다음과 같습니다. 

 

IP address가 10.0.2.15 (필자와 다를 수 있음)이 설정된 것을 알 수 있습니다. pc1, pc2, pc3, r1, r2, r3 모두 동일한 IP address를 이용할 수 있으나, VirtualBox 안의 NAT(DHCP) 시스템에 의해 문제가 발생하지 않습니다. 

 

각 VM instace에 있는 각 링크의 IP address는 instance를 부팅하고 나서 설정합니다. 부팅하게 전에는 VM instance adapter 별로 network type과 name을 설정해 주면 됩니다. Figure3를 참고합니다. 

Figure3. interface configuration table

PC1에서 Adapter2 (enp0s8)를 Enable Network Adapter, Attached to: Internal Network, Name: net-1 으로 설정하고 저장합니다. 

나머지 instace도 figure2에 있는 테이블 내용에 따라 설정합니다. 즉 PC2에서는 Adapter2 (enp0s8), PC3에서는 Adapter2 (enp0s8), R1에서는 Adapter2 (enp0s8) Adapter3 (enp0s9) Adapter4 (enp0s10), R2에서는 Adapter2 (enp0s8) Adapter3 (enp0s9) Adapter4 (enp0s10), R3에서는 Adapter2 (enp0s8) Adapter3 (enp0s9) Adapter4 (enp0s10)를 figure2 테이블 내용에 따라 설정합니다. 

 

아래는 R1의 Adapter1, Adapter2, Adapter3, Adapter4 설정 내용입니다. 

Adapter1
Adapter2
Adapter3
Adapter4
VirtualBox Manager의 Network에서 Adapter1,2,3,4설정 확인

 

아래는 PC1 부팅하고 Terminal UI에서 network interface를 확인한 결과입니다. management interface로 사용하는 enp0s3 (Adapter1) 외에 enp0s8(Adapter2)가 추가된 것을 볼 수 있습니다. IP address를 설정하지 않아 inet address (IPv4 address)가 없는 것을 알 수 있습니다. 

PC1 instance network interfaces

아래는 R1 부팅하고 Terminal UI에서 network interface를 확인한 결과입니다. 

R1 instance network interfaces

5. VM instance를 모두 켜고 network interface에 IP address를 설정합니다. 

PC1

맥북 Terminal에서 PC1 instance로 ssh login 합니다. 

chrisjang@chris2 ~ % ssh salsal@localhost -p14001

salsal@localhost's password:



salsal@u1804base:~$ sudo su
[sudo] password for salsal:
root@u1804base:/home/salsal#

 

아래 내용을 instance의 terminal UI에 copy paste 합니다. 내용은 hostname을 변경하고 interface 마다 IP address를 설정하는 것입니다. 

bash <<EOF2
sed -i 's/u1804base/pc1/g' /etc/hostname
sed -i 's/u1804base/pc1/g' /etc/hosts
hostname pc1
cat >> /etc/network/interfaces << EOF
auto enp0s8
iface enp0s8 inet static
   address 192.168.1.2
   netmask 255.255.255.0
up route add -net 192.168.0.0/16 gw 192.168.1.1 dev enp0s8
EOF
/etc/init.d/networking restart
exit
EOF2

 

PC1 instance를 리부팅합니다. 

salsal@u1804base:~$ sudo reboot

 

PC2

맥북 Terminal에서 PC2 instance로 ssh login 합니다.

chrisjang@chris2 ~ % ssh salsal@localhost -p14002

salsal@localhost's password:



salsal@u1804base:~$ sudo su
[sudo] password for salsal:
root@u1804base:/home/salsal#

 

아래 내용을 instance의 terminal UI에 copy paste 합니다. 내용은 hostname을 변경하고 interface 마다 IP address를 설정하는 것입니다. 

bash <<EOF2
sed -i 's/u1804base/pc2/g' /etc/hostname
sed -i 's/u1804base/pc2/g' /etc/hosts
hostname pc2
cat >> /etc/network/interfaces << EOF
auto enp0s8
iface enp0s8 inet static
   address 192.168.2.2
   netmask 255.255.255.0
up route add -net 192.168.0.0/16 gw 192.168.2.1 dev enp0s8
EOF
/etc/init.d/networking restart
exit
EOF2

 

PC2 instance를 리부팅합니다.

salsal@u1804base:~$ sudo reboot

 

PC3

맥북 Terminal에서 PC3 instance로 ssh login 합니다.

chrisjang@chris2 ~ % ssh salsal@localhost -p14003

salsal@localhost's password:



salsal@u1804base:~$ sudo su
[sudo] password for salsal:
root@u1804base:/home/salsal#

 

아래 내용을 instance의 terminal UI에 copy paste 합니다. 내용은 hostname을 변경하고 interface 마다 IP address를 설정하는 것입니다. 

bash <<EOF2
sed -i 's/u1804base/pc3/g' /etc/hostname
sed -i 's/u1804base/pc3/g' /etc/hosts
hostname pc3
cat >> /etc/network/interfaces << EOF
auto enp0s8
iface enp0s8 inet static
   address 192.168.3.2
   netmask 255.255.255.0
up route add -net 192.168.0.0/16 gw 192.168.3.1 dev enp0s8
EOF
/etc/init.d/networking restart
exit
EOF2

 

PC3 instance를 리부팅합니다.

salsal@u1804base:~$ sudo reboot

 

R1

맥북 Terminal에서 R1 instance로 ssh login 합니다.

chrisjang@chris2 ~ % ssh salsal@localhost -p14011

salsal@localhost's password:



salsal@u1804base:~$ sudo su
[sudo] password for salsal:
root@u1804base:/home/salsal#

 

아래 내용을 instance의 terminal UI에 copy paste 합니다. 내용은 hostname을 변경하고 interface 마다 IP address를 설정하는 것입니다. 

bash <<EOF2
sed -i 's/u1804base/r1/g' /etc/hostname
sed -i 's/u1804base/r1/g' /etc/hosts
hostname r1
cat >> /etc/network/interfaces << EOF
auto enp0s8
auto enp0s9
auto enp0s10
iface enp0s8 inet static
   address 192.168.1.1
   netmask 255.255.255.0
iface enp0s9 inet static
   address 192.168.12.1
   netmask 255.255.255.0
iface enp0s10 inet static
   address 192.168.13.1
   netmask 255.255.255.0
EOF
/etc/init.d/networking restart
exit
EOF2

 

R1 instance를 리부팅합니다.

salsal@u1804base:~$ sudo reboot

 

R2

맥북 Terminal에서 R2 instance로 ssh login 합니다.

chrisjang@chris2 ~ % ssh salsal@localhost -p14012

salsal@localhost's password:



salsal@u1804base:~$ sudo su
[sudo] password for salsal:
root@u1804base:/home/salsal#

 

 

아래 내용을 instance의 terminal UI에 copy paste 합니다. 내용은 hostname을 변경하고 interface 마다 IP address를 설정하는 것입니다. 

bash <<EOF2
sed -i 's/u1804base/r2/g' /etc/hostname
sed -i 's/u1804base/r2/g' /etc/hosts
hostname r2
cat >> /etc/network/interfaces << EOF
auto enp0s8
auto enp0s9
auto enp0s10
iface enp0s8 inet static
   address 192.168.2.1
   netmask 255.255.255.0
iface enp0s9 inet static
   address 192.168.12.2
   netmask 255.255.255.0
iface enp0s10 inet static
   address 192.168.23.2
   netmask 255.255.255.0
EOF
/etc/init.d/networking restart
exit
EOF2

 

R2 instance를 리부팅합니다.

salsal@u1804base:~$ sudo reboot

 

R3

맥북 Terminal에서 R3 instance로 ssh login 합니다.

chrisjang@chris2 ~ % ssh salsal@localhost -p14013

salsal@localhost's password:



salsal@u1804base:~$ sudo su
[sudo] password for salsal:
root@u1804base:/home/salsal#

 

아래 내용을 instance의 terminal UI에 copy paste 합니다. 내용은 hostname을 변경하고 interface 마다 IP address를 설정하는 것입니다. 

bash <<EOF2
sed -i 's/u1804base/r3/g' /etc/hostname
sed -i 's/u1804base/r3/g' /etc/hosts
hostname r3
cat >> /etc/network/interfaces << EOF
auto enp0s8
auto enp0s9
auto enp0s10
iface enp0s8 inet static
   address 192.168.3.1
   netmask 255.255.255.0
iface enp0s9 inet static
   address 192.168.13.3
   netmask 255.255.255.0
iface enp0s10 inet static
   address 192.168.23.3
   netmask 255.255.255.0
EOF
/etc/init.d/networking restart
exit
EOF2

 

R3 instance를 리부팅합니다.

salsal@u1804base:~$ sudo reboot

 

Ping 확인

R1에서 pc1, r2, r3 측 링크 IP address로 확인합니다. 

salsal@r1:~$ ping -c 1 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.322 ms

--- 192.168.1.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.322/0.322/0.322/0.000 ms
salsal@r1:~$ ping -c 1 192.168.12.2
PING 192.168.12.2 (192.168.12.2) 56(84) bytes of data.
64 bytes from 192.168.12.2: icmp_seq=1 ttl=64 time=23.4 ms

--- 192.168.12.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 23.482/23.482/23.482/0.000 ms
salsal@r1:~$ ping -c 1 192.168.13.2
PING 192.168.13.2 (192.168.13.2) 56(84) bytes of data.
64 bytes from 192.168.13.2: icmp_seq=1 ttl=64 time=0.367 ms

--- 192.168.13.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.367/0.367/0.367/0.000 ms

 

R2에서 pc2, r1, r3 측 링크 IP address로 확인합니다. 

salsal@r2:~$ ping -c 1 192.168.2.2
PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
64 bytes from 192.168.2.2: icmp_seq=1 ttl=64 time=0.567 ms

--- 192.168.2.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.567/0.567/0.567/0.000 ms
salsal@r2:~$ ping -c 1 192.168.12.1
PING 192.168.12.1 (192.168.12.1) 56(84) bytes of data.
64 bytes from 192.168.12.1: icmp_seq=1 ttl=64 time=0.362 ms

--- 192.168.12.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.362/0.362/0.362/0.000 ms
salsal@r2:~$ ping -c 1 192.168.23.2
PING 192.168.23.2 (192.168.23.2) 56(84) bytes of data.
64 bytes from 192.168.23.2: icmp_seq=1 ttl=64 time=0.493 ms

--- 192.168.23.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.493/0.493/0.493/0.000 ms

 

R3에서 pc3, r1, r2 측 링크 IP address로 확인합니다.

salsal@r3:~$ ping -c 1 192.168.3.2
PING 192.168.3.2 (192.168.3.2) 56(84) bytes of data.
64 bytes from 192.168.3.2: icmp_seq=1 ttl=64 time=0.368 ms

--- 192.168.3.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.368/0.368/0.368/0.000 ms
salsal@r3:~$ ping -c 1 192.168.13.1
PING 192.168.13.1 (192.168.13.1) 56(84) bytes of data.
64 bytes from 192.168.13.1: icmp_seq=1 ttl=64 time=0.361 ms

--- 192.168.13.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.361/0.361/0.361/0.000 ms
salsal@r3:~$ ping -c 1 192.168.23.1
PING 192.168.23.1 (192.168.23.1) 56(84) bytes of data.
64 bytes from 192.168.23.1: icmp_seq=1 ttl=64 time=10.3 ms

--- 192.168.23.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 10.334/10.334/10.334/0.000 ms

 

6. r1, r2, r3에 routing protocol을 설정하여 pc1, pc2, pc3가 서로 접속할 수 있도록 합니다.

참고:  https://www.cs.unm.edu/~rudym/Running+Quagga+On+Ubuntu+16.04.html 

 

r1 설정

맥북 Terminal에서 R1 instance로 ssh login 합니다.

chrisjang@chris2 ~ % ssh salsal@localhost -p14011
salsal@localhost's password:

salsal@r1:~$ sudo su
[sudo] password for salsal:
root@r1:/home/salsal#

아래 내용을 instance의 terminal UI에 copy paste 합니다. quagga 를 설치하고, vtysh, zebra, ospfd를 설정하는 것입니다. 

bash <<EOF2
apt update
apt install -y quagga quagga-doc traceroute
cp /usr/share/doc/quagga-core/examples/vtysh.conf.sample /etc/quagga/vtysh.conf
cp /usr/share/doc/quagga-core/examples/zebra.conf.sample /etc/quagga/zebra.conf
cp /usr/share/doc/quagga-core/examples/ospfd.conf.sample /etc/quagga/ospfd.conf
chown quagga.quagga /etc/quagga/*.conf
chown quagga.quaggavty /etc/quagga/vtysh.conf
chmod 640 /etc/quagga/*.conf
cat > /etc/quagga/ospfd.conf << EOF
interface enp0s8
interface enp0s9
interface enp0s10
interface lo
router ospf
 passive-interface enp0s8
 network 192.168.1.0/24 area 0.0.0.0
 network 192.168.12.0/24 area 0.0.0.0
 network 192.168.13.0/24 area 0.0.0.0
line vty
EOF
cat > /etc/quagga/zebra.conf << EOF
interface enp0s8
 ip address 192.168.1.1/24
interface enp0s9
 ip address 192.168.12.1/24
interface enp0s10
 ip address 192.168.13.1/24
interface lo
ip forwarding
line vty
EOF
systemctl start zebra
systemctl start ospfd
exit
EOF2

명령어를 입력하여 상태를 확인합니다. 

salsal@r1:~$ sudo systemctl is-enabled zebra
enabled
salsal@r1:~$ sudo systemctl is-enabled ospfd
enabled
salsal@r1:~$ sudo systemctl status zebra
● zebra.service - GNU Zebra routing manager
   Loaded: loaded (/lib/systemd/system/zebra.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-07-30 20:09:34 KST; 1min 17s ago
     Docs: man:zebra
  Process: 3401 ExecStart=/usr/sbin/zebra -d -A 127.0.0.1 -f /etc/quagga/zebra.conf (code=e
  Process: 3400 ExecStartPre=/bin/chown -f quagga:quaggavty /etc/quagga/vtysh.conf (code=ex
  Process: 3399 ExecStartPre=/bin/chown -f quagga:quagga /etc/quagga/zebra.conf (code=exite
  Process: 3398 ExecStartPre=/bin/chmod -f 640 /etc/quagga/vtysh.conf /etc/quagga/zebra.con
  Process: 3397 ExecStartPre=/sbin/ip route flush proto zebra (code=exited, status=0/SUCCES
 Main PID: 3402 (zebra)
    Tasks: 1 (limit: 4664)
   CGroup: /system.slice/zebra.service
           └─3402 /usr/sbin/zebra -d -A 127.0.0.1 -f /etc/quagga/zebra.conf

 7월 30 20:09:34 r1 systemd[1]: Starting GNU Zebra routing manager...
 7월 30 20:09:34 r1 systemd[1]: Started GNU Zebra routing manager.
salsal@r1:~$ sudo systemctl status ospfd
● ospfd.service - OSPF routing daemon
   Loaded: loaded (/lib/systemd/system/ospfd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-07-30 20:09:35 KST; 1min 22s ago
     Docs: man:ospfd
  Process: 3406 ExecStart=/usr/sbin/ospfd -d -A 127.0.0.1 -f /etc/quagga/ospfd.conf (code=e
  Process: 3405 ExecStartPre=/bin/chown -f quagga:quagga /etc/quagga/ospfd.conf (code=exite
  Process: 3404 ExecStartPre=/bin/chmod -f 640 /etc/quagga/ospfd.conf (code=exited, status=
 Main PID: 3407 (ospfd)
    Tasks: 1 (limit: 4664)
   CGroup: /system.slice/ospfd.service
           └─3407 /usr/sbin/ospfd -d -A 127.0.0.1 -f /etc/quagga/ospfd.conf

 7월 30 20:09:35 r1 systemd[1]: Starting OSPF routing daemon...
 7월 30 20:09:35 r1 systemd[1]: Started OSPF routing daemon.

vtysh를 이용하여 zebra에 연결하여 라우팅 설정을 확인합니다. 

salsal@r1:~$ sudo vtysh

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

r1# show running-config
Building configuration...

Current configuration:
!
!
interface enp0s3
!
interface enp0s8
 ip address 192.168.1.1/24
!
interface enp0s9
 ip address 192.168.12.1/24
!
interface enp0s10
 ip address 192.168.13.1/24
!
interface lo
!
router ospf
 passive-interface enp0s8
 network 192.168.1.0/24 area 0.0.0.0
 network 192.168.12.0/24 area 0.0.0.0
 network 192.168.13.0/24 area 0.0.0.0
!
ip forwarding
!
line vty
!
end
r1# exit
salsal@r1:~$

ip forwarding을 설정하였으므로 Terminal에서 상태를 확인하면 다음과 같습니다. 

salsal@r1:~$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

r2 설정

맥북 Terminal에서 R2 instance로 ssh login 합니다.

chrisjang@chris2 ~ % ssh salsal@localhost -p14012
salsal@localhost's password:

salsal@r2:~$ sudo su
[sudo] password for salsal:
root@r2:/home/salsal#

아래 내용을 instance의 terminal UI에 copy paste 합니다. quagga 를 설치하고, vtysh, zebra, ospfd를 설정하는 것입니다. 

bash <<EOF2
apt update
apt install -y quagga quagga-doc traceroute
cp /usr/share/doc/quagga-core/examples/vtysh.conf.sample /etc/quagga/vtysh.conf
cp /usr/share/doc/quagga-core/examples/zebra.conf.sample /etc/quagga/zebra.conf
cp /usr/share/doc/quagga-core/examples/ospfd.conf.sample /etc/quagga/ospfd.conf
chown quagga.quagga /etc/quagga/*.conf
chown quagga.quaggavty /etc/quagga/vtysh.conf
chmod 640 /etc/quagga/*.conf
cat > /etc/quagga/ospfd.conf << EOF
interface enp0s8
interface enp0s9
interface enp0s10
interface lo
router ospf
 passive-interface enp0s8
 network 192.168.2.0/24 area 0.0.0.0
 network 192.168.12.0/24 area 0.0.0.0
 network 192.168.23.0/24 area 0.0.0.0
line vty
EOF
cat > /etc/quagga/zebra.conf << EOF
interface enp0s8
 ip address 192.168.2.1/24
interface enp0s9
 ip address 192.168.12.2/24
interface enp0s10
 ip address 192.168.23.2/24
interface lo
ip forwarding
line vty
EOF
systemctl start zebra
systemctl start ospfd
exit
EOF2

명령어를 입력하여 상태를 확인합니다.

salsal@r2:~$ sudo systemctl is-enabled zebra
enabled
salsal@r2:~$ sudo systemctl is-enabled ospfd
enabled
salsal@r2:~$ sudo systemctl status zebra
● zebra.service - GNU Zebra routing manager
   Loaded: loaded (/lib/systemd/system/zebra.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-07-30 20:16:57 KST; 58s ago
     Docs: man:zebra
  Process: 4929 ExecStart=/usr/sbin/zebra -d -A 127.0.0.1 -f /etc/quagga/zebra.conf (code=e
  Process: 4928 ExecStartPre=/bin/chown -f quagga:quaggavty /etc/quagga/vtysh.conf (code=ex
  Process: 4927 ExecStartPre=/bin/chown -f quagga:quagga /etc/quagga/zebra.conf (code=exite
  Process: 4926 ExecStartPre=/bin/chmod -f 640 /etc/quagga/vtysh.conf /etc/quagga/zebra.con
  Process: 4925 ExecStartPre=/sbin/ip route flush proto zebra (code=exited, status=0/SUCCES
 Main PID: 4932 (zebra)
    Tasks: 1 (limit: 4664)
   CGroup: /system.slice/zebra.service
           └─4932 /usr/sbin/zebra -d -A 127.0.0.1 -f /etc/quagga/zebra.conf

 7월 30 20:16:56 r2 systemd[1]: Starting GNU Zebra routing manager...
 7월 30 20:16:57 r2 systemd[1]: Started GNU Zebra routing manager.
salsal@r2:~$ sudo systemctl status ospfd
● ospfd.service - OSPF routing daemon
   Loaded: loaded (/lib/systemd/system/ospfd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-07-30 20:16:57 KST; 1min 4s ago
     Docs: man:ospfd
  Process: 4936 ExecStart=/usr/sbin/ospfd -d -A 127.0.0.1 -f /etc/quagga/ospfd.conf (code=e
  Process: 4935 ExecStartPre=/bin/chown -f quagga:quagga /etc/quagga/ospfd.conf (code=exite
  Process: 4934 ExecStartPre=/bin/chmod -f 640 /etc/quagga/ospfd.conf (code=exited, status=
 Main PID: 4937 (ospfd)
    Tasks: 1 (limit: 4664)
   CGroup: /system.slice/ospfd.service
           └─4937 /usr/sbin/ospfd -d -A 127.0.0.1 -f /etc/quagga/ospfd.conf

 7월 30 20:16:57 r2 systemd[1]: Starting OSPF routing daemon...
 7월 30 20:16:57 r2 systemd[1]: Started OSPF routing daemon.

vtysh를 이용하여 zebra에 연결하여 라우팅 설정을 확인합니다. 

salsal@r2:~$ sudo vtysh

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

r2# show running-config
Building configuration...

Current configuration:
!
!
interface enp0s3
!
interface enp0s8
 ip address 192.168.2.1/24
!
interface enp0s9
 ip address 192.168.12.2/24
!
interface enp0s10
 ip address 192.168.23.2/24
!
interface lo
!
router ospf
 passive-interface enp0s8
 network 192.168.2.0/24 area 0.0.0.0
 network 192.168.12.0/24 area 0.0.0.0
 network 192.168.23.0/24 area 0.0.0.0
!
ip forwarding
!
line vty
!
end
r2# exit
salsal@r2:~$

ip forwarding을 설정하였으므로 Terminal에서 상태를 확인하면 다음과 같습니다.

salsal@r2:~$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

r3 설정

맥북 Terminal에서 R3 instance로 ssh login 합니다.

chrisjang@chris2 ~ % ssh salsal@localhost -p14013
salsal@localhost's password:

salsal@r3:~$ sudo su
[sudo] password for salsal:
root@r3:/home/salsal#

아래 내용을 instance의 terminal UI에 copy paste 합니다. quagga 를 설치하고, vtysh, zebra, ospfd를 설정하는 것입니다. 

bash <<EOF2
apt update
apt install -y quagga quagga-doc traceroute
cp /usr/share/doc/quagga-core/examples/vtysh.conf.sample /etc/quagga/vtysh.conf
cp /usr/share/doc/quagga-core/examples/zebra.conf.sample /etc/quagga/zebra.conf
cp /usr/share/doc/quagga-core/examples/ospfd.conf.sample /etc/quagga/ospfd.conf
chown quagga.quagga /etc/quagga/*.conf
chown quagga.quaggavty /etc/quagga/vtysh.conf
chmod 640 /etc/quagga/*.conf
cat > /etc/quagga/ospfd.conf << EOF
interface enp0s8
interface enp0s9
interface enp0s10
interface lo
router ospf
 passive-interface enp0s8
 network 192.168.3.0/24 area 0.0.0.0
 network 192.168.13.0/24 area 0.0.0.0
 network 192.168.23.0/24 area 0.0.0.0
line vty
EOF
cat > /etc/quagga/zebra.conf << EOF
interface enp0s8
 ip address 192.168.3.1/24
interface enp0s9
 ip address 192.168.13.3/24
interface enp0s10
 ip address 192.168.23.3/24
interface lo
ip forwarding
line vty
EOF
systemctl start zebra
systemctl start ospfd
exit
EOF2

명령어를 입력하여 상태를 확인합니다.

root@r3:/home/salsal# sudo systemctl is-enabled zebra
enabled
root@r3:/home/salsal# sudo systemctl is-enabled ospfd
enabled
root@r3:/home/salsal# sudo systemctl status zebra
● zebra.service - GNU Zebra routing manager
   Loaded: loaded (/lib/systemd/system/zebra.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-07-30 20:20:58 KST; 23s ago
     Docs: man:zebra
  Process: 4766 ExecStart=/usr/sbin/zebra -d -A 127.0.0.1 -f /etc/quagga/zebra.conf (code=e
  Process: 4765 ExecStartPre=/bin/chown -f quagga:quaggavty /etc/quagga/vtysh.conf (code=ex
  Process: 4764 ExecStartPre=/bin/chown -f quagga:quagga /etc/quagga/zebra.conf (code=exite
  Process: 4763 ExecStartPre=/bin/chmod -f 640 /etc/quagga/vtysh.conf /etc/quagga/zebra.con
  Process: 4762 ExecStartPre=/sbin/ip route flush proto zebra (code=exited, status=0/SUCCES
 Main PID: 4769 (zebra)
    Tasks: 1 (limit: 4664)
   CGroup: /system.slice/zebra.service
           └─4769 /usr/sbin/zebra -d -A 127.0.0.1 -f /etc/quagga/zebra.conf

 7월 30 20:20:58 r3 systemd[1]: Starting GNU Zebra routing manager...
 7월 30 20:20:58 r3 systemd[1]: Started GNU Zebra routing manager.
root@r3:/home/salsal# sudo systemctl status ospfd
● ospfd.service - OSPF routing daemon
   Loaded: loaded (/lib/systemd/system/ospfd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-07-30 20:20:58 KST; 26s ago
     Docs: man:ospfd
  Process: 4773 ExecStart=/usr/sbin/ospfd -d -A 127.0.0.1 -f /etc/quagga/ospfd.conf (code=e
  Process: 4772 ExecStartPre=/bin/chown -f quagga:quagga /etc/quagga/ospfd.conf (code=exite
  Process: 4771 ExecStartPre=/bin/chmod -f 640 /etc/quagga/ospfd.conf (code=exited, status=
 Main PID: 4774 (ospfd)
    Tasks: 1 (limit: 4664)
   CGroup: /system.slice/ospfd.service
           └─4774 /usr/sbin/ospfd -d -A 127.0.0.1 -f /etc/quagga/ospfd.conf

 7월 30 20:20:58 r3 systemd[1]: Starting OSPF routing daemon...
 7월 30 20:20:58 r3 systemd[1]: Started OSPF routing daemon.

vtysh를 이용하여 zebra에 연결하여 라우팅 설정을 확인합니다. 

salsal@r3:~$ sudo vtysh

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

r3# show running-config
Building configuration...

Current configuration:
!
!
interface enp0s3
!
interface enp0s8
 ip address 192.168.3.1/24
!
interface enp0s9
 ip address 192.168.13.3/24
!
interface enp0s10
 ip address 192.168.23.3/24
!
interface lo
!
router ospf
 passive-interface enp0s8
 network 192.168.3.0/24 area 0.0.0.0
 network 192.168.13.0/24 area 0.0.0.0
 network 192.168.23.0/24 area 0.0.0.0
!
ip forwarding
!
line vty
!
end
r3# exit
salsal@r3:~$

ip forwarding을 설정하였으므로 Terminal에서 상태를 확인하면 다음과 같습니다.

salsal@r3:~$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

PC1, PC2, PC3에서 서로 접근 가능한지 확인하기

PC1 입장에서 인터넷으로 가는 경로는 Adapter1 (enp0s3)를 사용합니다. 그러나 192.168.0.0/16으로 가는 경로는 Adapter2 (enp0s8)을 사용합니다. 

salsal@pc1:~$ netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         _gateway        0.0.0.0         UG        0 0          0 enp0s3
10.0.2.0        0.0.0.0         255.255.255.0   U         0 0          0 enp0s3
link-local      0.0.0.0         255.255.0.0     U         0 0          0 enp0s8
192.168.0.0     192.168.1.1     255.255.0.0     UG        0 0          0 enp0s8
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 enp0s8

따라서 PC2 192.168.2.2, PC3 192.168.3.2에 대해서 ping으로 점검을 해 보면 성공하는 것을 알 수 있습니다. 

salsal@pc1:~$ ping -c 1 192.168.2.2
PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
64 bytes from 192.168.2.2: icmp_seq=1 ttl=62 time=33.9 ms

--- 192.168.2.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 33.905/33.905/33.905/0.000 ms
salsal@pc1:~$ ping -c 1 192.168.2.2
PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
64 bytes from 192.168.2.2: icmp_seq=1 ttl=62 time=12.8 ms

--- 192.168.2.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 12.885/12.885/12.885/0.000 ms

mtr을 이용하여 경로를 확인합니다. 

 

salsal@pc1:~$ mtr -4 -c 1 --report --no-dns 192.168.2.2
Start: 2021-07-30T20:31:17+0900
HOST: pc1                         Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 192.168.1.1                0.0%     1    0.7   0.7   0.7   0.7   0.0
  2.|-- 192.168.12.2               0.0%     1   21.4  21.4  21.4  21.4   0.0
  3.|-- 192.168.2.2                0.0%     1   21.4  21.4  21.4  21.4   0.0
salsal@pc1:~$ mtr -4 -c 1 --report --no-dns 192.168.3.2
Start: 2021-07-30T20:31:25+0900
HOST: pc1                         Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 192.168.1.1                0.0%     1    0.7   0.7   0.7   0.7   0.0
  2.|-- 192.168.13.3               0.0%     1    1.0   1.0   1.0   1.0   0.0
  3.|-- 192.168.3.2                0.0%     1    1.4   1.4   1.4   1.4   0.0

 

Figure1. Topology를 보며 경로를 확인해 보면 잘 알 수 있습니다. 

Figure1. Topology

 

이렇게 직접 연결되어 있지 않은 PC1, PC2, PC3가 서로 접속 가능한 이유는 R1, R2, R3에서 OSPF routing을 설정해 운영하고 있기 때문입니다. R1, R2, R3 에서 OSPF neighbor, OSPF interface, OSPF route 정보 등을 살펴볼 수 있습니다. 

 

R1에서 확인

salsal@r1:~$ sudo vtysh
[sudo] password for salsal:

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

r1# show ip route ospf
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel, N - NHRP,
       > - selected route, * - FIB route

O   192.168.1.0/24 [110/10] is directly connected, enp0s8, 00:53:16
O>* 192.168.2.0/24 [110/20] via 192.168.12.2, enp0s9, 00:07:21
O>* 192.168.3.0/24 [110/20] via 192.168.13.3, enp0s10, 00:04:31
O   192.168.12.0/24 [110/10] is directly connected, enp0s9, 00:53:16
O   192.168.13.0/24 [110/10] is directly connected, enp0s10, 00:53:16
O>* 192.168.23.0/24 [110/20] via 192.168.12.2, enp0s9, 00:04:31
  *                          via 192.168.13.3, enp0s10, 00:04:31
r1# show ip ospf neighbor

Neighbor ID     Pri State           Dead Time Address         Interface            RXmtL RqstL DBsmL
192.168.23.2      1 Full/Backup       35.490s 192.168.12.2    enp0s9:192.168.12.1      0     0     0
192.168.23.3      1 Full/Backup       38.344s 192.168.13.3    enp0s10:192.168.13.1     0     0     0
r1# show ip ospf interface
enp0s3 is up
  ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  OSPF not enabled on this interface
enp0s8 is up
  ifindex 3, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.1.1/24, Broadcast 192.168.1.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.13.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.13.1, Interface Address 192.168.1.1
  No backup designated router on this network
  Multicast group memberships: <None>
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    No Hellos (Passive interface)
  Neighbor Count is 0, Adjacent neighbor count is 0
enp0s9 is up
  ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.12.1/24, Broadcast 192.168.12.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.13.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.13.1, Interface Address 192.168.12.1
  Backup Designated Router (ID) 192.168.23.2, Interface Address 192.168.12.2
  Saved Network-LSA sequence number 0x80000006
  Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 0.018s
  Neighbor Count is 1, Adjacent neighbor count is 1
enp0s10 is up
  ifindex 5, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.13.1/24, Broadcast 192.168.13.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.13.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.13.1, Interface Address 192.168.13.1
  Backup Designated Router (ID) 192.168.23.3, Interface Address 192.168.13.3
  Saved Network-LSA sequence number 0x80000003
  Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 0.018s
  Neighbor Count is 1, Adjacent neighbor count is 1
lo is up
  ifindex 1, MTU 65536 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
  OSPF not enabled on this interface
r1#

R2에서 확인

salsal@r2:~$ sudo vtysh

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

r2# show ip route ospf
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel, N - NHRP,
       > - selected route, * - FIB route

O>* 192.168.1.0/24 [110/20] via 192.168.12.1, enp0s9, 00:05:54
O   192.168.2.0/24 [110/10] is directly connected, enp0s8, 00:06:01
O>* 192.168.3.0/24 [110/20] via 192.168.23.3, enp0s10, 00:03:16
O   192.168.12.0/24 [110/10] is directly connected, enp0s9, 00:06:01
O>* 192.168.13.0/24 [110/20] via 192.168.12.1, enp0s9, 00:02:53
  *                          via 192.168.23.3, enp0s10, 00:02:53
O   192.168.23.0/24 [110/10] is directly connected, enp0s10, 00:06:01
r2# show ip ospf neighbor

Neighbor ID     Pri State           Dead Time Address         Interface            RXmtL RqstL D
BsmL
192.168.13.1      1 Full/DR           30.198s 192.168.12.1    enp0s9:192.168.12.2      0     0
   0
192.168.23.3      1 Full/Backup       30.484s 192.168.23.3    enp0s10:192.168.23.2     0     0
   0
r2# show ip ospf interface
enp0s3 is up
  ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  OSPF not enabled on this interface
enp0s8 is up
  ifindex 3, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.2.1/24, Broadcast 192.168.2.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.23.2, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.23.2, Interface Address 192.168.2.1
  No backup designated router on this network
  Multicast group memberships: <None>
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    No Hellos (Passive interface)
  Neighbor Count is 0, Adjacent neighbor count is 0
enp0s9 is up
  ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.12.2/24, Broadcast 192.168.12.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.23.2, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State Backup, Priority 1
  Designated Router (ID) 192.168.13.1, Interface Address 192.168.12.1
  Backup Designated Router (ID) 192.168.23.2, Interface Address 192.168.12.2
  Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 6.202s
  Neighbor Count is 1, Adjacent neighbor count is 1
enp0s10 is up
  ifindex 5, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.23.2/24, Broadcast 192.168.23.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.23.2, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.23.2, Interface Address 192.168.23.2
  Backup Designated Router (ID) 192.168.23.3, Interface Address 192.168.23.3
  Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 6.202s
  Neighbor Count is 1, Adjacent neighbor count is 1
lo is up
  ifindex 1, MTU 65536 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
  OSPF not enabled on this interface
r2#

R3에서 확인

salsal@r3:~$ sudo vtysh
[sudo] password for salsal:

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

r3# sh ip ospf neigh

Neighbor ID     Pri State           Dead Time Address         Interface            RXmtL RqstL
 DBsmL
192.168.13.1      1 Full/DR           39.605s 192.168.13.1    enp0s9:192.168.13.3      2     0
     0
192.168.23.2      1 Full/DR           39.821s 192.168.23.2    enp0s10:192.168.23.3     1     0
     0
r3# show ip route ospf
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel, N - NHRP,
       > - selected route, * - FIB route

O>* 192.168.1.0/24 [110/20] via 192.168.13.1, enp0s9, 00:03:27
O>* 192.168.2.0/24 [110/20] via 192.168.23.2, enp0s10, 00:04:00
O   192.168.3.0/24 [110/10] is directly connected, enp0s8, 00:04:12
O>* 192.168.12.0/24 [110/20] via 192.168.13.1, enp0s9, 00:03:27
  *                          via 192.168.23.2, enp0s10, 00:03:27
O   192.168.13.0/24 [110/10] is directly connected, enp0s9, 00:03:27
O   192.168.23.0/24 [110/10] is directly connected, enp0s10, 00:04:12
r3# show ip ospf neigh

Neighbor ID     Pri State           Dead Time Address         Interface            RXmtL RqstL
 DBsmL
192.168.13.1      1 Full/DR           35.779s 192.168.13.1    enp0s9:192.168.13.3      0     0
     0
192.168.23.2      1 Full/DR           33.164s 192.168.23.2    enp0s10:192.168.23.3     0     0
     0
r3# show ip ospf interface
enp0s3 is up
  ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  OSPF not enabled on this interface
enp0s8 is up
  ifindex 3, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.3.1/24, Broadcast 192.168.3.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.23.3, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.23.3, Interface Address 192.168.3.1
  No backup designated router on this network
  Multicast group memberships: <None>
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    No Hellos (Passive interface)
  Neighbor Count is 0, Adjacent neighbor count is 0
enp0s9 is up
  ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.13.3/24, Broadcast 192.168.13.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.23.3, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State Backup, Priority 1
  Designated Router (ID) 192.168.13.1, Interface Address 192.168.13.1
  Backup Designated Router (ID) 192.168.23.3, Interface Address 192.168.13.3
  Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 1.396s
  Neighbor Count is 1, Adjacent neighbor count is 1
enp0s10 is up
  ifindex 5, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.23.3/24, Broadcast 192.168.23.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.23.3, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State Backup, Priority 1
  Designated Router (ID) 192.168.23.2, Interface Address 192.168.23.2
  Backup Designated Router (ID) 192.168.23.3, Interface Address 192.168.23.3
  Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 1.416s
  Neighbor Count is 1, Adjacent neighbor count is 1
lo is up
  ifindex 1, MTU 65536 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
  OSPF not enabled on this interface
r3#