init(): initial commit

This commit is contained in:
ITQ
2026-02-20 23:14:19 +03:00
commit fd8de1052a
36 changed files with 1713 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
# General
.DS_Store
__MACOSX/
.AppleDouble
.LSOverride
Icon[
]
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
+5
View File
@@ -0,0 +1,5 @@
# Backup of containerlab topology
*.yaml.bak
# containerlab files
clab-*
Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

+54
View File
@@ -0,0 +1,54 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y --no-install-recommends \
ca-certificates \
curl \
bash \
zsh \
vim \
git \
bind9-dnsutils \
bridge-utils \
conntrack \
ethtool \
ipset \
iptables \
openssh-server \
strace \
jq \
netcat-openbsd \
ipython3 \
scapy \
iproute2 \
iputils-ping \
iputils-arping \
mtr \
traceroute \
tcptraceroute \
net-tools \
tcpdump \
tshark \
bird2-doc \
bird2 && \
mkdir /run/bird && \
apt clean && \
rm -rf /var/lib/apt/lists/*
USER root
WORKDIR /root
ENV HOSTNAME=sch57
# ZSH Themes
RUN curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh
RUN git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
COPY ./configs/zshrc .zshrc
COPY ./configs/motd motd
RUN chmod -R g=u /root
RUN chown root:root /usr/bin/dumpcap
CMD [ "sleep", "infinity" ]
+8
View File
@@ -0,0 +1,8 @@
_ ___
| | |__ \
| | ) |
| | / /
| |____ / /_
|______|____|
Networks Demo
+140
View File
@@ -0,0 +1,140 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
#export TERM="xterm-256color"
ZSH_THEME="powerlevel10k/powerlevel10k"
ZSH_DISABLE_COMPFIX="true"
# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
zsh-autosuggestions
yarn
web-search
jsontools
macports
node
sudo
docker
)
source $ZSH/oh-my-zsh.sh
# User configuration
cat motd
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# Reload the plugin to highlight the commands each time Iterm2 starts
#source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
### VISUAL CUSTOMIZATION ###
# Elements options of left prompt (remove the @username context)
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(host dir rbenv)
# Elements options of right prompt
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
# Add a second prompt line for the command
POWERLEVEL9K_PROMPT_ON_NEWLINE=false
# Add a space in the first prompt
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=''
# Visual customization of the second prompt line
#local user_symbol="$"
#if [[ $(print -P "%#") =~ "#" ]]; then
# user_symbol = "#"
#fi
#POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%{%B%F{black}%K{yellow}%} $user_symbol%{%b%f%k%F{yellow}%} %{%f%}"
# Change the git status to red when something isn't committed and pushed
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='red'
# Add a new line after the global prompt
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
# Colorize the top Tabs of Iterm2 with the same color as background
# Just change the 18/26/33 which are the rgb values
echo -e "\033]6;1;bg;red;brightness;18\a"
echo -e "\033]6;1;bg;green;brightness;26\a"
echo -e "\033]6;1;bg;blue;brightness;33\a"
+68
View File
@@ -0,0 +1,68 @@
#!/bin/sh
set -eux pipefail
# containerlab needs some time to setup links
sleep $CONTAINERLAB_TIMEOUT
if [ "$ROLE" = "switch" ]; then
echo "Configuring as switch with MAC=$MAC"
if [ "$VLAN" = "yes" ]; then
ip link add name br0 type bridge vlan_filtering 1
else
ip link add name br0 type bridge
fi
ip link set dev br0 address $MAC
ip link set br0 up
for i in eth1 eth2 eth3 eth4; do
ip link set $i master br0
ip link set $i up
done
if [ "$VLAN" = "yes" ]; then
bridge vlan add dev eth1 vid 10 pvid untagged
bridge vlan add dev eth2 vid 20 pvid untagged
bridge vlan add dev eth4 vid 10,20
fi
echo "Switch setup complete"
elif [ "$ROLE" = "bridge" ]; then
echo "Configuring as bridge with MAC=$MAC"
if [ "$VLAN" = "yes" ]; then
ip link add name br0 type bridge vlan_filtering 1
else
ip link add name br0 type bridge
fi
ip link set dev br0 address $MAC
ip link set br0 up
ip link set eth1 master br0
ip link set eth2 master br0
ip link set eth1 up
ip link set eth2 up
if [ "$VLAN" = "yes" ]; then
bridge vlan add dev eth1 vid 10,20
bridge vlan add dev eth2 vid 10,20
fi
echo "Bridge setup complete"
elif [ "$ROLE" = "host" ]; then
echo "Configuring as host with MAC=$MAC"
ip link set dev eth1 down
ip link set dev eth1 address $MAC
ip link set dev eth1 up
echo "Host setup complete"
else
echo "Unknown ROLE: $ROLE"
fi
sleep infinity
+73
View File
@@ -0,0 +1,73 @@
name: l2-l3-1
prefix: net
topology:
kinds:
linux:
image: docker.io/itqdev/netops:latest
defaults:
network-mode: none
cmd: /scripts/node-init.sh
env:
ROLE: host
CONTAINERLAB_TIMEOUT: 5
VLAN: yes
binds:
- ./docker/scripts:/scripts
nodes:
sw_left:
kind: linux
env:
ROLE: switch
MAC: "02:11:11:11:00:01"
sw_right:
kind: linux
env:
ROLE: switch
MAC: "02:11:11:11:00:02"
mid_bridge:
kind: linux
env:
ROLE: bridge
MAC: "02:11:11:11:11:03"
pc1:
kind: linux
env:
MAC: "02:00:00:00:01:01"
pc2:
kind: linux
env:
MAC: "02:00:00:00:01:02"
pc3:
kind: linux
env:
MAC: "02:00:00:00:01:03"
pc4:
kind: linux
env:
MAC: "02:00:00:00:02:04"
pc5:
kind: linux
env:
MAC: "02:00:00:00:02:05"
pc6:
kind: linux
env:
MAC: "02:00:00:00:02:06"
links:
- endpoints: ["sw_left:eth1", "pc1:eth1"]
- endpoints: ["sw_left:eth2", "pc2:eth1"]
- endpoints: ["sw_left:eth3", "pc3:eth1"]
- endpoints: ["sw_right:eth1", "pc4:eth1"]
- endpoints: ["sw_right:eth2", "pc5:eth1"]
- endpoints: ["sw_right:eth3", "pc6:eth1"]
- endpoints: ["sw_left:eth4", "mid_bridge:eth1"]
- endpoints: ["sw_right:eth4", "mid_bridge:eth2"]
# - endpoints: ["sw_left:eth5", "sw_right:eth5"]
+5
View File
@@ -0,0 +1,5 @@
# Backup of containerlab topology
*.yaml.bak
# containerlab files
clab-*
+54
View File
@@ -0,0 +1,54 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y --no-install-recommends \
ca-certificates \
curl \
bash \
zsh \
vim \
git \
bind9-dnsutils \
bridge-utils \
conntrack \
ethtool \
ipset \
iptables \
openssh-server \
strace \
jq \
netcat-openbsd \
ipython3 \
scapy \
iproute2 \
iputils-ping \
iputils-arping \
mtr \
traceroute \
tcptraceroute \
net-tools \
tcpdump \
tshark \
bird2-doc \
bird2 && \
mkdir /run/bird && \
apt clean && \
rm -rf /var/lib/apt/lists/*
USER root
WORKDIR /root
ENV HOSTNAME=sch57
# ZSH Themes
RUN curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh
RUN git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
COPY ./configs/zshrc .zshrc
COPY ./configs/motd motd
RUN chmod -R g=u /root
RUN chown root:root /usr/bin/dumpcap
CMD [ "sleep", "infinity" ]
+8
View File
@@ -0,0 +1,8 @@
_ ___
| | |__ \
| | ) |
| | / /
| |____ / /_
|______|____|
Networks Demo
+140
View File
@@ -0,0 +1,140 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
#export TERM="xterm-256color"
ZSH_THEME="powerlevel10k/powerlevel10k"
ZSH_DISABLE_COMPFIX="true"
# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
zsh-autosuggestions
yarn
web-search
jsontools
macports
node
sudo
docker
)
source $ZSH/oh-my-zsh.sh
# User configuration
cat motd
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# Reload the plugin to highlight the commands each time Iterm2 starts
#source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
### VISUAL CUSTOMIZATION ###
# Elements options of left prompt (remove the @username context)
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(host dir rbenv)
# Elements options of right prompt
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
# Add a second prompt line for the command
POWERLEVEL9K_PROMPT_ON_NEWLINE=false
# Add a space in the first prompt
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=''
# Visual customization of the second prompt line
#local user_symbol="$"
#if [[ $(print -P "%#") =~ "#" ]]; then
# user_symbol = "#"
#fi
#POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%{%B%F{black}%K{yellow}%} $user_symbol%{%b%f%k%F{yellow}%} %{%f%}"
# Change the git status to red when something isn't committed and pushed
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='red'
# Add a new line after the global prompt
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
# Colorize the top Tabs of Iterm2 with the same color as background
# Just change the 18/26/33 which are the rgb values
echo -e "\033]6;1;bg;red;brightness;18\a"
echo -e "\033]6;1;bg;green;brightness;26\a"
echo -e "\033]6;1;bg;blue;brightness;33\a"
+40
View File
@@ -0,0 +1,40 @@
#!/bin/sh
set -eux pipefail
# containerlab needs some time to setup links
sleep $CONTAINERLAB_TIMEOUT
if [ "$ROUTER" = "yes" ]; then
echo "Configuring as router..."
ip link add br0 type bridge
ip addr add 192.168.100.1/24 dev br0
ip addr add 172.16.100.1/24 dev br0
ip link set dev br0 up
ip link set eth1 up
ip link set eth2 up
ip link set eth3 up
ip link set eth4 up
ip link set eth1 master br0
ip link set eth2 master br0
ip link set eth3 master br0
ip link set eth4 master br0
echo "Router setup complete"
else
echo "Configuring as host with CIDR=$CIDR and GATEWAY=$GATEWAY"
ip link set eth1 up
ip addr add $CIDR dev eth1
ip route add default via $GATEWAY dev eth1
echo "Host setup complete"
fi
sleep infinity
+54
View File
@@ -0,0 +1,54 @@
name: l2-l3-2
prefix: net
topology:
kinds:
linux:
image: docker.io/itqdev/netops:latest
defaults:
network-mode: none
cmd: /scripts/node-init.sh
env:
ROUTER: no
CONTAINERLAB_TIMEOUT: 5
binds:
- ./docker/scripts:/scripts
nodes:
router1:
kind: linux
env:
ROUTER: yes
sysctls:
net.ipv4.ip_forward: 1
pc1:
kind: linux
env:
CIDR: 192.168.100.10/24
GATEWAY: 192.168.100.1
pc2:
kind: linux
env:
CIDR: 192.168.100.20/24
GATEWAY: 192.168.100.1
pc3:
kind: linux
env:
CIDR: 172.16.100.10/24
GATEWAY: 172.16.100.1
pc4:
kind: linux
env:
CIDR: 172.16.100.20/24
GATEWAY: 172.16.100.1
links:
- endpoints: ["router1:eth1", "pc1:eth1"]
- endpoints: ["router1:eth2", "pc2:eth1"]
- endpoints: ["router1:eth3", "pc3:eth1"]
- endpoints: ["router1:eth4", "pc4:eth1"]
+18
View File
@@ -0,0 +1,18 @@
CFLAGS := "-Wall -O2"
PROGRAM := "sockets_demo"
build:
gcc {{CFLAGS}} -o {{PROGRAM}} main.c
run: build
sudo ./{{PROGRAM}}
clean:
rm -f {{PROGRAM}}
udp-server:
nc -u -l -p 12002
tcp-server:
nc -l -p 12001
+133
View File
@@ -0,0 +1,133 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/ip_icmp.h>
#define SRC_PORT 12000
void stream_socket() {
printf("\n=== STREAM SOCKET (TCP) ===\n");
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
perror("socket");
return;
}
struct sockaddr_in src = {0};
src.sin_family = AF_INET;
src.sin_addr.s_addr = inet_addr("127.0.0.1");
src.sin_port = htons(SRC_PORT);
if (bind(sock, (struct sockaddr*)&src, sizeof(src)) < 0) {
perror("bind");
close(sock);
return;
}
struct sockaddr_in server = {0};
server.sin_family = AF_INET;
server.sin_port = htons(12001);
inet_pton(AF_INET, "127.0.0.1", &server.sin_addr);
printf("[*] Connecting to 127.0.0.1:12001...\n");
if (connect(sock, (struct sockaddr*)&server, sizeof(server)) == 0) {
printf("[+] Connected successfully!\n");
const char *msg = "привет никифор";
send(sock, msg, strlen(msg), 0);
char buf[256] = {0};
recv(sock, buf, sizeof(buf) - 1, 0);
printf("[Response]:\n%s\n", buf);
} else {
perror("connect");
}
close(sock);
}
void datagram_socket() {
printf("\n=== DATAGRAM SOCKET (UDP) ===\n");
int sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
perror("socket");
return;
}
struct sockaddr_in src = {0};
src.sin_family = AF_INET;
src.sin_addr.s_addr = inet_addr("127.0.0.1");
src.sin_port = htons(SRC_PORT);
if (bind(sock, (struct sockaddr*)&src, sizeof(src)) < 0) {
perror("bind");
close(sock);
return;
}
struct sockaddr_in dest = {0};
dest.sin_family = AF_INET;
dest.sin_port = htons(12002);
inet_pton(AF_INET, "127.0.0.1", &dest.sin_addr);
const char *msg = "ялквмом!";
printf("[*] Sending UDP datagram to 127.0.0.1:12002...\n");
sendto(sock, msg, strlen(msg), 0, (struct sockaddr*)&dest, sizeof(dest));
printf("[+] Datagram sent, waiting for response...\n");
char buf[256];
socklen_t addrlen = sizeof(dest);
while (1) {
ssize_t n = recvfrom(sock, buf, sizeof(buf) - 1, 0, (struct sockaddr*)&dest, &addrlen);
if (n > 0) {
buf[n] = '\0';
printf("[Response]: \n%s\n", buf);
break;
} else {
sleep(0.1);
}
}
close(sock);
}
void raw_socket() {
printf("\n=== RAW SOCKET (ICMP) ===\n");
int sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
if (sock < 0) {
perror("socket");
return;
}
struct sockaddr_in dest = {0};
dest.sin_family = AF_INET;
inet_pton(AF_INET, "8.8.8.8", &dest.sin_addr);
struct icmphdr icmp_hdr = {0};
icmp_hdr.type = ICMP_ECHO;
icmp_hdr.code = 0;
icmp_hdr.checksum = 0xFFFF;
printf("[*] Sending ICMP echo request to 8.8.8.8...\n");
ssize_t sent = sendto(sock, &icmp_hdr, sizeof(icmp_hdr), 0,
(struct sockaddr*)&dest, sizeof(dest));
if (sent > 0)
printf("[+] ICMP packet sent\n");
else
perror("sendto");
close(sock);
}
int main() {
stream_socket();
sleep(1);
datagram_socket();
sleep(1);
raw_socket();
return 0;
}
+5
View File
@@ -0,0 +1,5 @@
# Backup of containerlab topology
*.bak
# containerlab files
clab-*
+43
View File
@@ -0,0 +1,43 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y --no-install-recommends \
ca-certificates \
curl \
bash \
vim \
git \
bind9-dnsutils \
bridge-utils \
conntrack \
ethtool \
ipset \
iptables \
openssh-server \
strace \
jq \
iproute2 \
iputils-ping \
iputils-arping \
mtr \
traceroute \
tcptraceroute \
net-tools \
tcpdump \
tshark \
frr \
frr-pythontools && \
apt clean
USER root
WORKDIR /root
ENV HOSTNAME=ya-kit
COPY motd motd
RUN chmod -R g=u /root
RUN chown root:root /usr/bin/dumpcap
CMD ["bash"]
Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

+36
View File
@@ -0,0 +1,36 @@
zebra=yes
bgpd=yes
ospfd=yes
ospf6d=no
ripd=yes
ripngd=no
isisd=no
pimd=no
ldpd=no
nhrpd=no
eigrpd=no
babeld=no
sharpd=no
staticd=yes
pbrd=no
bfdd=no
fabricd=no
vtysh_enable=yes
zebra_options=" -s 90000000 --daemon -A 127.0.0.1"
bgpd_options=" --daemon -A 127.0.0.1"
ospfd_options=" --daemon -A 127.0.0.1"
ospf6d_options=" --daemon -A ::1"
ripd_options=" --daemon -A 127.0.0.1"
ripngd_options=" --daemon -A ::1"
isisd_options=" --daemon -A 127.0.0.1"
pimd_options=" --daemon -A 127.0.0.1"
ldpd_options=" --daemon -A 127.0.0.1"
nhrpd_options=" --daemon -A 127.0.0.1"
eigrpd_options=" --daemon -A 127.0.0.1"
babeld_options=" --daemon -A 127.0.0.1"
sharpd_options=" --daemon -A 127.0.0.1"
staticd_options=" --daemon -A 127.0.0.1"
pbrd_options=" --daemon -A 127.0.0.1"
bfdd_options=" --daemon -A 127.0.0.1"
fabricd_options=" --daemon -A 127.0.0.1"
View File
+87
View File
@@ -0,0 +1,87 @@
# Router A
10.10.10.1 A-eth1
192.168.1.254 A-eth2
10.10.0.1 A
# Router B
10.10.10.2 B-eth1
10.10.10.9 B-eth2
10.10.10.13 B-eth3
10.10.0.2 B
# Router C
10.10.10.17 C-eth1
192.168.4.254 C-eth2
10.10.10.21 C-eth3
10.10.0.3 C
# Router D
10.10.10.10 D-eth1
10.10.10.18 D-eth2
10.10.10.25 D-eth3
10.10.10.28 D-eth4
10.10.0.4 D
# Router F
10.10.10.14 F-eth1
10.10.10.26 F-eth2
203.0.113.1 F-eth3
203.0.113.5 F-eth4
10.10.0.5 F
# Router G
10.10.10.22 G-eth1
10.10.10.30 G-eth2
203.0.113.9 G-eth3
10.10.0.6 G
# Router R1
10.30.30.1 R1-eth1
10.30.30.5 R1-eth2
203.0.113.10 R1-eth3
203.0.113.6 R1-eth4
203.0.113.14 R1-eth5
10.30.0.1 R1
# Router R2
10.30.30.2 R2-eth1
10.30.30.9 R2-eth3
10.30.0.2 R2
# Router R3
10.30.30.6 R3-eth1
192.168.3.254 R3-eth2
10.30.30.10 R3-eth3
10.30.0.3 R3
# Router Frodo
10.20.20.2 Frodo-eth1
192.168.2.254 Frodo-eth2
10.20.20.9 Frodo-eth3
192.168.5.254 Frodo-eth4
10.20.0.2 Frodo
# Router Gandalf
10.20.20.1 Gandalf-eth1
10.20.20.5 Gandalf-eth2
203.0.113.2 Gandalf-eth3
203.0.113.13 Gandalf-eth5
10.20.0.1 Gandalf
# Router Sam
10.20.20.6 Sam-eth1
10.20.20.10 Sam-eth3
10.20.0.3 Sam
# Host 1
192.168.1.1 host1
# Host 2
192.168.2.1 host2
# Host 3
192.168.3.1 host3
192.168.5.1 host3-alt
# Host 4
192.168.4.1 host4
+13
View File
@@ -0,0 +1,13 @@
███████████ █████ ███
░░███░░░░░███ ░░███ ░░░
░███ ░███ ██████ █████ ████ ███████ ████ ████████ ███████
░██████████ ███░░███░░███ ░███ ░░░███░ ░░███ ░░███░░███ ███░░███
░███░░░░░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███
░███ ░███ ░███ ░███ ░███ ░███ ░███ ███ ░███ ░███ ░███ ░███ ░███
█████ █████░░██████ ░░████████ ░░█████ █████ ████ █████░░███████
░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░███
███ ░███
░░██████
░░░░░░
Routing information exchange protocols lab
+27
View File
@@ -0,0 +1,27 @@
frr version 8.1
frr defaults traditional
hostname A
no ipv6 forwarding
!
interface eth1
ip address 10.10.10.1/30
ip ospf cost 10
exit
!
interface eth2
ip address 192.168.1.254/24
ip ospf passive
exit
!
interface lo
ip address 10.10.0.1/32
ip ospf passive
exit
!
router ospf
ospf router-id 10.10.0.1
network 10.10.0.1/32 area 1
network 10.10.10.0/30 area 1
network 192.168.1.0/24 area 1
exit
!
+32
View File
@@ -0,0 +1,32 @@
frr version 8.1
frr defaults traditional
hostname B
no ipv6 forwarding
!
interface eth1
ip address 10.10.10.2/30
ip ospf cost 10
exit
!
interface eth2
ip address 10.10.10.9/30
ip ospf cost 10
exit
!
interface eth3
ip address 10.10.10.13/30
exit
!
interface lo
ip address 10.10.0.2/32
ip ospf passive
exit
!
router ospf
ospf router-id 10.10.0.2
network 10.10.0.2/32 area 0
network 10.10.10.0/30 area 1
network 10.10.10.8/30 area 0
network 10.10.10.12/30 area 0
exit
!
+32
View File
@@ -0,0 +1,32 @@
frr version 8.1
frr defaults traditional
hostname C
no ipv6 forwarding
!
interface eth1
ip address 10.10.10.17/30
ip ospf cost 1
exit
!
interface eth2
ip address 192.168.4.254/24
ip ospf passive
exit
!
interface eth3
ip address 10.10.10.21/30
ip ospf cost 100
exit
!
interface lo
ip address 10.10.0.3/32
ip ospf passive
exit
!
router ospf
ospf router-id 10.10.0.3
network 10.10.0.3/32 area 2
network 10.10.10.0/27 area 2
network 192.168.4.0/24 area 2
exit
!
+39
View File
@@ -0,0 +1,39 @@
frr version 8.1
frr defaults traditional
hostname D
no ipv6 forwarding
!
interface eth1
ip address 10.10.10.10/30
ip ospf cost 10
exit
!
interface eth2
ip address 10.10.10.18/30
ip ospf cost 1
exit
!
interface eth3
ip address 10.10.10.25/30
ip ospf cost 1
exit
!
interface eth4
ip address 10.10.10.28/30
ip ospf cost 10
exit
!
interface lo
ip address 10.10.0.4/32
ip ospf passive
exit
!
router ospf
ospf router-id 10.10.0.4
network 10.10.0.4/32 area 0
network 10.10.10.8/30 area 0
network 10.10.10.16/30 area 2
network 10.10.10.24/30 area 0
network 10.10.10.28/30 area 2
exit
!
+81
View File
@@ -0,0 +1,81 @@
frr version 8.1
frr defaults traditional
hostname F
no ipv6 forwarding
!
interface eth1
description B-eth3
ip address 10.10.10.14/30
ip ospf cost 10
exit
!
interface eth2
description D-eth3
ip address 10.10.10.26/30
ip ospf cost 1
exit
!
interface eth3
description Gandalf-eth3
ip address 203.0.113.1/30
exit
!
interface eth4
description R1-eth4
ip address 203.0.113.5/30
exit
!
interface lo
ip address 10.10.0.5/32
ip ospf passive
exit
!
router bgp 65501
bgp router-id 10.10.0.5
no bgp ebgp-requires-policy
neighbor 10.10.0.6 remote-as 65501
neighbor 10.10.0.6 update-source lo
neighbor 203.0.113.2 remote-as 65502
neighbor 203.0.113.2 update-source eth3
neighbor 203.0.113.6 remote-as 65503
neighbor 203.0.113.6 update-source eth4
!
address-family ipv4 unicast
redistribute ospf metric 10 route-map BGP4-OSPF
neighbor 10.10.0.6 next-hop-self
neighbor 203.0.113.2 route-map PREFER-ROUTE in
neighbor 203.0.113.6 route-map PREFER-ROUTE2 in
exit-address-family
exit
!
router ospf
ospf router-id 10.10.0.5
redistribute bgp metric 20 metric-type 1 route-map BGP4-OSPF
network 10.10.0.5/32 area 0
network 10.10.10.0/27 area 0
exit
!
ip prefix-list ALLOWED_ROUTES seq 10 permit 10.0.0.0/24 ge 32
ip prefix-list ALLOWED_ROUTES seq 20 permit 192.168.0.0/16 ge 24
ip prefix-list ALLOWED_ROUTES seq 30 deny 0.0.0.0/0 le 32
ip prefix-list PREFER-ROUTE seq 5 permit 192.168.2.0/24
ip prefix-list PREFER-ROUTE seq 10 deny any
ip prefix-list PREFER-ROUTE2 seq 5 permit 192.168.3.0/24
ip prefix-list PREFER-ROUTE2 seq 10 deny any
!
route-map BGP4-OSPF permit 10
match ip address prefix-list ALLOWED_ROUTES
exit
!
route-map PREFER-ROUTE permit 10
match ip address prefix-list PREFER-ROUTE
set local-preference 200
set weight 32768
exit
!
route-map PREFER-ROUTE2 permit 10
match ip address prefix-list PREFER-ROUTE2
set local-preference 200
set weight 32768
exit
!
+62
View File
@@ -0,0 +1,62 @@
frr version 8.1
frr defaults traditional
hostname G
no ipv6 forwarding
!
interface eth1
description C-eth3
ip address 10.10.10.22/30
ip ospf cost 100
exit
!
interface eth2
description D-eth4
ip address 10.10.10.30/30
ip ospf cost 10
exit
!
interface eth3
description R1-eth3
ip address 203.0.113.9/30
exit
!
interface lo
ip address 10.10.0.6/32
ip ospf passive
exit
!
router bgp 65501
bgp router-id 10.10.0.6
no bgp ebgp-requires-policy
neighbor 10.10.0.5 remote-as 65501
neighbor 10.10.0.5 shutdown
neighbor 10.10.0.5 update-source lo
neighbor 203.0.113.10 remote-as 65503
neighbor 203.0.113.10 update-source eth3
!
address-family ipv4 unicast
redistribute ospf metric 10 route-map BGP-to-OSPF
neighbor 10.10.0.5 next-hop-self
neighbor 203.0.113.10 route-map PREPEND out
exit-address-family
exit
!
router ospf
ospf router-id 10.10.0.6
redistribute bgp metric 20 metric-type 1 route-map BGP-to-OSPF
network 10.10.0.6/32 area 2
network 10.10.10.0/27 area 2
exit
!
ip prefix-list ALLOWED_ROUTES seq 10 permit 10.0.0.0/24 ge 32
ip prefix-list ALLOWED_ROUTES seq 20 permit 192.168.0.0/16 ge 24
ip prefix-list ALLOWED_ROUTES seq 30 deny 0.0.0.0/0 le 32
!
route-map BGP-to-OSPF permit 10
match ip address prefix-list ALLOWED_ROUTES
exit
!
route-map PREPEND permit 10
set as-path prepend 65501 65501
exit
!
+64
View File
@@ -0,0 +1,64 @@
frr version 8.1
frr defaults traditional
hostname R1
no ipv6 forwarding
!
interface eth1
ip address 10.30.30.1/30
exit
!
interface eth2
description R3-eth1
ip address 10.30.30.5/30
exit
!
interface eth3
ip address 203.0.113.10/30
exit
!
interface eth4
ip address 203.0.113.6/30
exit
!
interface eth5
ip address 203.0.113.14/30
exit
!
interface lo
ip address 10.30.0.1/32
exit
!
router rip
network 10.30.0.1/32
network 10.30.30.0/28
passive-interface lo
passive-interface eth3
passive-interface eth4
passive-interface eth5
redistribute bgp metric 5 route-map BGP4-rip
version 2
exit
!
router bgp 65503
bgp router-id 10.30.0.1
no bgp ebgp-requires-policy
neighbor 203.0.113.5 remote-as 65501
neighbor 203.0.113.5 update-source lo
neighbor 203.0.113.9 remote-as 65501
neighbor 203.0.113.9 update-source eth3
neighbor 203.0.113.13 remote-as 65502
neighbor 203.0.113.13 update-source eth5
!
address-family ipv4 unicast
redistribute rip route-map BGP4-rip
exit-address-family
exit
!
ip prefix-list ALLOWED_ROUTES seq 10 permit 10.0.0.0/24 ge 32
ip prefix-list ALLOWED_ROUTES seq 20 permit 192.168.0.0/16 ge 24
ip prefix-list ALLOWED_ROUTES seq 30 deny 0.0.0.0/0 le 32
!
route-map BGP4-rip permit 10
match ip address prefix-list ALLOWED_ROUTES
exit
!
+24
View File
@@ -0,0 +1,24 @@
frr version 8.1
frr defaults traditional
hostname R2
no ipv6 forwarding
!
interface eth1
ip address 10.30.30.2/30
exit
!
interface eth3
ip address 10.30.30.9/30
exit
!
interface lo
ip address 10.30.0.2/32
exit
!
router rip
network 10.30.0.2/32
network 10.30.30.0/28
passive-interface lo
version 2
exit
!
+30
View File
@@ -0,0 +1,30 @@
frr version 8.1
frr defaults traditional
hostname R3
no ipv6 forwarding
!
interface eth1
ip address 10.30.30.6/30
exit
!
interface eth2
ip address 192.168.3.254/24
exit
!
interface eth3
ip address 10.30.30.10/30
exit
!
interface lo
ip address 10.30.0.3/32
exit
!
router rip
network 10.30.0.3/32
network 10.30.30.0/28
network 192.168.3.0/24
passive-interface lo
passive-interface eth2
version 2
exit
!
+45
View File
@@ -0,0 +1,45 @@
frr version 8.1
frr defaults traditional
hostname Frodo
no ipv6 forwarding
!
interface eth1
description Gandalf-eth1
ip address 10.20.20.2/30
exit
!
interface eth2
description usernet2
ip address 192.168.2.254/24
ip ospf passive
exit
!
interface eth3
description Sam-eth3
ip address 10.20.20.9/30
exit
!
interface eth4
description usernet3
ip address 192.168.5.254/24
ip ospf passive
exit
!
interface lo
ip address 10.20.0.2/32
ip ospf passive
exit
!
router ospf
ospf router-id 10.20.0.2
network 10.20.0.2/32 area 1
network 10.20.20.0/30 area 0
network 10.20.20.8/30 area 0
network 192.168.2.0/24 area 1
network 192.168.5.0/24 area 1
area 0 filter-list prefix RESTRICT_5_SUBNET in
exit
!
ip prefix-list RESTRICT_5_SUBNET seq 5 deny 192.168.5.0/24
ip prefix-list RESTRICT_5_SUBNET seq 10 permit any
!
+55
View File
@@ -0,0 +1,55 @@
frr version 8.1
frr defaults traditional
hostname Gandalf
no ipv6 forwarding
!
interface eth1
ip address 10.20.20.1/30
exit
!
interface eth2
ip address 10.20.20.5/30
exit
!
interface eth3
ip address 203.0.113.2/30
exit
!
interface eth5
ip address 203.0.113.13/30
exit
!
interface lo
ip address 10.20.0.1/32
ip ospf passive
exit
!
router bgp 65502
bgp router-id 10.20.0.1
no bgp ebgp-requires-policy
neighbor 203.0.113.1 remote-as 65501
neighbor 203.0.113.1 update-source eth3
neighbor 203.0.113.14 remote-as 65503
neighbor 203.0.113.14 update-source eth5
!
address-family ipv4 unicast
redistribute ospf metric 10 route-map BGP4-OSPF
exit-address-family
exit
!
router ospf
ospf router-id 10.20.0.1
redistribute bgp metric 20 metric-type 1 route-map BGP4-OSPF
network 10.20.0.1/32 area 0
network 10.20.20.0/30 area 0
network 10.20.20.4/30 area 0
exit
!
ip prefix-list ALLOWED_ROUTES seq 10 permit 10.0.0.0/24 ge 32
ip prefix-list ALLOWED_ROUTES seq 20 permit 192.168.0.0/16 ge 24
ip prefix-list ALLOWED_ROUTES seq 30 deny 0.0.0.0/0 le 32
!
route-map BGP4-OSPF permit 10
match ip address prefix-list ALLOWED_ROUTES
exit
!
+25
View File
@@ -0,0 +1,25 @@
frr version 8.1
frr defaults traditional
hostname Sam
no ipv6 forwarding
!
interface eth1
ip address 10.20.20.6/30
exit
!
interface eth3
ip address 10.20.20.10/30
exit
!
interface lo
ip address 10.20.0.3/32
ip ospf passive
exit
!
router ospf
ospf router-id 10.20.0.3
network 10.20.0.3/32 area 0
network 10.20.20.4/30 area 0
network 10.20.20.8/30 area 0
exit
!
+187
View File
@@ -0,0 +1,187 @@
name: routing
prefix: net
topology:
kinds:
linux:
image: docker.io/itqdev/netops:routing
defaults:
network-mode: none
nodes:
A:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- ospf/A/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
B:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- ospf/B/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
C:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- ospf/C/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
D:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- ospf/D/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
F:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- ospf/F/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
G:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- ospf/G/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
Gandalf:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- static/Gandalf/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
Frodo:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- static/Frodo/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
Sam:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- static/Sam/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
R1:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- rip/R1/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
R2:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- rip/R2/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
R3:
kind: linux
binds:
- common/daemons:/etc/frr/daemons
- common/vtysh.conf:/etc/frr/vtysh.conf
- rip/R3/frr.conf:/etc/frr/frr.conf
exec:
- service frr start
host1:
kind: linux
image: docker.io/itqdev/netops:latest
binds:
- hosts:/etc/hosts
exec:
- ip addr add 192.168.1.1/24 dev eth2
- ip link set eth2 up
- ip route add 192.168.0.0/16 via 192.168.1.254 dev eth2
host4:
kind: linux
image: docker.io/itqdev/netops:latest
binds:
- hosts:/etc/hosts
exec:
- ip addr add 192.168.4.1/24 dev eth2
- ip link set eth2 up
- ip route add 192.168.0.0/16 via 192.168.4.254 dev eth2
host2:
kind: linux
image: docker.io/itqdev/netops:latest
binds:
- hosts:/etc/hosts
exec:
- ip addr add 192.168.2.1/24 dev eth2
- ip link set eth2 up
- ip route add 192.168.0.0/16 via 192.168.2.254 dev eth2
host3:
kind: linux
image: docker.io/itqdev/netops:latest
binds:
- hosts:/etc/hosts
exec:
- ip addr add 192.168.3.1/24 dev eth2
- ip link set eth2 up
- ip route add 192.168.0.0/16 via 192.168.3.254 dev eth2
- ip addr add 192.168.5.1/24 dev eth4
- ip link set eth4 up
- ip route add 192.168.2.0/24 via 192.168.5.254 dev eth4
links:
- endpoints: ["A:eth1","B:eth1"]
- endpoints: ["B:eth2","D:eth1"]
- endpoints: ["B:eth3","F:eth1"]
- endpoints: ["C:eth1","D:eth2"]
- endpoints: ["C:eth3","G:eth1"]
- endpoints: ["D:eth3","F:eth2"]
- endpoints: ["D:eth4","G:eth2"]
- endpoints: ["Gandalf:eth3","F:eth3"]
- endpoints: ["Gandalf:eth1","Frodo:eth1"]
- endpoints: ["Gandalf:eth2","Sam:eth1"]
- endpoints: ["Frodo:eth3","Sam:eth3"]
- endpoints: ["R1:eth3","G:eth3"]
- endpoints: ["R1:eth4","F:eth4"]
- endpoints: ["R1:eth1","R2:eth1"]
- endpoints: ["R1:eth2","R3:eth1"]
- endpoints: ["R1:eth5","Gandalf:eth5"]
- endpoints: ["R2:eth3","R3:eth3"]
- endpoints: ["A:eth2","host1:eth2"]
- endpoints: ["C:eth2","host4:eth2"]
- endpoints: ["Frodo:eth2","host2:eth2"]
- endpoints: ["R3:eth2","host3:eth2"]
- endpoints: ["Frodo:eth4","host3:eth4"]