Community discussions

MikroTik App
 
tjweber
just joined
Topic Author
Posts: 2
Joined: Fri Mar 08, 2013 3:51 pm

RouterOS China VPN --> Route all destination IP address

Fri Mar 08, 2013 4:14 pm

We have an apartment/design studio in Shenzhen, China, an office in Los Angeles and home in Chicago.

We have our Routerboards in China (China Telecom) our Los Angeles office (Time Warner) connected via PPTP to transfer extremely large files between the studio and the office. I also have a Routerboard in a Chicago home (AT&T / DSL) so I can watch real English TV and sometimes download a DVD from my collection -- which works great.

This is my problem. I now have this very good VPN provider that is stable with Extremely fast connections to the USA. I get great speeds for what I need to do (such as download files) and access certain web sites that China would otherwise block or slow down to crawling speeds, such as Gmail. (Gmail got so bad in China we gave up and used another provider).

I found a list on the internet of all IP blocks/ranges assigned to a specific country. See http://www.nirsoft.net/countryip/

I want to route ALL US/Canada IP addresses over the PPTP connection via the VPN. I can't seem to figure out how to route EVERYTHING destined to a particular public IP address range over the PPTP VPN connection. Ideally, I just route all traffic bound to the US over the PPTP VPN.

Any suggestions please let me know.
 
lambert
Long time Member
Long time Member
Posts: 548
Joined: Fri Jul 23, 2010 1:09 am

Re: RouterOS China VPN --> Route all destination IP address

Sat Mar 09, 2013 8:47 am

First, the format of the netblocks you get from that site are not nice for your application. You'll have better luck starting from a CIDR format list.

https://www.countryipblocks.net/

For a test I used the CIDR aggregation script and got a file with one netblock per line.

Then it would be need to be manipulated into a format which you can use to insert routes into the mikrotik.
How you do that depends on your scripting language of choice.

You want to output a line for each CIDR bock the ${ } is a variable notation I use a lot in sh scripting. Use whatever format works for your scripting language. It's probably possible to do it on the MikroTik itself. MikroTik scripting is help is in the MikroTik wiki. I spend all of my time on Unix boxes with sh available...
/ip route add dst-address=${cidr_block_from_the_list} gateway=${pptp-interface}
I put the addresses in a file called new_US_Allow.txt. I assumed your pptp interface is named pptp-usa.

In sh, it would be:
(echo '/ip route delete [find where comment="USA"]'; 
while read CIDR_NETBLOCK; do 
  echo "/ip route add dst-address=${CIDR_NETBLOCK} gateway=pptp-usa comment=USA"; 
done;) < new_US_Allow.txt > blahblah.rsc
You can upload the list in a blahblah.rsc file to the MikroTik and import it, or you can copy and paste it into an ssh session on the MikroTik.

The comment just helps you quickly delete all of the old entries, if you update the list. That's what the first line of the script does. It writes the command to delete every route with a comment of "USA" as the first line of the output file.
 
tjweber
just joined
Topic Author
Posts: 2
Joined: Fri Mar 08, 2013 3:51 pm

Re: RouterOS China VPN --> Route all destination IP address

Sat Mar 09, 2013 6:11 pm

This is extremely helpful information, thanks. Especially the CountryIPBlocks web site -- exactly what I needed in the format I need it in. It gave me another idea that I can redirect web traffic from specific countries -- as we have a problem with people copying our designs from China/Hong Kong/Taiwan and other Asian countries -- we can just deter them by redirecting them all away. :-D

Thanks again for the help.
 
Horva
just joined
Posts: 4
Joined: Sun Apr 23, 2017 7:11 pm

Re: RouterOS China VPN --> Route all destination IP address

Sun Apr 23, 2017 7:35 pm

Thank you very much for your input.

Could you as well show us the configuration regarding DNS, Routes, ...

Kind regards

Who is online

Users browsing this forum: No registered users and 39 guests