Class: Dcmgr::VNet::Tasks::DropMacSpoofing

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

Overview

Disables instances from spoofing another mac address

Instance Attribute Summary collapse

Attributes inherited from Dcmgr::VNet::Task

#rules

Instance Method Summary collapse

Constructor Details

#initialize(mac, enable_logging, log_prefix) ⇒ DropMacSpoofing

Returns a new instance of DropMacSpoofing.



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

def initialize(mac,enable_logging,log_prefix)
super()
self.mac = mac
self.enable_logging = enable_logging
self.log_prefix = log_prefix

# Prevent spoofing to the outside world
self.rules << EbtablesRule.new(:filter,:forward,:arp,:outgoing,"--protocol arp --arp-mac-src ! #{self.mac} #{EbtablesRule.log_arp(self.log_prefix) if self.enable_logging} -j DROP")
# Prevent spoofing to the host
self.rules << EbtablesRule.new(:filter,:input,:arp,:outgoing,"--protocol arp --arp-mac-src ! #{self.mac} #{EbtablesRule.log_arp(self.log_prefix) if self.enable_logging} -j DROP")
# Prevent spoofing from the outside world
self.rules << EbtablesRule.new(:filter,:forward,:arp,:incoming,"--protocol arp --arp-mac-dst ! #{self.mac} #{EbtablesRule.log_arp(self.log_prefix) if self.enable_logging} -j DROP")
# Prevent spoofing from the host
self.rules << EbtablesRule.new(:filter,:output,:arp,:incoming,"--protocol arp --arp-mac-dst ! #{self.mac} #{EbtablesRule.log_arp(self.log_prefix) if self.enable_logging} -j DROP")
end

Instance Attribute Details

#enable_loggingObject

Returns the value of attribute enable_logging.



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

def enable_logging
  @enable_logging
end

#log_prefixObject

Returns the value of attribute log_prefix.



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

def log_prefix
  @log_prefix
end

#macObject

Returns the value of attribute mac.



10
11
12
# File 'lib/dcmgr/vnet/tasks/drop_mac_spoofing.rb', line 10

def mac
  @mac
end