Class: Dcmgr::VNet::Tasks::AcceptWakameDNSOnly

Inherits:
Dcmgr::VNet::Task show all
Includes:
Netfilter
Defined in:
lib/dcmgr/vnet/tasks/accept_wakame_dns_only.rb

Overview

Allows for DNS traffic to be exchanged with and only with Wakame’s DNS server

Instance Attribute Summary collapse

Attributes inherited from Dcmgr::VNet::Task

#rules

Instance Method Summary collapse

Constructor Details

#initialize(dns_server_ip, dns_server_port = "53") ⇒ AcceptWakameDNSOnly

Returns a new instance of AcceptWakameDNSOnly.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dcmgr/vnet/tasks/accept_wakame_dns_only.rb', line 14

def initialize(dns_server_ip,dns_server_port="53")
  super()
  
  @dns_server_ip = dns_server_ip
  @dns_server_port = dns_server_port
  
  # Allow DNS traffic to take place
  self.rules << IptablesRule.new(:filter,:forward,:udp,:outgoing,"-p udp -d #{self.dns_server_ip} --dport #{self.dns_server_port} -j ACCEPT")
  self.rules << IptablesRule.new(:filter,:forward,:udp,:incoming,"-p udp -d #{self.dns_server_ip} --dport #{self.dns_server_port} -j ACCEPT")
  
  # Disable any non DNS traffic to DNS server
  #[:udp,:tcp,:icmp].each { |protocol|
    #self.rules << IptablesRule.new(:filter,:forward,protocol,:outgoing,"-d #{self.dns_server_ip} -p #{protocol} -j DROP")
  #}
end

Instance Attribute Details

#dns_server_ipObject (readonly)

TODO: allow ARP traffic to DNS server



11
12
13
# File 'lib/dcmgr/vnet/tasks/accept_wakame_dns_only.rb', line 11

def dns_server_ip
  @dns_server_ip
end

#dns_server_portObject (readonly)

Returns the value of attribute dns_server_port.



12
13
14
# File 'lib/dcmgr/vnet/tasks/accept_wakame_dns_only.rb', line 12

def dns_server_port
  @dns_server_port
end