Archive for May, 2014

27
May

openvz - remote public ip

   Posted by: admin    in Mẹo vặt của hiếu râu

======= on public ip vps ===============================

#ip tunnel add gre1 mode gre local [public_ip] remote [openvz_ip]
#ifconfig gre1 192.168.1.1 pointopoint 192.168.1.2
#route add [local_ip] gw 192.168.1.2

*nat
:PREROUTING ACCEPT [25003:1664683]
:POSTROUTING ACCEPT [168001:10091407]
:OUTPUT ACCEPT [168000:10091367]
-A PREROUTING -d [public_ip] -p tcp -m tcp –dport 80 -j DNAT –to-destination [local_ip]:80
-A PREROUTING -d [public_ip] -p tcp -m tcp –dport 22 -j DNAT –to-destination [local_ip]:22
-A POSTROUTING -s [local_ip] ! -d [public_ip] -j SNAT –to-source [public_ip]
COMMIT

#echo 1 > /proc/sys/net/ipv4/ip_forward
========== ON OPENVZ =====================
#ip tunnel add gre1 mode gre remote [public_ip] local [openvz_ip]
#ifconfig gre1 192.168.1.2 pointopoint 192.168.1.1
echo “201   gre_1″ >> /etc/iproute2/rt_tables
# /sbin/ip rule add from [local_ip] table gre_1
# /sbin/ip route add throw [openvz_ip] table gre_1
# /sbin/ip route add default via 192.168.1.1 table gre_1