Garz Documentation

website·Indexed 31 days ago

https://docs.garz.dev

A collection of code snippets, technical guides, and solutions covering Cisco device configuration (VLANs, OSPF, IPSec, NAT, ACLs), Linux administration (Fedora, Arch, Nginx, Certbot), Windows system modifications, and various developer tools like PlatformIO.

Tokens
12.8K
Snippets
104
Records
112
Agent score
51%

What's inside Garz Docs

  1. Discover connected neighbors using CDP

    Cisco Discovery Protocol (CDP) allows a device to collect information about directly connected neighbor devices, which is useful for mapping the logical network topology.
    show cdp neighbors
  2. Configure an IPSec VPN between two Cisco routers

    To establish an IPSec VPN between two Cisco routers, you must configure a matching ISAKMP policy, a shared secret key, a transform set for encryption, and a crypto map bound to the external interface.

    Key Requirements:

    • The Pre-shared Key (PSK) must match exactly on both peers.
    • The ISAKMP policy (encryption, authentication, and Diffie-Hellman group) must match on both peers.
    • The crypto map must be applied to the outside interface (e.g., gi0/0/0).
    • A static route must be configured to direct traffic for the remote network toward the peer's public IP address.

    Critical Caveats:

    • Ensure the inbound interface on the receiving peer allows the VPN traffic.
    • If using NAT/PAT, you must explicitly exclude the remote VPN network from the NAT translation using an ACL to prevent the tunnel from failing.
    ! --- Peer 1 Configuration ---
    ! Address: 223.130.23.2 | Local Net: 10.0.0.0/16
    
    crypto isakmp policy 10
      encryption aes 256
      authentication pre-share
      group 2
    
    crypto isakmp key 1mysecurepassword! address 223.130.23.6
    
    crypto ipsec transform-set my-vpn-set esp-aes 256 esp-sha-hmac
    
    ip access-list extended my-vpn-acl
      permit ip 10.0.0.0 255.255.0.0 10.1.0.0 255.255.255.0
    
    crypto map my-vpn-map 10 ipsec-isakmp
      set peer 223.130.23.6
      set transform-set my-vpn-set
      match address my-vpn-acl
    
    interface gi0/0/0
      crypto map my-vpn-map
    
    ip route 10.1.0.0 255.255.0.0 223.130.23.6
    
    ! --- Peer 2 Configuration ---
    ! Address: 223.130.23.6 | Local Net: 10.1.0.0/16
    
    crypto isakmp policy 10
      encryption aes 256
      authentication pre-share
      group 2
    
    crypto isakmp key 1mysecurepassword! address 223.130.23.2
    
    crypto ipsec transform-set my-vpn-set esp-aes 256 esp-sha-hmac
    
    ip access-list extended my-vpn-acl
      permit ip 10.1.0.0 255.255.0.0 10.0.0.0 255.255.255.0
    
    crypto map my-vpn-map 10 ipsec-isakmp
      set peer 223.130.23.2
      set transform-set my-vpn-set
      match address my-vpn-acl
    
    interface gi0/0/0
      crypto map my-vpn-map
    
    ip route 10.0.0.0 255.255.0.0 223.130.23.2
  3. Install and configure Docker on Fedora

    Standard procedure to install Docker using the official script, enable the systemd service, and configure user permissions.
    curl -fsSL https://get.docker.com -o install-docker.sh
    sh install-docker.sh
    
    # Start and enable Docker service
    sudo systemctl enable --now docker
    
    # Add current user to docker group to avoid using sudo for every command
    sudo usermod -aG docker $USER
  4. Create and activate a Linux swapfile

    A swapfile provides virtual memory on the hard drive to extend available RAM, which is particularly useful for cloud-based virtual machines where dedicated swap partitions may not be available. To create a swapfile, you must be in super user mode (sudo su).
    # Show current swap spaces
    swapon --show
    
    # Allocate a 1G file
    dd if=/dev/zero of=/var/swapfile bs=1M count=1K
    
    # Set correct permissions and format as swap
    chmod 600 /var/swapfile
    mkswap /var/swapfile
    
    # Activate the swap immediately
    swapon /var/swapfile
    
    # Make the swap persistent across reboots
    echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab
  5. Configure HSRP for gateway redundancy

    Hot Standby Router Protocol (HSRP) provides a virtual IP address that serves as a default gateway for clients, ensuring redundancy if the primary router fails.

    Key configuration parameters include:

    • standby [group] ip [address]: Sets the virtual gateway IP.
    • standby [group] priority [value]: Determines which router becomes active (higher is preferred; default is 100).
    • standby [group] preempt: Allows a higher-priority router to take over the active role from a lower-priority router.
    • standby [group] track [interface]: Lowers the priority (typically by 10) if a specific interface goes down, triggering a failover.
    ! Primary Router (sw-1)
    int vlan1
      ip address 10.0.0.2 255.255.0.0
      standby 1 preempt
      standby 1 priority 105
      standby 1 ip 10.0.0.1
      standby 1 track gi1/1/1
    
    ! Standby Router (sw-2)
    int vlan1
      ip address 10.0.0.3 255.255.0.0
      standby 1 preempt
      standby 1 ip 10.0.0.1
  6. Configure Nginx as a reverse proxy for HTTP and WebSockets

    To pass all incoming traffic from an Nginx server to a backend service running on port 8080 (including support for WebSockets), use the following location block configuration. This setup ensures that the Host header is preserved and the connection is upgraded for WebSocket traffic.
    location / {
      proxy_pass http://localhost:8080;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
    }
  7. Navigate Cisco IOS configuration modes

    Cisco devices use different prompt symbols to indicate the current privilege level and configuration mode:

    • >: Unprivileged exec mode
    • #: Privileged exec mode (enable)
    • Global configuration mode: Used for most configuration changes. Enter this mode using the configure terminal command.

    Use the ? command to list available configuration options or subcommands (e.g., interface ?).

    enable
    configure terminal
    
    ! List configuration options
    ?
    
    ! List subcommands of an option
    interface ?
  8. Modify domains on an existing Certbot certificate

    To add or change domains for an existing certificate without requesting a brand new one, use the --cert-name flag. When prompted by Certbot, press e to expand the certificate or u to update it.
    certbot --nginx --cert-name $name -d example.com,www.example.com,newsubdomain.example.com
  9. Configure IP addressing on a Cisco Router

    Assign IPv4 and IPv6 addresses to physical router interfaces. You can configure interfaces individually or use the interface range command to apply settings to multiple ports simultaneously.
    interface gi0/0/0
      description No description here
      ip address 192.168.0.254 255.255.255.0
      ipv6 address 2001:db8:1234:aabb::1/64
      ipv6 address fe80::1 link-local
      no shutdown
    
    ! Using a range to configure multiple interfaces
    interface range gi0/0/0 - 1 , gi0/1/0
  10. Redistribute routes between OSPF and EIGRP

    Use the redistribute command to share routes learned from one routing protocol with another. This is essential when bridging different routing domains.
    router eigrp 100
      redistribute ospf 1
    
    router ospf 1
      redistribute eigrp 100 subnets
  11. Configure a Loopback interface for router redundancy

    Loopback interfaces are used to ensure a router remains reachable even if a physical interface goes down. A loopback interface stays active as long as the device is powered on and the interface is not administratively shut down, provided there is a valid route to it.
    interface loopback 0
      ip address 2.2.2.2 255.255.255.255
      no shutdown
  12. Secure a new MySQL installation

    Run the mysql_secure_installation script to secure the server. Recommended settings include removing anonymous users, removing the test database, and reloading privilege tables.
    mysql_secure_installation