Benutzer:Leo/Setup dev environment for Opennet Firmware: Unterschied zwischen den Versionen
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
Leo (Diskussion | Beiträge) Die Seite wurde neu angelegt: „<span id="setup-dev-environment-for-opennet-firmware"></span> = Setup dev environment for Opennet Firmware = We want to have a dev environment for Opennet fir…“ |
Leo (Diskussion | Beiträge) nutze kein plain Debian weil sehr aufwändig |
||
| Zeile 174: | Zeile 174: | ||
uci commit |
uci commit |
||
/etc/init.d/system restart</pre> |
/etc/init.d/system restart</pre> |
||
<span id="create-debian-vm"></span> |
|||
= Create Debian VM = |
|||
Instructions: https://wiki.debian.org/ThomasChung/CloudImage |
|||
<pre> |
|||
#wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2 |
|||
#sudo apt update |
|||
#sudo apt install libguestfs-tools |
|||
# client mit Debian 12 |
|||
#--- begin manual input --- |
|||
VM_TEMPLATE="debian-12-generic-amd64.qcow2" |
|||
VM_ID=13 # between 10..250; SET ID HERE!!! |
|||
VIRBR_NR=4 |
|||
#--- end manual input --- |
|||
VM_NAME=oni-00${VM_ID}-client-${VM_IMAGE%-amd64*} |
|||
VM_IMAGE=$VM_NAME.img |
|||
cp $VM_TEMPLATE $VM_IMAGE |
|||
cat > config.yaml <<EOF |
|||
network: |
|||
version: 2 |
|||
renderer: networkd |
|||
ethernets: |
|||
ens1: |
|||
dhcp4: true |
|||
ens2: |
|||
dhcp4: no |
|||
addresses: |
|||
- 192.168.101.${VM_ID}/24 |
|||
EOF |
|||
sudo virt-customize -a $VM_IMAGE --root-password password:admin --upload |
|||
cat > meta-data.yaml <<EOF |
|||
network-interfaces: | |
|||
iface ens1 inet static |
|||
address 192.168.101.${VM_ID}/24 |
|||
iface ens2 inet dhcp |
|||
EOF |
|||
sudo virt-install --connect "qemu:///system" -n "$VM_NAME" -r 1024 --vcpus=1 \ |
|||
--import --disk "path=$VM_IMAGE,format=qcow2,bus=sata,size=512" \ |
|||
--graphics vnc,keymap=de --serial pty --noautoconsole \ |
|||
--osinfo linux2020 \ |
|||
--network bridge=virbr${VIRBR_NR},model=e1000 \ |
|||
--network bridge=virbr2,model=e1000 \ |
|||
--hvm |
|||
--cloud-init meta-data=meta-data |
|||
# LAN - virbr${VIRBR_NR} |
|||
# WAN - virbr0 |
|||
# MESH - virbr1 |
|||
# MGMT - virbr2 |
|||
cat > /etc/netplan/config.yaml <<EOF |
|||
network: |
|||
version: 2 |
|||
renderer: networkd |
|||
ethernets: |
|||
ens1: |
|||
dhcp4: true |
|||
ens2: |
|||
dhcp4: no |
|||
addresses: |
|||
- 192.168.101.${VM_ID}/24 |
|||
EOF |
|||
netplan apply |
|||
#login via console |
|||
# apt update |
|||
# apt install --reinstall openssh-server |
|||
# vi /etc/ssh/sshd_config |
|||
... |
|||
PasswordAuthentication yes |
|||
... |
|||
# systemctl reload sshd |
|||
</pre> |
|||
<span id="configure-debian-vm"></span> |
|||
= Configure Debian VM = |
|||
Version vom 27. März 2024, 19:12 Uhr
Setup dev environment for Opennet Firmware
We want to have a dev environment for Opennet firmware development.
What do we need?
- 2x UGW AP (virtual x86)
- 2x User AP (virtual x86)
- 2x Clients
Network structure
see file
networks:
- internet (with NAT; also for admin access later on)
- mesh
- br-lan (for each AP)
- mgmt (for ssh/web access)
Setup virtualization infrastructure
Install kvm + quemu + virt-manager.
Create networks:
- “default”
- virbr0
- 192.168.122.0/24
- NAT for Internet connection
- “network2-mesh”
- virbr1
- mesh
- 192.168.100.0/24
- Open network
- “network3-mgmt”
- virbr2
- additional interface on AP (for ssh/web access)
- 192.168.101.0/24
- Open network
- “network4-devnull”
- virbr3
- connect all br-lan here when br-lan is not needed
- Open network, 192.168.110.0/24, no DHCP
- “network4-lan0XY” (011, 021)
- virbrZ ( 4, 6)
- br-lan for AP0XY (011, 021)
- Open network, 192.168.1XY.0/24, no DHCP
Create OpenWrt VM
download image *-x86-generic-combined-ext4.img.gz
Name file: oni-{0123}-{DATE}-{VERSIONNR}-{STUFF}
# start networks
virsh net-list --all
virsh net-start ...
##########################################
# Dies ist UGW AP mit 0.5.8 stable
VM_ID=10 # between 10..250;
AP_NR=2.1 # e.g. 2.50 for AP2.50
VIRBR_NR=3 # number of virbr for br-lan, e.g. virbr4
GZ_IMAGE=openwrt-0.5.8-3013-x86-generic-generic-ext4-combined.img.gz
# Dies ist User AP mit 0.5.8 stable
VM_ID=11 # between 10..250; SET ID HERE!!!
AP_NR=2.50 # e.g. AP2.50; SET NR HERE!!!
VIRBR_NR=4
GZ_IMAGE=openwrt-0.5.8-3013-x86-generic-generic-ext4-combined.img.gz
# Dies ist Client mit vanilla OpenWrt
VM_ID=12
AP_NR=XX #not of interest here because no olsr
VIRBR_NR=4 #will be reassigned to WAN later on
GZ_IMAGE=openwrt-23.05.2-x86-generic-generic-ext4-combined.img.gz
##########################################
#UGW unstable
VM_ID=20
AP_NR=1.238
VIRBR_NR=3
GZ_IMAGE=openwrt-0.5.9-unstable-3054-c6ff47f6-x86-generic-generic-ext4-combined.img.gz
#User-AP unstable
VM_ID=21
AP_NR=2.51
VIRBR_NR=6
GZ_IMAGE=openwrt-0.5.9-unstable-3054-c6ff47f6-x86-generic-generic-ext4-combined.img.gz
# Dies ist Client mit vanilla OpenWrt
VM_ID=22
AP_NR=YY #not of interest here because no olsr
VIRBR_NR=6 #will be reassigned to WAN later on
GZ_IMAGE=openwrt-23.05.2-x86-generic-generic-ext4-combined.img.gz
##########################################
VM_NAME=oni-00${VM_ID}-AP${AP_NR}-${GZ_IMAGE%-x86*}
VM_IMAGE=$VM_NAME.img
ls $GZ_IMAGE
zcat $GZ_IMAGE > $VM_IMAGE
sudo virt-install --connect "qemu:///system" -n "$VM_NAME" -r 1024 --vcpus=1 \
--import --disk "path=$VM_IMAGE,format=raw,bus=sata,size=512" \
--graphics vnc,keymap=de --serial pty --noautoconsole \
--osinfo linux2020 \
--network bridge=virbr${VIRBR_NR},model=e1000 \
--network bridge=virbr0,model=e1000 \
--network bridge=virbr1,model=e1000 \
--network bridge=virbr2,model=e1000 \
--hvm
#eth0 - LAN - virbr${VIRBR_NR}
#eth1 - WAN - virbr0
#eth2 - MESH - virbr1
#eth3 - MGMT - virbr2
#if you see an error:
# You will need to grant the 'libvirt-qemu' user search permissions for the following directories: ['/home/leo']
#then exec: setfacl -m u:libvirt-qemu:x /home/leo
Configure OpenWrt VM
sudo virsh console $VM_NAME
#exit from console via Ctrl+5
#Hinweis: Wenn das '=' Zeichen in der Console nicht zu schreiben ist, dann Keyboard Language mit "no dead key" installieren.
#if you want to delete VM then exec:
# sudo virsh destroy $VM_NAME
# sudo virsh undefine $VM_NAME
VMID=21 # insert VM_ID here!!!
#for all ONI Firmware (insert your publ. SSH key here)
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKfDzl26SnrS2sWq1fhkTTyEd+ASDJ6ta4CDLcBLIlR9I7SRYOhO+v1Y4agvDcQZilD+YVO7X5dlRMdnqogmbk30TGYRIZyo3TPG8vTMrjXigs8y8pcXcBPmPNOi5ZZqp7Vyqjb3w1mrtv5rKGYkd4PkMIU+WmH6WGAdMGYaLi5Zzh34mBPihT7zdheVIDhSB1+5YNhqKL0dyKss8VW+ivGfFXZd0OB078n0MW5Fx/z17YSgCMzbU6uAXPzm9jqWPgXoyX8ld4Ng+1vLdzJGSR0APHfwxWQ6z8JniTEoNIp7QRCOiAuQRS4MynicMEEiwkOgqz2Sa6lxf7bYfElg// leo@lini" > /etc/dropbear/authorized_keys
uci set network.on_eth_0.device='eth2' #for mesh
uci set network.mgmt=interface
uci set network.mgmt.device='eth3'
uci set network.mgmt.proto='static'
uci set network.mgmt.netmask="255.255.255.0"
uci set network.mgmt.ipaddr="192.168.101.$VMID"
uci commit
/etc/init.d/network restart
#ssh root@192.168.101.${VMID} # oder http
#for User-AP: deactivate wan(eth1)
uci set network.wan.auto='0'
uci set network.wan6.auto='0'
uci set network.wan.disabled="1"
uci set network.wan6.disabled="1"
uci commit
/etc/init.d/network restart
#for Client: free eth0(from br-lan) and assign eth0 to wan
uci delete network.@device[0].ports
uci set network.wan.device='eth0'
uci set network.wan6.device='eth0'
uci commit
/etc/init.d/network restart
uci add_list firewall.@zone[0].network='mgmt'
uci commit
/etc/init.d/firewall restart
uci set system.@system[0].hostname="192-168-101-${VMID}"
uci commit
/etc/init.d/system restart