Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Skrypt pozwalający łatwo przy bootowaniu dodać adresy do routowania
- # pomiędzy internetem a OpenVPN
- #
- # Dodać do wykonia after boot!
- #
- # v1.0 Filipczyk.net
- #
- trybTestowy=0; #1 = test | 0 = dzialanie
- declare -a PubliczneIP=(
- "51.83.232.187" "51.83.232.188"
- )
- declare -a PrywatneIP=(
- "10.8.0.2" "10.8.0.3"
- )
- declare -a PortyDoPrzekierowania=(
- "21" "25" "53" "80" "110" "143" "443" "465" "587" "993" "995"
- )
- counter=0;
- for i in "${PubliczneIP[@]}"
- do
- for j in "${PortyDoPrzekierowania[@]}"
- do
- iptables -t nat -A PREROUTING -d ${PubliczneIP[counter]} -p tcp --dport $j -j DNAT --to-dest ${PrywatneIP[counter]}:$j
- iptables -t filter -A INPUT -p tcp -d ${PrywatneIP[counter]} --dport $j -j ACCEPT
- done
- # RDP 33891 to local 3389
- iptables -t nat -A PREROUTING -d ${PubliczneIP[counter]} -p tcp --dport 33891 -j DNAT --to-dest ${PrywatneIP[counter]}:3389
- iptables -t filter -A INPUT -p tcp -d ${PrywatneIP[counter]} --dport 33891 -j ACCEPT
- iptables -t nat -A PREROUTING -d ${PubliczneIP[counter]} -p udp --dport 33891 -j DNAT --to-dest ${PrywatneIP[counter]}:3389
- iptables -t filter -A INPUT -p udp -d ${PrywatneIP[counter]} --dport 33891 -j ACCEPT
- # SSH 22111 to local 22
- iptables -t nat -A PREROUTING -d ${PubliczneIP[counter]} -p tcp --dport 22111 -j DNAT --to-dest ${PrywatneIP[counter]}:22
- iptables -t filter -A INPUT -p tcp -d ${PrywatneIP[counter]} --dport 22111 -j ACCEPT
- iptables -t nat -A PREROUTING -d ${PubliczneIP[counter]} -p udp --dport 22111 -j DNAT --to-dest ${PrywatneIP[counter]}:22
- iptables -t filter -A INPUT -p udp -d ${PrywatneIP[counter]} --dport 22111 -j ACCEPT
- let "counter=counter+1"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement