Skip to content

Instantly share code, notes, and snippets.

@Chachu1
Chachu1 / bash
Last active August 12, 2021 13:29
Iptables rules for port forwarding
#First Allow forwarding of port 80 to create a connection
sudo iptables -A FORWARD -i eth0 -o eth1 -p tcp --syn --dport 80 -m conntrack --ctstate NEW -j ACCEPT
#Second allow movement of traffic for established connections back and forth
iptables -A FORWARD -i eth0 -o eth1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
#Forward traffic comming on port 80 from eth0 to private server
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp -d 192.168.1.1 --dport 80 -j DNAT --to-destination 192.0.2.2:80
@Chachu1
Chachu1 / haproxy.cfg
Last active June 27, 2021 07:20 — forked from cmer/haproxy.cfg
Simple, no bullshit TCP port forwarding using HAProxy
listen https
bind 0.0.0.0:443
mode tcp
timeout connect 4000
timeout client 180000
timeout server 180000
server s1 host.example.com:443
@Chachu1
Chachu1 / dockerScript.sh
Last active May 4, 2021 20:50
Setting up server for Docker on New VM
#!/bin/bash
apt-get update
apt-get upgrade -y
# Set the TimeZone
timedatectl
timedatectl set-timezone Asia/Dubai
timedatectl
# Set the Hostname of the Machine