Class: Dcmgr::VNet::Tasks::ExcludeFromNat

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

Overview

Contains specific rules for ip addresses to which connections should not be natted.

Instance Attribute Summary collapse

Attributes inherited from Dcmgr::VNet::Task

#rules

Instance Method Summary collapse

Constructor Details

#initialize(ips, self_ip) ⇒ ExcludeFromNat

Returns a new instance of ExcludeFromNat.

Raises:

  • (ArgumentError)


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

def initialize(ips,self_ip)
  super()
  raise ArgumentError, "ips Must be an array containing IP addresses" unless ips.is_a? Array
  
  ips.each { |ip|
    if ip.is_a? String
      exclude = IPAddress(ip)
    elsif ip.is_a? IPAddress
      exclude = ip
    else
      next
    end
    
    #self.rules << IptablesRule.new(:nat,:prerouting,nil,:incoming,"-d #{self_ip} -s #{ip} -j ACCEPT")
    self.rules << IptablesRule.new(:nat,:postrouting,nil,:outgoing,"-d #{ip} -s #{self_ip} -j ACCEPT")
  }
end

Instance Attribute Details

#excluded_ipsObject

An array of the ip addresses excluded from nat



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

def excluded_ips
  @excluded_ips
end