Skip to content

Instantly share code, notes, and snippets.

@soheilsec
Created February 9, 2024 09:02
Show Gist options
  • Select an option

  • Save soheilsec/a5ae319d596a72a0bfc7b353b7481764 to your computer and use it in GitHub Desktop.

Select an option

Save soheilsec/a5ae319d596a72a0bfc7b353b7481764 to your computer and use it in GitHub Desktop.
6to4 for Openvpn & cisco
Openvpn / cisco
#IRAN
#!/bin/bash
ip tunnel add 6to4tun_IR mode sit remote 65.21.4.49 local 185.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
# confige tunnele GRE6 ya IPIPv6 IR
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
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -I INPUT -p tcp --dport 2202 -j ACCEPT
iptables -I INPUT -p tcp --dport 528 -j ACCEPT
#openvpn
iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -j SNAT --to-source 172.16.1.1
#cisco
iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -j SNAT --to-source 172.16.1.1
#iptables -t nat -A PREROUTING -i ens160 -j DNAT --to-destination 172.16.1.2
iptables -t nat -A POSTROUTING -o GRE6Tun_IR -j MASQUERADE
iptables -A FORWARD -j ACCEPT
sudo sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward=1" > /etc/sysctl.conf
sysctl -p
#openvpn
sudo echo "200 iprange" >> /etc/iproute2/rt_tables
sudo ip rule add from 10.8.0.0/16 table iprange
sudo ip route add default via 172.16.1.2 dev GRE6Tun_IR table iprange
sudo iptables -t mangle -A PREROUTING -s 10.8.0.0/16 -j MARK --set-mark 200
#cisco
sudo echo "300 iprange" >> /etc/iproute2/rt_tables
sudo ip rule add from 192.168.0.0/16 table iprange
sudo ip route add default via 172.16.1.2 dev GRE6Tun_IR table iprange
sudo iptables -t mangle -A PREROUTING -s 192.168.0.0/16 -j MARK --set-mark 200
service iptables save
service iptables restart
service iptables stop
service iptables start
#kharej
#!/bin/bash
# confige tunnele 6to4 KH
ip tunnel add 6to4tun_KH mode sit remote 185.1.1.1 local 65.21.4.49
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
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -j ACCEPT
sudo sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward=1" > /etc/sysctl.conf
sysctl -p
service iptables save
service iptables restart
service iptables stop
service iptables start
@Tesla2550
Copy link
Copy Markdown

Does this have a link to your YouTube tutorial?

@soheilsec
Copy link
Copy Markdown
Author

soheilsec commented Dec 25, 2024 via email

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