Skip to content

Instantly share code, notes, and snippets.

@Sid3y1
Created August 23, 2016 08:40
Show Gist options
  • Save Sid3y1/beeb309709031419bfd014e3b836f083 to your computer and use it in GitHub Desktop.
Save Sid3y1/beeb309709031419bfd014e3b836f083 to your computer and use it in GitHub Desktop.
Routing on proxmox
#!/bin/bash
/sbin/iptables -t nat --flush
iptables --flush
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o vmbr0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
/sbin/iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o vmbr0 -j SNAT --to PUBLIC_IP
#exit 1
while read line
do
serveur=` echo $line |cut -d: -f1`
ports=` echo $line |cut -d: -f2`
for port in $ports
do
from=` echo $port |cut -d/ -f1`
to=` echo $port |cut -d/ -f2`
echo "$serveur : $from -> $to"
/sbin/iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport $from -j DNAT --to 10.0.0.$serveur:$to
done
done < "/root/rules"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment