Traffic rules
Traffic proxy Rules (Hydra transport)
Its possible to configure how Hydra will operate with DNS and other traffic. To configure it, use addDnsRule
and addProxyRule
of SessionConfig.Builder
when starting a VPN session.
DNS
Whenever a DNS resolution takes place, it's intercepted by Hydra VPN and domain-based rules might be applied.
Domain-based rules affect how DNS resolution proceeds as well as how further connections to a particular domain will be routed.
Domains might be classified according to types below:
type
dns resolution
bypass
DNS request will proceed in bypass of Hydra VPN. DNS server is a system-wide one or the one specified in hydra configuration.
proxy
No dns resolution will take place on client-side. Real IP resolved on server-side is returned to application.
vpn
No dns resolution will take place on client-side. Real IP resolved on server-side is returned to application.
blockDns
No DNS resolution takes place. Connections to this domain never happen. By default 127.0.0.1 returned
These rules can be created and added to SessionConfig.Builder#addDnsRule
with the following methods.
TrafficRule.Builder.bypass
TrafficRule.Builder.proxy
TrafficRule.Builder.blockDns
TrafficRule.Builder.vpn
Data sources
fromAssets - read list of domains stored in application assets
fromFile - read list of domains from file
fromDomains - direct pass list of domains
fromResource - read list of domains from application resources
Domain matching algorithm:
Domains are searched using longest prefix matching approach, meaning that the most specific match has the highest priority.
Wildcard "*" might be used to match any character occurring any number of times.
Character "?" might be used to match any character occurring one time.
key
entries
match
www.google.com
www.google.com
www.yahoo.com
www.google.com
www.google.com
www.*.com
www.goog*.com
www.google.com
www.google.com
www.google.com
*.google.com
*.com
*.google.com
If no match for a domain is found default domain rule is applied.
Other
Whenever traffic other than DNS reaches Hydra VPN, domain-based rules are the first ones to be considered in order to route content through a correct data path.
In case no domain rule was associated to this IP (e.g. application is using directly IP, no DNS resolution took place previously) or domain default rule was applied to respective domain (no particular match for this domain was found by the time of dns resolution) generic rules are applied. This might be interpreted as domain based rules always taking precedence over generic rules unless they were not applied or default domain rule was applied.
Generic rules are based on any combination of destination IP, destination port and protocol.
These rules can be created and added to SessionConfig.Builder#addProxyRule
with the following methods:
TrafficRule.Builder.bypass
TrafficRule.Builder.proxy
TrafficRule.Builder.blockPkt
TrafficRule.Builder.vpn
Data sources:
fromIp
udp
tcp
tcpFromIp
udpFromIp
any
Valid combinations for searching. (port or/and protocol)
1
X
bypass().any(0) bypass().any(1, 1024)
2
X
bypass().udp(0)
3
X
X
bypass().tcp(23)
bypass().tcp(20,30)
Valid combinations for searching. (IP longest prefix match)
4
X
bypass().fromIp("100.96.0.0",12)
5
X
X
vpn().fromIp("100.64.0.0",10,22)
bypass().fromIp("100.64.0.0",10, 25, 30)
6
X
X
bypass().udpFromIp("100.100.0.0",16)
7
X
X
X
proxy().tcpFromIp("100.100.0.0", 16, 23)
proxy().tcpFromIp("100.100.0.0", 16, 23, 40)
Port Ranges
Port ranges might be specified wherever port is allowed
Just one port range per rule is allowed, but multiple ranges for same combination of ip, proto and type might be considered by adding multiple rules (one per port range):
Using one rule for each range since port ranges don't overlap:
Port range which overlaps existing port range for same combination of ip and proto will NOT be added:
Method of Blocking
blockPkt for TCP: send RST message when SYN packet is first seen
blockPkt for UDP: send ICMP message HOST UNREACHABLE->PORT UNREACHABLE when udp packet is first seen
blockPkt for Non-TCP/UDP: Drop packet
Examples
To bypass local network traffic and make local network resource accessible, you can configure an IP mask rule:
Last updated
Was this helpful?