create a full file

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2025-04-27 22:54:44 +02:00
commit 0a4ed4a156
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
9 changed files with 56 additions and 0 deletions

126
base_data/frr/daemons Normal file
View file

@ -0,0 +1,126 @@
# This file tells the frr package which daemons to start.
#
# Sample configurations for these daemons can be found in
# /usr/share/doc/frr/examples/.
#
# ATTENTION:
#
# When activating a daemon for the first time, a config file, even if it is
# empty, has to be present *and* be owned by the user and group "frr", else
# the daemon will not be started by /etc/init.d/frr. The permissions should
# be u=rw,g=r,o=.
# When using "vtysh" such a config file is also needed. It should be owned by
# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too.
#
# The watchfrr, zebra and staticd daemons are always started.
#
bgpd=yes
ospfd=no
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
pim6d=no
ldpd=no
nhrpd=no
eigrpd=no
babeld=no
sharpd=no
pbrd=no
bfdd=no
fabricd=no
vrrpd=no
pathd=no
#
# If this option is set the /etc/init.d/frr script automatically loads
# the config via "vtysh -b" when the servers are started.
# Check /etc/pam.d/frr if you intend to use "vtysh"!
#
vtysh_enable=yes
zebra_options=" -A 127.0.0.1 -s 90000000"
mgmtd_options=" -A 127.0.0.1"
bgpd_options=" -A 127.0.0.1"
ospfd_options=" -A 127.0.0.1"
ospf6d_options=" -A ::1"
ripd_options=" -A 127.0.0.1"
ripngd_options=" -A ::1"
isisd_options=" -A 127.0.0.1"
pimd_options=" -A 127.0.0.1"
pim6d_options=" -A ::1"
ldpd_options=" -A 127.0.0.1"
nhrpd_options=" -A 127.0.0.1"
eigrpd_options=" -A 127.0.0.1"
babeld_options=" -A 127.0.0.1"
sharpd_options=" -A 127.0.0.1"
pbrd_options=" -A 127.0.0.1"
staticd_options="-A 127.0.0.1"
bfdd_options=" -A 127.0.0.1"
fabricd_options="-A 127.0.0.1"
vrrpd_options=" -A 127.0.0.1"
pathd_options=" -A 127.0.0.1"
# If you want to pass a common option to all daemons, you can use the
# "frr_global_options" variable.
#
#frr_global_options=""
# The list of daemons to watch is automatically generated by the init script.
# This variable can be used to pass options to watchfrr that will be passed
# prior to the daemon list.
#
# To make watchfrr create/join the specified netns, add the the "--netns"
# option here. It will only have an effect in /etc/frr/<somename>/daemons, and
# you need to start FRR with "/usr/lib/frr/frrinit.sh start <somename>".
#
#watchfrr_options=""
# configuration profile
#
#frr_profile="traditional"
#frr_profile="datacenter"
# This is the maximum number of FD's that will be available. Upon startup this
# is read by the control files and ulimit is called. Uncomment and use a
# reasonable value for your setup if you are expecting a large number of peers
# in say BGP.
#
#MAX_FDS=1024
# Uncomment this option if you want to run FRR as a non-root user. Note that
# you should know what you are doing since most of the daemons need root
# to work. This could be useful if you want to run FRR in a container
# for instance.
# FRR_NO_ROOT="yes"
# For any daemon, you can specify a "wrap" command to start instead of starting
# the daemon directly. This will simply be prepended to the daemon invocation.
# These variables have the form daemon_wrap, where 'daemon' is the name of the
# daemon (the same pattern as the daemon_options variables).
#
# Note that when daemons are started, they are told to daemonize with the `-d`
# option. This has several implications. For one, the init script expects that
# when it invokes a daemon, the invocation returns immediately. If you add a
# wrap command here, it must comply with this expectation and daemonize as
# well, or the init script will never return. Furthermore, because daemons are
# themselves daemonized with -d, you must ensure that your wrapper command is
# capable of following child processes after a fork() if you need it to do so.
#
# If your desired wrapper does not support daemonization, you can wrap it with
# a utility program that daemonizes programs, such as 'daemonize'. An example
# of this might look like:
#
# bgpd_wrap="/usr/bin/daemonize /usr/bin/mywrapper"
#
# This is particularly useful for programs which record processes but lack
# daemonization options, such as perf and rr.
#
# If you wish to wrap all daemons in the same way, you may set the "all_wrap"
# variable.
#
#all_wrap=""

View file

@ -0,0 +1,25 @@
# default to using syslog. /etc/rsyslog.d/45-frr.conf places the log in
# /var/log/frr/frr.log
#
# Note:
# FRR's configuration shell, vtysh, dynamically edits the live, in-memory
# configuration while FRR is running. When instructed, vtysh will persist the
# live configuration to this file, overwriting its contents. If you want to
# avoid this, you can edit this file manually before starting FRR, or instruct
# vtysh to write configuration to a different file.
log syslog informational
router bgp 65000
bgp router-id 192.168.14.103
no bgp default ipv4-unicast
neighbor fabric peer-group
neighbor fabric remote-as 65000
neighbor fabric capability extended-nexthop
! BGP sessions with route reflectors
neighbor 192.168.14.100 peer-group fabric
!
address-family l2vpn evpn
neighbor fabric activate
advertise-all-vni
exit-address-family
!
!

View file

2
base_data/seed/meta-data Normal file
View file

@ -0,0 +1,2 @@
instance-id: iid-local03
local-hostname: my-vm-03

View file

@ -0,0 +1,14 @@
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: false
addresses:
- 240.0.1.3/4
routes:
- to: 0.0.0.0/0
via: 240.0.0.1
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1

10
base_data/seed/user-data Normal file
View file

@ -0,0 +1,10 @@
#cloud-config
users:
- name: nicolas
lock_passwd: false
passwd: "$5$K4nmmwy8HXUZvUbL$8987jEXLGdXyXhF5WPbscg5PjCXqN3jOo6lcjWXg5IC"
doas: [permit nopass nicolas]
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNxP6+vpKgqLfQ4aA90MezAkqgBtwXYWnhNQznXH6bU root@lab3
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNxP6+vpKgqLfQ4aA90MezAkqgBtwXYWnhNQznXH6bU root@lab3

75
base_data/start_net.sh Normal file
View file

@ -0,0 +1,75 @@
#!/bin/bash
function exec_command {
eval "${1}"
}
function up_bridge {
local vpc="${1}"
local bridge="br-${2}"
local exec=""
if [[ "${vpc}" != "" ]]
then
exec="ip netns exec ${vpc}"
fi
exec_command "${exec} brctl addbr ${bridge}"
exec_command "${exec} brctl stp ${bridge} off"
exec_command "${exec} ip link set up dev ${bridge}"
}
function up_vxlan {
local id="${1}"
local local_ip="${2}"
local bridge="br-${3}"
ip link add "vxlan-${id}" type vxlan \
id "${id}" \
dstport 4789 \
local "${local_ip}" \
nolearning
brctl addif "${bridge}" "vxlan-${id}"
ip link set up dev "vxlan-${id}"
}
function up_netns {
local netns="${1}"
local subnet="${2}"
local veth="veth-${subnet}"
ip netns add "${netns}"
ip link add "${veth}-ext" type veth peer name "${veth}-int" netns ${netns}
ip link set up dev "${veth}-ext"
ip -n "${netns}" link set up dev "${veth}-int"
}
INTERFACE="eno1"
LOCAL_IP=$(ip a | grep -E "^ .*${INTERFACE}$" | sed 's/ */ /g' | cut -d\ -f 3|cut -d\/ -f1)
VXLAN_ID="${2}"
SUBNET_NAME="${3}"
VPC_NAME="${4}"
TAP_NAME="${5}"
echo "Create vm subnet"
echo " -> interface name : ${INTERFACE}"
echo " -> interface ip : ${LOCAL_IP}"
echo " -> vxlan id : ${VXLAN_ID}"
echo " -> subnet name : ${SUBNET_NAME}"
echo " -> vpn : ${VPC_NAME}"
echo " -> tapid : ${TAP_NAME}"
up_netns "${VPC_NAME}" "${SUBNET_NAME}"
up_bridge "" "${SUBNET_NAME}"
up_bridge "${VPC_NAME}" "${SUBNET_NAME}"
up_vxlan "${VXLAN_ID}" "${LOCAL_IP}" "${SUBNET_NAME}"
brctl addif "br-${SUBNET_NAME}" "veth-${SUBNET_NAME}-ext"
ip netns exec "${VPC_NAME}" brctl addif "br-${SUBNET_NAME}" "veth-${SUBNET_NAME}-int"
ip -n "${VPC_NAME}" tuntap add dev "tap${TAP_NAME}" mode tap
ip -n "${VPC_NAME}" link set up dev "tap${TAP_NAME}"
ip netns exec "${VPC_NAME}" brctl addif "br-${SUBNET_NAME}" "tap${TAP_NAME}"

16
base_data/start_vm.sh Normal file
View file

@ -0,0 +1,16 @@
rm nocloud_alpine.qcow2
cp nocloud* nocloud_alpine.qcow2
qemu-system-x86_64 \
-enable-kvm \
-cpu host \
-m 512 \
-smp 1 \
-serial unix:/tmp/vm-serial.sock,server,nowait \
-monitor unix:/tmp/vm-monitor.sock,server,nowait \
-daemonize \
-display none \
-drive file=./seed/seed.iso,media=cdrom,if=ide \
-drive file=nocloud_alpine.qcow2,format=qcow2,if=virtio \
-netdev tap,id=net0,ifname=tap551,script=no,downscript=no \
-device virtio-net-pci,netdev=net0,mac=52:54:00:12:34:56