puppet-firewall模块
1.先睹为快
class my_fw::pre {
Firewall {
require => undef,
}
# Default firewall rules
firewall { '000 accept all icmp':
proto => 'icmp',
action => 'accept',
}->
firewall { '001 accept all to lo interface':
proto => 'all',
iniface => 'lo',
action => 'accept',
}->
firewall { '002 reject local traffic not on loopback interface':
iniface => '! lo',
proto => 'all',
destination => '127.0.0.1/8',
action => 'reject',
}->
firewall { '003 accept related established rules':
proto => 'all',
state => ['RELATED', 'ESTABLISHED'],
action => 'accept',
}
}
class my_fw::post {
firewall { '999 drop all':
proto => 'all',
action => 'drop',
before => undef,
}
}
class my_fw {
firewall { '004 Allow inbound SSH':
dport => 22,
proto => tcp,
action => accept,
provider => 'iptables',
}
firewall { '005 Allow inbound HTTP':
dport => 80,
proto => tcp,
action => accept,
provider => 'iptables',
}
}
Firewall {
before => Class['my_fw::post'],
require => Class['my_fw::pre'],
}
class { ['my_fw::pre', 'my_fw::post','my_fw']: }
class { 'firewall': }2.代码讲解
2.1 class firewall
class firewall2.2 type firewall
type firewall2.2.1 为apache开启80和443端口
2.2.2 丢弃FIN/RST/ACK包如果没有对应的SYN包
2.3 type firewallchain
type firewallchain3.扩展阅读
4.动手练习
Last updated