247 |
247 |
#
|
248 |
248 |
# IP spoofing
|
249 |
249 |
# iptables -A one-3-0-o ! --source 10.0.0.1 -j DROP
|
250 |
|
def self.nic_pre(vm, nic)
|
|
250 |
def self.nic_pre(vm, nic, antiSpoofingOnly)
|
251 |
251 |
commands = VNMNetwork::Commands.new
|
252 |
252 |
|
253 |
253 |
vars = SGIPTables.vars(vm, nic)
|
... | ... | |
275 |
275 |
end
|
276 |
276 |
|
277 |
277 |
# Related, Established
|
278 |
|
commands.add :iptables, "-A #{chain_in} -m state --state ESTABLISHED,RELATED -j ACCEPT"
|
279 |
|
commands.add :iptables, "-A #{chain_out} -m state --state ESTABLISHED,RELATED -j ACCEPT"
|
|
278 |
if !antiSpoofingOnly
|
|
279 |
commands.add :iptables, "-A #{chain_in} -m state --state ESTABLISHED,RELATED -j ACCEPT"
|
|
280 |
commands.add :iptables, "-A #{chain_out} -m state --state ESTABLISHED,RELATED -j ACCEPT"
|
|
281 |
end
|
280 |
282 |
|
281 |
283 |
commands.run!
|
282 |
284 |
end
|
... | ... | |
284 |
286 |
# Sets the default policy to DROP for the NIC rules. Example
|
285 |
287 |
# iptables -A one-3-0-i -j DROP
|
286 |
288 |
# iptables -A one-3-0-o -j DROP
|
287 |
|
def self.nic_post(vm, nic)
|
|
289 |
def self.nic_post(vm, nic, antiSpoofingOnly)
|
288 |
290 |
vars = SGIPTables.vars(vm, nic)
|
289 |
291 |
chain_in = vars[:chain_in]
|
290 |
292 |
chain_out = vars[:chain_out]
|
291 |
293 |
|
292 |
294 |
commands = VNMNetwork::Commands.new
|
293 |
|
commands.add :iptables, "-A #{chain_in} -j DROP"
|
294 |
|
commands.add :iptables, "-A #{chain_out} -j DROP"
|
|
295 |
if !antiSpoofingOnly
|
|
296 |
commands.add :iptables, "-A #{chain_in} -j DROP"
|
|
297 |
commands.add :iptables, "-A #{chain_out} -j DROP"
|
|
298 |
end
|
295 |
299 |
|
296 |
300 |
commands.run!
|
297 |
301 |
end
|
... | ... | |
338 |
342 |
end
|
339 |
343 |
end
|
340 |
344 |
|
341 |
|
end
|
|
345 |
end
|