KatharaFramework / Kathara-Labs

Collection of Kathará network scenarios and tutorials.
https://www.kathara.org/
GNU General Public License v3.0
102 stars 42 forks source link

Ping not working #9

Closed iuliat23 closed 2 years ago

iuliat23 commented 2 years ago

Hello, when I try to start the Static routing lab downloaded from here, I cannot ping R1 from PC1, but if I create the lab myself I am able to do this. Why is this happening, please?

root@pc1:/# ping -c 3 195.11.14.1
PING 195.11.14.1 (195.11.14.1) 56(84) bytes of data.
^C
--- 195.11.14.1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 57ms

root@pc1:/#

root@pc1:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
189: eth0@if188: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 2e:a4:a2:26:9b:b3 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 195.11.14.5/24 brd 195.11.14.255 scope global eth0
       valid_lft forever preferred_lft forever
root@pc1:/# 

root@r1:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
181: eth0@if180: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 06:15:c9:bd:0f:bd brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 195.11.14.1/24 brd 195.11.14.255 scope global eth0
       valid_lft forever preferred_lft forever
185: eth1@if184: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 5a:b0:75:64:f4:a9 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 100.0.0.9/30 brd 100.0.0.11 scope global eth1
       valid_lft forever preferred_lft forever
root@r1:/# 
iuliat23 commented 2 years ago

Also, I have observed this issue with my own test lab. When I am creating the .startup files and then run the lstart command, the ips and routes are added but ping is showing me packet loss, while when I add the ips and routes directly from the terminal, with no .startup files, it is working perfectly.

Skazza94 commented 2 years ago

Hi @iuliat23, thanks for your issue.

The Static Routing lab is one of the labs that we use for teaching in our networking course at Roma Tre University. If you read the PDF presentation in the folder, you'll find that it is purposefully not working, since students have to understand what's happening.

The quick answer is that in all the .startup files the route command is commented. If you uncomment it, everything should work.

If you have further problems, or questions, don't hesitate to reply! Mariano.

iuliat23 commented 2 years ago

Hello, thanks for the info 😬 I am also trying to install NRPE on my emulated devices, as I want to monitor them with Nagios, do you know how can I save my installation/configuration? Maybe docker commit should do the job? Or if it is another method of saving what I did on my devices. Thanks!

Skazza94 commented 2 years ago

Hi @iuliat23, the best way to add new packages to a device is to build a new Docker Image. You can extend one of the Kathara images (like kathara/base or kathara/quagga) and add your own packages.

For example, if you want to install NRPE, you can do the following. Create a file called Dockerfile without extension:

FROM kathara/base

ARG DEBIAN_FRONTEND="noninteractive"
RUN apt update && \
    apt install -y nagios-nrpe-server nagios-plugins && \
    apt clean && \
    rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*

Then, on the terminal, in the same folder where the Dockerfile is stored, run:

docker build -t kathara/nrpe .

At this point, you have a new Docker image built with the desired packages. You can specify it for a device, in the lab.conf, e.g.:

dev1[image]="kathara/nrpe"
iuliat23 commented 2 years ago

Thank you again for your suggestion! I managed to install NRPE on my containers with the manual, classic method 😆, but the problem occurs after I also install Nagios on my main virtual machine because it cannot even ping my containers, nor monitor them or make a simple check on them. Also I have tried another method by installing Nagios on one of the container PCs, but once again in order to access the web interface you need to write something like ipaddress-of-the-server/nagios, but it does not recognise the ip address, in my opinion due to a NAT issue. I hope the problem is explained correctly 😃, if you could help me with this, that would be great.

Skazza94 commented 2 years ago

Hi @iuliat23, by default, Kathará networks are isolated from the host network stack and from the Internet. However, if you want to create a so-called "bridged" interface (that shares the host network stack + has Internet access) on a device, you should add the bridged option in the lab.conf:

dev1[bridged]="true"
dev2[bridged]="true"

In this way, each device will have the standard interfaces (declared in the lab.conf) plus an additional interface configured by Docker (normally on the 172.17.0.0/16 network). Hopefully (I think! 😆), the Nagios installation on the host should be able to reach such IPs.

If you have further problems, don't hesitate to reply! Mariano.