martes, 29 de abril de 2025

Port forwarding on linux

To forward traffic received on port 27017 from server to 10.10.10.10, you'll need to set up the following iptables rules on the server:
# Enable IP forwarding in the kernel
sudo sysctl -w net.ipv4.ip_forward=1

# Make IP forwarding persistent across reboots
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf

# Add the PREROUTING rule to redirect incoming traffic
sudo iptables -t nat -A PREROUTING -p tcp --dport 27017 -j DNAT --to-destination 10.10.10.10:27017

# Add the POSTROUTING rule for masquerading (if the destination is on a different network)
sudo iptables -t nat -A POSTROUTING -j MASQUERADE

# Allow forwarded traffic in the FORWARD chain
sudo iptables -A FORWARD -p tcp -d 10.10.10.10 --dport 27017 -j ACCEPT 
To make these rules persistent across reboots, save them with:
# For Debian/Ubuntu systems
sudo apt-get install iptables-persistent
sudo netfilter-persistent save

# OR for other distributions
sudo service iptables save

 

 

sábado, 19 de abril de 2025

Get all processor groups including sub-processor groups in nifi using rest api

 

nifi-api/flow/process-groups/root/status?recursive=true

 

This end point will return the process groups

Deactivate current venv python and run last one

# Deactivate current venv
deactivate

# Create new venv with Python 3.6+
python3.6 -m venv .venv  # or python3.7, python3.8, etc.

# Activate the new venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt
 
 

sudo apt install python3-pip python3-venv

pip3 --version

python3 -m venv .venv

source .venv/bin/activate

 

viernes, 18 de abril de 2025

Rotate aws keys

List all access keys
~ $ aws iam list-access-keys --user-name managment

Create a new one
~ $ aws iam create-access-key --user-name managment

Set inactive state to the old access key
~ $ aws iam update-access-key --access-key-id XXXXXXXXXXXXXXXX --status Inactive --user-name managment

Delete the old access key
~ $ aws iam delete-access-key --access-key-id XXXXXXXXXXXXXXXX --user-name managment

viernes, 11 de abril de 2025

UEFI Partition





Moving Your EFI Partition to the End of the Disk - Revised Plan

Based on the accurate disk information:Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468862128 sectors Device Start End Sectors Size Type /dev/sda1 2048 292972543 292970496 139.7G Linux filesystem /dev/sda2 292972544 295174143 2201600 1G EFI System


I can now provide a correct procedure for moving your EFI partition to the end of the disk.
Step-by-Step Process
1. PreparationBack up your entire system before proceeding
Create a bootable recovery USB with a Linux distribution
2. Back Up Your EFI Partition Contents# Create backup directory sudo mkdir -p /home/alejandro/efi_backup # Copy all EFI contents with proper permissions sudo cp -a /boot/efi/* /home/alejandro/efi_backup/ # Verify the backup ls -la /home/alejandro/efi_backup/

3. Create New EFI Partition at the End of the Disk

You can do this from your running system, but you'll need to unmount the EFI partition first:# Check if the EFI partition is mounted mount | grep efi # If it is mounted, unmount it sudo umount /boot/efi


Now create the new partition:sudo parted /dev/sda


In parted:(parted) print (parted) mkpart primary fat32 466660528s 468862127s (parted) name 3 "EFI System" (parted) set 3 esp on (parted) print (parted) quit


Note: I've placed the new partition at the very end of the disk, leaving a small margin from the absolute end. The start sector (466660528) is calculated to create a 1GB partition similar to your current EFI partition.
4. Format the New EFI Partitionsudo mkfs.fat -F32 /dev/sda3

5. Mount and Copy EFI Contents# Create mount point for the new EFI partition sudo mkdir -p /mnt/new_efi # Mount the new EFI partition sudo mount /dev/sda3 /mnt/new_efi # Copy the contents from the backup sudo cp -a /home/alejandro/efi_backup/* /mnt/new_efi/ # Verify the copy ls -la /mnt/new_efi/

6. Update the fstab File

Get the UUID of the new EFI partition:NEW_UUID=$(sudo blkid -s UUID -o value /dev/sda3) echo $NEW_UUID # Note this UUID for the next step


Edit the fstab file:# Backup the original fstab sudo cp /etc/fstab /etc/fstab.backup # Edit fstab (replace OLD_UUID with the UUID of your current EFI partition) sudo sed -i "s|UUID=OLD_UUID|UUID=$NEW_UUID|" /etc/fstab # Alternatively, edit manually sudo nano /etc/fstab

7. Update the Boot Configuration# Mount the new EFI partition to /boot/efi sudo mount /dev/sda3 /boot/efi # Update the bootloader sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB sudo update-grub

8. Update UEFI Boot Entries# List current boot entries sudo efibootmgr -v # Create a new boot entry for the new EFI partition sudo efibootmgr --create --disk /dev/sda --part 3 --label "GRUB" --loader '\EFI\GRUB\grubx64.efi' # Optionally, remove old entries (replace X with the number of the old entry) sudo efibootmgr -b X -B

9. Reboot and Test

Reboot your system and verify it boots correctly with the new EFI partition.
10. Remove the Old EFI Partition

Only after confirming successful boot:sudo parted /dev/sda


In parted:(parted) print (parted) rm 2 (parted) print (parted) quit

Additional Notes

UEFI Firmware Access: If your system doesn't boot after the change, you may need to enter your UEFI firmware settings (often by pressing F2, Del, or Esc during boot) and adjust the boot order to prioritize the new EFI partition.


Dual-Boot Considerations: If you're dual-booting with Windows or another OS, you'll need to update its boot configuration as well.


Recovery Option: If something goes wrong, you can boot from your live USB, mount your root partition, and restore the original EFI configuration using your backup.


Alternative Approach: If you encounter issues, you could also consider using a tool like Clonezilla to clone the entire disk, repartition it with the EFI at the end, and then restore the data.

This revised procedure should work with your actual disk layout. The key difference is that we now have accurate information about the disk size and available space, allowing us to correctly place the new EFI partition at the end of the disk.



miércoles, 9 de abril de 2025

Kubernetes - Passing multiple commands to the container

You can send multiple entrypoint commands to a Docker container in the command tag of kubernetes config file.

command: ["/bin/sh","-c"]
args: ["command one; command two && command three"]