Skip to content

Instantly share code, notes, and snippets.

@shivanshtalwar0
Last active January 12, 2025 10:21
Show Gist options
  • Save shivanshtalwar0/87d6c37c3fe9b95ff2d385085ade2032 to your computer and use it in GitHub Desktop.
Save shivanshtalwar0/87d6c37c3fe9b95ff2d385085ade2032 to your computer and use it in GitHub Desktop.
IpTables based port forwarding make sure to disable ufw or set rule to make it work

make pupeteer work on arm64 (raspberry pi or orangepi)

  1. Install deps
sudo apt install chromium-browser chromium-codecs-ffmpeg

and specify flags and path

const browser = await puppeteer.launch({
          headless: true,
          executablePath: '/usr/bin/chromium-browser',
          args: ['--no-sandbox', '--disable-setuid-sandbox']
  });

Emulate Display for pupeteer

in non headless mode you can Install xvfb

sudo apt install xvfb x11-apps x11-xkb-utils libx11-6 libx11-xcb1

Then run the following command

Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99

Enable port forwarding in linux

sysctl -w net.ipv4.ip_forward=1

Routing rules

iptables -t nat -A PREROUTING -p tcp --dport 3124 -j DNAT --to-destination 10.7.0.3:80
iptables -t nat -A POSTROUTING -j MASQUERADE

List all iptables nat

iptables -L -n -t nat

Flush nat changes

iptables -t nat -F && iptables -F

start up wireguard

sudo wg-quick up wg0

stop wireguard

sudo wg-quick down wg0

link wireguard for linux

sudo install -o root -g root -m 600 ~/Downloads/desktop.conf /etc/wireguard/wg0.conf

show wireguard status

sudo wg show

Add on System Startup

sudo systemctl enable [email protected]
sudo systemctl daemon-reload
sudo systemctl start wg-quick@wg0

in case openresolv not found

sudo apt install openresolv

Virtualbox local-remote host setup guide

  • create two adapters that is adapter1 with NAT and adapter 2 with host only network lets say vboxnet0 with ip range as (192.168.56.3/3) lower and upper respectively.

Now on guest machine perform following actions

  • copy yaml below to /etc/netplan/00-installer-config.yaml
network:
  ethernets:
    enp0s3:
      dhcp4: true
    enp0s7:
      addresses:
        - 192.168.57.1/24
      dhcp4: no
    enp0s8:
      addresses:
        - 192.168.56.1/24
      dhcp4: no
  version: 2

then finalize

sudo netplan try
sudo netplan generate
sudo netplan apply
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment