Netgate SG-1000 microFirewall

Author Topic: DNS/Domain Based Routing  (Read 351 times)

0 Members and 1 Guest are viewing this topic.

Offline ccmks

  • Jr. Member
  • **
  • Posts: 42
  • Karma: +1/-0
    • View Profile
DNS/Domain Based Routing
« on: December 30, 2017, 03:38:54 am »
Hello,

I am currently have 2 different ISP which ISP1 is for regular use and ISP2 offers free youtube access unlimited and also for fail-over.


I would like to implement all youtube traffic will be going to ISP2 and rest of traffic will be going to ISP1 in order to take the advantage of the offer.

How can I implement that since youtube server are all over the place and there are too many of them which I don't even know which server/IP I am connected to. I was think if there is a way for PFSENSE to know if this is a youtube traffic by detecting the DNS or such then can implement policy based routing to ISP2.

Thank you so much!

Offline viragomann

  • Hero Member
  • *****
  • Posts: 2838
  • Karma: +312/-1
    • View Profile
Re: DNS/Domain Based Routing
« Reply #1 on: December 30, 2017, 06:34:52 am »
You may add an alias of type IP and add all youtube host names to it like "youtube.com", "www.youtube.com". Then use this alias in the firewall rule for policy routing.

Alternatively you can search for youtube IP addresses in the Web. You will find lists like this one: http://artica-proxy.com/youtube-tcpip-addresses-list
Copy the addresses into a text file, then import it into an alias.

Offline ccmks

  • Jr. Member
  • **
  • Posts: 42
  • Karma: +1/-0
    • View Profile
Re: DNS/Domain Based Routing
« Reply #2 on: January 01, 2018, 10:06:47 pm »
Thanks for the reply.

How can you add alias with wildcard? After analyzing youtube traffic, I realize that they have thousands subdomain under youtube.com as well as googlevideo.com. Each subdomains points to different IP. If I decide to create Alias then use the entire network CIDR to route, then it will affect the entire google service such as gmail, drive, and others.

What I really want to have route policy is just youtube server only.

For artica-proxy.com, the list of server is no longer valid.

Thank you

Offline forceps

  • Newbie
  • *
  • Posts: 5
  • Karma: +1/-0
    • View Profile
Re: DNS/Domain Based Routing
« Reply #3 on: January 08, 2018, 01:01:18 am »
There is an alternative way.

First, you need build a custom kernel to enable multiple routing table.

http://wiki.stocksy.co.uk/wiki/Multiple_default_routes_in_FreeBSD_without_BGP_or_similar


Then use DNS forwarder (dnsmasq), which provide a nice feature called ipset. It will add the resolved IPs from matching hostname to a pf table. You also need to manually edit /etc/inc/filter.inc, to add a custom pf rule, which force IPs listed in a pf table go through a route other than the default WAN.