parameters = [
  {
    'key' => 'net.ipv4.conf.all.accept_redirects',
    'value' => 0,
  },
  {
    'key' => 'net.ipv4.conf.default.accept_redirects',
    'value' => 0,
  },
  {
    'key' => 'net.ipv4.conf.all.arp_announce',
    'value' => 2,
  },
  {
    'key' => 'net.ipv4.conf.all.arp_ignore',
    'value' => 1,
  },
  {
    'key' => 'net.ipv4.conf.all.rp_filter',
    'value' => 1,
  },
  {
    'key' => 'net.ipv4.conf.default.accept_source_route',
    'value' => 0,
  },
  {
    'key' => 'net.ipv4.conf.default.rp_filter',
    'value' => 1,
  },
  {
    'key' => 'net.ipv4.tcp_rfc1337',
    'value' => 1,
  },
  {
    'key' => 'net.ipv4.icmp_ratemask',
    'value' => 88089,
  },
  {
    'key' => 'net.ipv4.tcp_timestamps',
    'value' => 0,
  },
  {
    'key' => 'kernel.sysrq',
    'value' => 0,
  },
  {
    'key' => 'net.ipv4.conf.all.secure_redirects',
    'value' => 0,
  },
  {
    'key' => 'net.ipv4.conf.default.secure_redirects',
    'value' => 0,
  },
  {
    'key' => 'net.ipv4.conf.all.log_martians',
    'value' => 1,
  },
  {
    'key' => 'net.ipv4.conf.default.log_martians',
    'value' => 1,
  },
  {
    'key' => 'net.ipv4.icmp_echo_ignore_broadcasts',
    'value' => 1,
  },
  {
    'key' => 'net.ipv4.icmp_ignore_bogus_error_responses',
    'value' => 1,
  },
  {
    'key' => 'net.ipv4.conf.all.send_redirects',
    'value' => 0,
  },
  {
    'key' => 'net.ipv4.conf.default.send_redirects',
    'value' => 0,
  },
  {
    'key' => 'net.ipv6.conf.all.accept_ra',
    'value' => 0,
  },
  {
    'key' => 'net.ipv6.conf.default.accept_ra',
    'value' => 0,
  },
  {
    'key' => 'net.ipv6.conf.all.accept_redirects',
    'value' => 0,
  },
  {
    'key' => 'net.ipv6.conf.default.accept_redirects',
    'value' => 0,
  },
  {
    'key' => 'fs.suid_dumpable',
    'value' => 0,
  },
]

file '/etc/sysctl.conf' do
  action :create_if_missing
end

parameters.each do |param|
  sysctl param['key'] do
    value param['value']
  end
end

sysctl 'net.ipv4.route.flush' do
  key 'net.ipv4.route.flush'
  value 1
end
