Skip to content

Instantly share code, notes, and snippets.

@soheilsec
Created February 9, 2024 09:01
Show Gist options
  • Save soheilsec/cb52302a300e561584ae66d3260594f3 to your computer and use it in GitHub Desktop.
Save soheilsec/cb52302a300e561584ae66d3260594f3 to your computer and use it in GitHub Desktop.
6to4 to multiple host
#!/bin/bash
#IRAN
# First 6to4 tunnel
ip tunnel add 6to4tun_IR mode sit remote 108.1.1.1 local 193.1.1.1
ip -6 addr add 2001:470:1f10:e1f::1/64 dev 6to4tun_IR
ip link set 6to4tun_IR mtu 1480
ip link set 6to4tun_IR up
# Second 6to4 tunnel
ip tunnel add 6to4tun_IR2 mode sit remote 199.1.1.1 local 193.1.1.1
ip -6 addr add 2001:470:1f10:e1f::3/64 dev 6to4tun_IR2
ip link set 6to4tun_IR2 mtu 1480
ip link set 6to4tun_IR2 up
# Configure GRE tunnel for each 6to4 tunnel
# First GRE tunnel
ip -6 tunnel add GRE6Tun_IR mode ip6gre remote 2001:470:1f10:e1f::2 local 2001:470:1f10:e1f::1
ip addr add 172.16.1.1/30 dev GRE6Tun_IR
ip link set GRE6Tun_IR mtu 1436
ip link set GRE6Tun_IR up
# Second GRE tunnel
ip -6 tunnel add GRE6Tun_IR2 mode ip6gre remote 2001:470:1f10:e1f::4 local 2001:470:1f10:e1f::3
ip addr add 172.16.2.1/30 dev GRE6Tun_IR2
ip link set GRE6Tun_IR2 mtu 1436
ip link set GRE6Tun_IR2 up
iptables -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp ! --dport 22 -j DNAT --to-destination 172.16.1.2
configuration in server 2:
#kharej1
#!/bin/bash
# confige tunnele 6to4 KH
ip tunnel add 6to4tun_KH mode sit remote 193.1.1.1 local 108.1.1.1
ip -6 addr add 2001:470:1f10:e1f::2/64 dev 6to4tun_KH
ip link set 6to4tun_KH mtu 1480
ip link set 6to4tun_KH up
# confige tunnele GRE6 KH using 6to4
ip -6 tunnel add GRE6Tun_KH mode ip6gre remote 2001:470:1f10:e1f::1 local 2001:470:1f10:e1f::2
ip addr add 172.16.1.2/30 dev GRE6Tun_KH
ip link set GRE6Tun_KH mtu 1436
ip link set GRE6Tun_KH up
configuration in server 3:
#kharej2
#!/bin/bash
# confige tunnele 6to4 KH
ip tunnel add 6to4tun_KH mode sit remote 193.1.1.1 local 199.247.5.108
ip -6 addr add 2001:470:1f10:e1f::4 dev 6to4tun_KH
ip link set 6to4tun_KH mtu 1480
ip link set 6to4tun_KH up
# confige tunnele GRE6 KH using 6to4
ip -6 tunnel add GRE6Tun_KH mode ip6gre remote 2001:470:1f10:e1f::3 local 2001:470:1f10:e1f::4
ip addr add 172.16.2.2/30 dev GRE6Tun_KH
ip link set GRE6Tun_KH mtu 1436
ip link set GRE6Tun_KH up
@Technomobile
Copy link

Technomobile commented May 25, 2024

سلام
تشکر بابت پست خوبتون
من این دستورات رو دقیق و 2 بار روی 2 سرور خارج به یک سرور ایران اجرا کردم اما سرور دوم خارج ارتباطش برقرار نمیشه و پینگ آی پی پرایویتی که بهش اختصاص میدم رو میگیرم با ارور From 172.16.2.2 icmp_seq=1 Destination Host Unreachable از سمت سرور خارج روبرو میشم وسرور ایران هیچ واکنشی به گرفتن پینگ نمیده و اروری هم نمیده

اما ارتباط با سرور اول دقیق و بدون مشکل اجرا میشه

ممنون میشم بررسی کنید و راه حل رو ارائه بدین

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment