PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/firewall/spec/fixtures/iptables/conversion_hash.rb

https://github.com/RichardKnop/puppet
Ruby | 817 lines | 807 code | 3 blank | 7 comment | 0 complexity | 012d92a358cc0c74304de14657bf9a23 MD5 | raw file
Possible License(s): Apache-2.0
  1. # These hashes allow us to iterate across a series of test data
  2. # creating rspec examples for each parameter to ensure the input :line
  3. # extrapolates to the desired value for the parameter in question. And
  4. # vice-versa
  5. # This hash is for testing a line conversion to a hash of parameters
  6. # which will be used to create a resource.
  7. ARGS_TO_HASH = {
  8. 'long_rule_1' => {
  9. :line => '-A INPUT -s 1.1.1.1/32 -d 1.1.1.1/32 -p tcp -m multiport --dports 7061,7062 -m multiport --sports 7061,7062 -m comment --comment "000 allow foo" -j ACCEPT',
  10. :table => 'filter',
  11. :compare_all => true,
  12. :params => {
  13. :action => "accept",
  14. :chain => "INPUT",
  15. :destination => "1.1.1.1/32",
  16. :dport => ["7061","7062"],
  17. :ensure => :present,
  18. :line => '-A INPUT -s 1.1.1.1/32 -d 1.1.1.1/32 -p tcp -m multiport --dports 7061,7062 -m multiport --sports 7061,7062 -m comment --comment "000 allow foo" -j ACCEPT',
  19. :name => "000 allow foo",
  20. :proto => "tcp",
  21. :provider => "iptables",
  22. :source => "1.1.1.1/32",
  23. :sport => ["7061","7062"],
  24. :table => "filter",
  25. },
  26. },
  27. 'action_drop_1' => {
  28. :line => '-A INPUT -m comment --comment "000 allow foo" -j DROP',
  29. :table => 'filter',
  30. :params => {
  31. :jump => nil,
  32. :action => "drop",
  33. },
  34. },
  35. 'action_reject_1' => {
  36. :line => '-A INPUT -m comment --comment "000 allow foo" -j REJECT',
  37. :table => 'filter',
  38. :params => {
  39. :jump => nil,
  40. :action => "reject",
  41. },
  42. },
  43. 'action_nil_1' => {
  44. :line => '-A INPUT -m comment --comment "000 allow foo"',
  45. :table => 'filter',
  46. :params => {
  47. :jump => nil,
  48. :action => nil,
  49. },
  50. },
  51. 'jump_custom_chain_1' => {
  52. :line => '-A INPUT -m comment --comment "000 allow foo" -j custom_chain',
  53. :table => 'filter',
  54. :params => {
  55. :jump => "custom_chain",
  56. :action => nil,
  57. },
  58. },
  59. 'source_destination_ipv4_no_cidr' => {
  60. :line => '-A INPUT -s 1.1.1.1 -d 2.2.2.2 -m comment --comment "000 source destination ipv4 no cidr"',
  61. :table => 'filter',
  62. :params => {
  63. :source => '1.1.1.1/32',
  64. :destination => '2.2.2.2/32',
  65. },
  66. },
  67. 'source_destination_ipv6_no_cidr' => {
  68. :line => '-A INPUT -s 2001:db8:85a3::8a2e:370:7334 -d 2001:db8:85a3::8a2e:370:7334 -m comment --comment "000 source destination ipv6 no cidr"',
  69. :table => 'filter',
  70. :params => {
  71. :source => '2001:db8:85a3::8a2e:370:7334/128',
  72. :destination => '2001:db8:85a3::8a2e:370:7334/128',
  73. },
  74. },
  75. 'source_destination_ipv4_netmask' => {
  76. :line => '-A INPUT -s 1.1.1.0/255.255.255.0 -d 2.2.0.0/255.255.0.0 -m comment --comment "000 source destination ipv4 netmask"',
  77. :table => 'filter',
  78. :params => {
  79. :source => '1.1.1.0/24',
  80. :destination => '2.2.0.0/16',
  81. },
  82. },
  83. 'source_destination_ipv6_netmask' => {
  84. :line => '-A INPUT -s 2001:db8:1234::/ffff:ffff:ffff:0000:0000:0000:0000:0000 -d 2001:db8:4321::/ffff:ffff:ffff:0000:0000:0000:0000:0000 -m comment --comment "000 source destination ipv6 netmask"',
  85. :table => 'filter',
  86. :params => {
  87. :source => '2001:db8:1234::/48',
  88. :destination => '2001:db8:4321::/48',
  89. },
  90. },
  91. 'dport_range_1' => {
  92. :line => '-A INPUT -m multiport --dports 1:1024 -m comment --comment "000 allow foo"',
  93. :table => 'filter',
  94. :params => {
  95. :dport => ["1-1024"],
  96. },
  97. },
  98. 'dport_range_2' => {
  99. :line => '-A INPUT -m multiport --dports 15,512:1024 -m comment --comment "000 allow foo"',
  100. :table => 'filter',
  101. :params => {
  102. :dport => ["15","512-1024"],
  103. },
  104. },
  105. 'sport_range_1' => {
  106. :line => '-A INPUT -m multiport --sports 1:1024 -m comment --comment "000 allow foo"',
  107. :table => 'filter',
  108. :params => {
  109. :sport => ["1-1024"],
  110. },
  111. },
  112. 'sport_range_2' => {
  113. :line => '-A INPUT -m multiport --sports 15,512:1024 -m comment --comment "000 allow foo"',
  114. :table => 'filter',
  115. :params => {
  116. :sport => ["15","512-1024"],
  117. },
  118. },
  119. 'dst_type_1' => {
  120. :line => '-A INPUT -m addrtype --dst-type LOCAL',
  121. :table => 'filter',
  122. :params => {
  123. :dst_type => 'LOCAL',
  124. },
  125. },
  126. 'src_type_1' => {
  127. :line => '-A INPUT -m addrtype --src-type LOCAL',
  128. :table => 'filter',
  129. :params => {
  130. :src_type => 'LOCAL',
  131. },
  132. },
  133. 'dst_range_1' => {
  134. :line => '-A INPUT -m iprange --dst-range 10.0.0.2-10.0.0.20',
  135. :table => 'filter',
  136. :params => {
  137. :dst_range => '10.0.0.2-10.0.0.20',
  138. },
  139. },
  140. 'src_range_1' => {
  141. :line => '-A INPUT -m iprange --src-range 10.0.0.2-10.0.0.20',
  142. :table => 'filter',
  143. :params => {
  144. :src_range => '10.0.0.2-10.0.0.20',
  145. },
  146. },
  147. 'tcp_flags_1' => {
  148. :line => '-A INPUT -p tcp -m tcp --tcp-flags SYN,RST,ACK,FIN SYN -m comment --comment "000 initiation"',
  149. :table => 'filter',
  150. :compare_all => true,
  151. :chain => 'INPUT',
  152. :proto => 'tcp',
  153. :params => {
  154. :chain => "INPUT",
  155. :ensure => :present,
  156. :line => '-A INPUT -p tcp -m tcp --tcp-flags SYN,RST,ACK,FIN SYN -m comment --comment "000 initiation"',
  157. :name => "000 initiation",
  158. :proto => "tcp",
  159. :provider => "iptables",
  160. :table => "filter",
  161. :tcp_flags => "SYN,RST,ACK,FIN SYN",
  162. },
  163. },
  164. 'state_returns_sorted_values' => {
  165. :line => '-A INPUT -m state --state INVALID,RELATED,ESTABLISHED',
  166. :table => 'filter',
  167. :params => {
  168. :state => ['ESTABLISHED', 'INVALID', 'RELATED'],
  169. :action => nil,
  170. },
  171. },
  172. 'comment_string_character_validation' => {
  173. :line => '-A INPUT -s 192.168.0.1/32 -m comment --comment "000 allow from 192.168.0.1, please"',
  174. :table => 'filter',
  175. :params => {
  176. :source => '192.168.0.1/32',
  177. },
  178. },
  179. 'log_level_debug' => {
  180. :line => '-A INPUT -m comment --comment "956 INPUT log-level" -m state --state NEW -j LOG --log-level 7',
  181. :table => 'filter',
  182. :params => {
  183. :state => ['NEW'],
  184. :log_level => '7',
  185. :jump => 'LOG'
  186. },
  187. },
  188. 'log_level_warn' => {
  189. :line => '-A INPUT -m comment --comment "956 INPUT log-level" -m state --state NEW -j LOG',
  190. :table => 'filter',
  191. :params => {
  192. :state => ['NEW'],
  193. :log_level => '4',
  194. :jump => 'LOG'
  195. },
  196. },
  197. 'load_limit_module_and_implicit_burst' => {
  198. :line => '-A INPUT -m multiport --dports 123 -m comment --comment "057 INPUT limit NTP" -m limit --limit 15/hour',
  199. :table => 'filter',
  200. :params => {
  201. :dport => ['123'],
  202. :limit => '15/hour',
  203. :burst => '5'
  204. },
  205. },
  206. 'limit_with_explicit_burst' => {
  207. :line => '-A INPUT -m multiport --dports 123 -m comment --comment "057 INPUT limit NTP" -m limit --limit 30/hour --limit-burst 10',
  208. :table => 'filter',
  209. :params => {
  210. :dport => ['123'],
  211. :limit => '30/hour',
  212. :burst => '10'
  213. },
  214. },
  215. 'proto_ipencap' => {
  216. :line => '-A INPUT -p ipencap -m comment --comment "0100 INPUT accept ipencap"',
  217. :table => 'filter',
  218. :params => {
  219. :proto => 'ipencap',
  220. }
  221. },
  222. 'load_uid_owner_filter_module' => {
  223. :line => '-A OUTPUT -m owner --uid-owner root -m comment --comment "057 OUTPUT uid root only" -j ACCEPT',
  224. :table => 'filter',
  225. :params => {
  226. :action => 'accept',
  227. :uid => 'root',
  228. :chain => 'OUTPUT',
  229. },
  230. },
  231. 'load_uid_owner_postrouting_module' => {
  232. :line => '-t mangle -A POSTROUTING -m owner --uid-owner root -m comment --comment "057 POSTROUTING uid root only" -j ACCEPT',
  233. :table => 'mangle',
  234. :params => {
  235. :action => 'accept',
  236. :chain => 'POSTROUTING',
  237. :uid => 'root',
  238. },
  239. },
  240. 'load_gid_owner_filter_module' => {
  241. :line => '-A OUTPUT -m owner --gid-owner root -m comment --comment "057 OUTPUT gid root only" -j ACCEPT',
  242. :table => 'filter',
  243. :params => {
  244. :action => 'accept',
  245. :chain => 'OUTPUT',
  246. :gid => 'root',
  247. },
  248. },
  249. 'load_gid_owner_postrouting_module' => {
  250. :line => '-t mangle -A POSTROUTING -m owner --gid-owner root -m comment --comment "057 POSTROUTING gid root only" -j ACCEPT',
  251. :table => 'mangle',
  252. :params => {
  253. :action => 'accept',
  254. :chain => 'POSTROUTING',
  255. :gid => 'root',
  256. },
  257. },
  258. 'mark_set-mark' => {
  259. :line => '-t mangle -A PREROUTING -j MARK --set-xmark 0x3e8/0xffffffff',
  260. :table => 'mangle',
  261. :params => {
  262. :jump => 'MARK',
  263. :chain => 'PREROUTING',
  264. :set_mark => '0x3e8/0xffffffff',
  265. }
  266. },
  267. 'iniface_1' => {
  268. :line => '-A INPUT -i eth0 -m comment --comment "060 iniface" -j DROP',
  269. :table => 'filter',
  270. :params => {
  271. :action => 'drop',
  272. :chain => 'INPUT',
  273. :iniface => 'eth0',
  274. },
  275. },
  276. 'iniface_with_vlans_1' => {
  277. :line => '-A INPUT -i eth0.234 -m comment --comment "060 iniface" -j DROP',
  278. :table => 'filter',
  279. :params => {
  280. :action => 'drop',
  281. :chain => 'INPUT',
  282. :iniface => 'eth0.234',
  283. },
  284. },
  285. 'iniface_with_plus_1' => {
  286. :line => '-A INPUT -i eth+ -m comment --comment "060 iniface" -j DROP',
  287. :table => 'filter',
  288. :params => {
  289. :action => 'drop',
  290. :chain => 'INPUT',
  291. :iniface => 'eth+',
  292. },
  293. },
  294. 'outiface_1' => {
  295. :line => '-A OUTPUT -o eth0 -m comment --comment "060 outiface" -j DROP',
  296. :table => 'filter',
  297. :params => {
  298. :action => 'drop',
  299. :chain => 'OUTPUT',
  300. :outiface => 'eth0',
  301. },
  302. },
  303. 'outiface_with_vlans_1' => {
  304. :line => '-A OUTPUT -o eth0.234 -m comment --comment "060 outiface" -j DROP',
  305. :table => 'filter',
  306. :params => {
  307. :action => 'drop',
  308. :chain => 'OUTPUT',
  309. :outiface => 'eth0.234',
  310. },
  311. },
  312. 'outiface_with_plus_1' => {
  313. :line => '-A OUTPUT -o eth+ -m comment --comment "060 outiface" -j DROP',
  314. :table => 'filter',
  315. :params => {
  316. :action => 'drop',
  317. :chain => 'OUTPUT',
  318. :outiface => 'eth+',
  319. },
  320. },
  321. 'pkttype multicast' => {
  322. :line => '-A INPUT -m pkttype --pkt-type multicast -j ACCEPT',
  323. :table => 'filter',
  324. :params => {
  325. :action => 'accept',
  326. :pkttype => 'multicast',
  327. },
  328. },
  329. 'socket_option' => {
  330. :line => '-A PREROUTING -m socket -j ACCEPT',
  331. :table => 'mangle',
  332. :params => {
  333. :action => 'accept',
  334. :chain => 'PREROUTING',
  335. :socket => true,
  336. },
  337. },
  338. 'isfragment_option' => {
  339. :line => '-A INPUT -f -m comment --comment "010 a-f comment with dashf" -j ACCEPT',
  340. :table => 'filter',
  341. :params => {
  342. :name => '010 a-f comment with dashf',
  343. :action => 'accept',
  344. :isfragment => true,
  345. },
  346. },
  347. 'single_tcp_sport' => {
  348. :line => '-A OUTPUT -s 10.94.100.46/32 -p tcp -m tcp --sport 20443 -j ACCEPT',
  349. :table => 'mangle',
  350. :params => {
  351. :action => 'accept',
  352. :chain => 'OUTPUT',
  353. :source => "10.94.100.46/32",
  354. :proto => "tcp",
  355. :sport => ["20443"],
  356. },
  357. },
  358. 'single_udp_sport' => {
  359. :line => '-A OUTPUT -s 10.94.100.46/32 -p udp -m udp --sport 20443 -j ACCEPT',
  360. :table => 'mangle',
  361. :params => {
  362. :action => 'accept',
  363. :chain => 'OUTPUT',
  364. :source => "10.94.100.46/32",
  365. :proto => "udp",
  366. :sport => ["20443"],
  367. },
  368. },
  369. 'single_tcp_dport' => {
  370. :line => '-A OUTPUT -s 10.94.100.46/32 -p tcp -m tcp --dport 20443 -j ACCEPT',
  371. :table => 'mangle',
  372. :params => {
  373. :action => 'accept',
  374. :chain => 'OUTPUT',
  375. :source => "10.94.100.46/32",
  376. :proto => "tcp",
  377. :dport => ["20443"],
  378. },
  379. },
  380. 'single_udp_dport' => {
  381. :line => '-A OUTPUT -s 10.94.100.46/32 -p udp -m udp --dport 20443 -j ACCEPT',
  382. :table => 'mangle',
  383. :params => {
  384. :action => 'accept',
  385. :chain => 'OUTPUT',
  386. :source => "10.94.100.46/32",
  387. :proto => "udp",
  388. :dport => ["20443"],
  389. },
  390. },
  391. }
  392. # This hash is for testing converting a hash to an argument line.
  393. HASH_TO_ARGS = {
  394. 'long_rule_1' => {
  395. :params => {
  396. :action => "accept",
  397. :chain => "INPUT",
  398. :destination => "1.1.1.1",
  399. :dport => ["7061","7062"],
  400. :ensure => :present,
  401. :name => "000 allow foo",
  402. :proto => "tcp",
  403. :source => "1.1.1.1",
  404. :sport => ["7061","7062"],
  405. :table => "filter",
  406. },
  407. :args => ["-t", :filter, "-s", "1.1.1.1/32", "-d", "1.1.1.1/32", "-p", :tcp, "-m", "multiport", "--sports", "7061,7062", "-m", "multiport", "--dports", "7061,7062", "-m", "comment", "--comment", "000 allow foo", "-j", "ACCEPT"],
  408. },
  409. 'long_rule_2' => {
  410. :params => {
  411. :chain => "INPUT",
  412. :destination => "2.10.13.3/24",
  413. :dport => ["7061"],
  414. :ensure => :present,
  415. :jump => "my_custom_chain",
  416. :name => "700 allow bar",
  417. :proto => "udp",
  418. :source => "1.1.1.1",
  419. :sport => ["7061","7062"],
  420. :table => "filter",
  421. },
  422. :args => ["-t", :filter, "-s", "1.1.1.1/32", "-d", "2.10.13.0/24", "-p", :udp, "-m", "multiport", "--sports", "7061,7062", "-m", "multiport", "--dports", "7061", "-m", "comment", "--comment", "700 allow bar", "-j", "my_custom_chain"],
  423. },
  424. 'no_action' => {
  425. :params => {
  426. :name => "100 no action",
  427. :table => "filter",
  428. },
  429. :args => ["-t", :filter, "-p", :tcp, "-m", "comment", "--comment",
  430. "100 no action"],
  431. },
  432. 'zero_prefixlen_ipv4' => {
  433. :params => {
  434. :name => '100 zero prefix length ipv4',
  435. :table => 'filter',
  436. :source => '0.0.0.0/0',
  437. :destination => '0.0.0.0/0',
  438. },
  439. :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '100 zero prefix length ipv4'],
  440. },
  441. 'zero_prefixlen_ipv6' => {
  442. :params => {
  443. :name => '100 zero prefix length ipv6',
  444. :table => 'filter',
  445. :source => '::/0',
  446. :destination => '::/0',
  447. },
  448. :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '100 zero prefix length ipv6'],
  449. },
  450. 'source_destination_ipv4_no_cidr' => {
  451. :params => {
  452. :name => '000 source destination ipv4 no cidr',
  453. :table => 'filter',
  454. :source => '1.1.1.1',
  455. :destination => '2.2.2.2',
  456. },
  457. :args => ['-t', :filter, '-s', '1.1.1.1/32', '-d', '2.2.2.2/32', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv4 no cidr'],
  458. },
  459. 'source_destination_ipv6_no_cidr' => {
  460. :params => {
  461. :name => '000 source destination ipv6 no cidr',
  462. :table => 'filter',
  463. :source => '2001:db8:1234::',
  464. :destination => '2001:db8:4321::',
  465. },
  466. :args => ['-t', :filter, '-s', '2001:db8:1234::/128', '-d', '2001:db8:4321::/128', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv6 no cidr'],
  467. },
  468. 'source_destination_ipv4_netmask' => {
  469. :params => {
  470. :name => '000 source destination ipv4 netmask',
  471. :table => 'filter',
  472. :source => '1.1.1.0/255.255.255.0',
  473. :destination => '2.2.0.0/255.255.0.0',
  474. },
  475. :args => ['-t', :filter, '-s', '1.1.1.0/24', '-d', '2.2.0.0/16', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv4 netmask'],
  476. },
  477. 'source_destination_ipv6_netmask' => {
  478. :params => {
  479. :name => '000 source destination ipv6 netmask',
  480. :table => 'filter',
  481. :source => '2001:db8:1234::/ffff:ffff:ffff:0000:0000:0000:0000:0000',
  482. :destination => '2001:db8:4321::/ffff:ffff:ffff:0000:0000:0000:0000:0000',
  483. },
  484. :args => ['-t', :filter, '-s', '2001:db8:1234::/48', '-d', '2001:db8:4321::/48', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv6 netmask'],
  485. },
  486. 'sport_range_1' => {
  487. :params => {
  488. :name => "100 sport range",
  489. :sport => ["1-1024"],
  490. :table => "filter",
  491. },
  492. :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--sports", "1:1024", "-m", "comment", "--comment", "100 sport range"],
  493. },
  494. 'sport_range_2' => {
  495. :params => {
  496. :name => "100 sport range",
  497. :sport => ["15","512-1024"],
  498. :table => "filter",
  499. },
  500. :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--sports", "15,512:1024", "-m", "comment", "--comment", "100 sport range"],
  501. },
  502. 'dport_range_1' => {
  503. :params => {
  504. :name => "100 sport range",
  505. :dport => ["1-1024"],
  506. :table => "filter",
  507. },
  508. :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--dports", "1:1024", "-m", "comment", "--comment", "100 sport range"],
  509. },
  510. 'dport_range_2' => {
  511. :params => {
  512. :name => "100 sport range",
  513. :dport => ["15","512-1024"],
  514. :table => "filter",
  515. },
  516. :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--dports", "15,512:1024", "-m", "comment", "--comment", "100 sport range"],
  517. },
  518. 'dst_type_1' => {
  519. :params => {
  520. :name => '000 dst_type',
  521. :table => 'filter',
  522. :dst_type => 'LOCAL',
  523. },
  524. :args => ['-t', :filter, '-p', :tcp, '-m', 'addrtype', '--dst-type', :LOCAL, '-m', 'comment', '--comment', '000 dst_type'],
  525. },
  526. 'src_type_1' => {
  527. :params => {
  528. :name => '000 src_type',
  529. :table => 'filter',
  530. :src_type => 'LOCAL',
  531. },
  532. :args => ['-t', :filter, '-p', :tcp, '-m', 'addrtype', '--src-type', :LOCAL, '-m', 'comment', '--comment', '000 src_type'],
  533. },
  534. 'dst_range_1' => {
  535. :params => {
  536. :name => '000 dst_range',
  537. :table => 'filter',
  538. :dst_range => '10.0.0.1-10.0.0.10',
  539. },
  540. :args => ['-t', :filter, '-m', 'iprange', '--dst-range', '10.0.0.1-10.0.0.10', '-p', :tcp, '-m', 'comment', '--comment', '000 dst_range'],
  541. },
  542. 'src_range_1' => {
  543. :params => {
  544. :name => '000 src_range',
  545. :table => 'filter',
  546. :dst_range => '10.0.0.1-10.0.0.10',
  547. },
  548. :args => ['-t', :filter, '-m', 'iprange', '--dst-range', '10.0.0.1-10.0.0.10', '-p', :tcp, '-m', 'comment', '--comment', '000 src_range'],
  549. },
  550. 'tcp_flags_1' => {
  551. :params => {
  552. :name => "000 initiation",
  553. :tcp_flags => "SYN,RST,ACK,FIN SYN",
  554. :table => "filter",
  555. },
  556. :args => ["-t", :filter, "-p", :tcp, "-m", "tcp", "--tcp-flags", "SYN,RST,ACK,FIN", "SYN", "-m", "comment", "--comment", "000 initiation",]
  557. },
  558. 'states_set_from_array' => {
  559. :params => {
  560. :name => "100 states_set_from_array",
  561. :table => "filter",
  562. :state => ['ESTABLISHED', 'INVALID']
  563. },
  564. :args => ["-t", :filter, "-p", :tcp, "-m", "comment", "--comment", "100 states_set_from_array",
  565. "-m", "state", "--state", "ESTABLISHED,INVALID"],
  566. },
  567. 'comment_string_character_validation' => {
  568. :params => {
  569. :name => "000 allow from 192.168.0.1, please",
  570. :table => 'filter',
  571. :source => '192.168.0.1'
  572. },
  573. :args => ['-t', :filter, '-s', '192.168.0.1/32', '-p', :tcp, '-m', 'comment', '--comment', '000 allow from 192.168.0.1, please'],
  574. },
  575. 'port_property' => {
  576. :params => {
  577. :name => '001 port property',
  578. :table => 'filter',
  579. :port => '80',
  580. },
  581. :args => ['-t', :filter, '-p', :tcp, '-m', 'multiport', '--ports', '80', '-m', 'comment', '--comment', '001 port property'],
  582. },
  583. 'log_level_debug' => {
  584. :params => {
  585. :name => '956 INPUT log-level',
  586. :table => 'filter',
  587. :state => 'NEW',
  588. :jump => 'LOG',
  589. :log_level => 'debug'
  590. },
  591. :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '956 INPUT log-level', '-m', 'state', '--state', 'NEW', '-j', 'LOG', '--log-level', '7'],
  592. },
  593. 'log_level_warn' => {
  594. :params => {
  595. :name => '956 INPUT log-level',
  596. :table => 'filter',
  597. :state => 'NEW',
  598. :jump => 'LOG',
  599. :log_level => 'warn'
  600. },
  601. :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '956 INPUT log-level', '-m', 'state', '--state', 'NEW', '-j', 'LOG', '--log-level', '4'],
  602. },
  603. 'load_limit_module_and_implicit_burst' => {
  604. :params => {
  605. :name => '057 INPUT limit NTP',
  606. :table => 'filter',
  607. :dport => '123',
  608. :limit => '15/hour'
  609. },
  610. :args => ['-t', :filter, '-p', :tcp, '-m', 'multiport', '--dports', '123', '-m', 'comment', '--comment', '057 INPUT limit NTP', '-m', 'limit', '--limit', '15/hour'],
  611. },
  612. 'limit_with_explicit_burst' => {
  613. :params => {
  614. :name => '057 INPUT limit NTP',
  615. :table => 'filter',
  616. :dport => '123',
  617. :limit => '30/hour',
  618. :burst => '10'
  619. },
  620. :args => ['-t', :filter, '-p', :tcp, '-m', 'multiport', '--dports', '123', '-m', 'comment', '--comment', '057 INPUT limit NTP', '-m', 'limit', '--limit', '30/hour', '--limit-burst', '10'],
  621. },
  622. 'proto_ipencap' => {
  623. :params => {
  624. :name => '0100 INPUT accept ipencap',
  625. :table => 'filter',
  626. :proto => 'ipencap',
  627. },
  628. :args => ['-t', :filter, '-p', :ipencap, '-m', 'comment', '--comment', '0100 INPUT accept ipencap'],
  629. },
  630. 'load_uid_owner_filter_module' => {
  631. :params => {
  632. :name => '057 OUTPUT uid root only',
  633. :table => 'filter',
  634. :uid => 'root',
  635. :action => 'accept',
  636. :chain => 'OUTPUT',
  637. :proto => 'all',
  638. },
  639. :args => ['-t', :filter, '-p', :all, '-m', 'owner', '--uid-owner', 'root', '-m', 'comment', '--comment', '057 OUTPUT uid root only', '-j', 'ACCEPT'],
  640. },
  641. 'load_uid_owner_postrouting_module' => {
  642. :params => {
  643. :name => '057 POSTROUTING uid root only',
  644. :table => 'mangle',
  645. :uid => 'root',
  646. :action => 'accept',
  647. :chain => 'POSTROUTING',
  648. :proto => 'all',
  649. },
  650. :args => ['-t', :mangle, '-p', :all, '-m', 'owner', '--uid-owner', 'root', '-m', 'comment', '--comment', '057 POSTROUTING uid root only', '-j', 'ACCEPT'],
  651. },
  652. 'load_gid_owner_filter_module' => {
  653. :params => {
  654. :name => '057 OUTPUT gid root only',
  655. :table => 'filter',
  656. :chain => 'OUTPUT',
  657. :gid => 'root',
  658. :action => 'accept',
  659. :proto => 'all',
  660. },
  661. :args => ['-t', :filter, '-p', :all, '-m', 'owner', '--gid-owner', 'root', '-m', 'comment', '--comment', '057 OUTPUT gid root only', '-j', 'ACCEPT'],
  662. },
  663. 'load_gid_owner_postrouting_module' => {
  664. :params => {
  665. :name => '057 POSTROUTING gid root only',
  666. :table => 'mangle',
  667. :gid => 'root',
  668. :action => 'accept',
  669. :chain => 'POSTROUTING',
  670. :proto => 'all',
  671. },
  672. :args => ['-t', :mangle, '-p', :all, '-m', 'owner', '--gid-owner', 'root', '-m', 'comment', '--comment', '057 POSTROUTING gid root only', '-j', 'ACCEPT'],
  673. },
  674. 'mark_set-mark_int' => {
  675. :params => {
  676. :name => '058 set-mark 1000',
  677. :table => 'mangle',
  678. :jump => 'MARK',
  679. :chain => 'PREROUTING',
  680. :set_mark => '1000',
  681. },
  682. :args => ['-t', :mangle, '-p', :tcp, '-m', 'comment', '--comment', '058 set-mark 1000', '-j', 'MARK', '--set-xmark', '0x3e8/0xffffffff'],
  683. },
  684. 'mark_set-mark_hex' => {
  685. :params => {
  686. :name => '058 set-mark 0x32',
  687. :table => 'mangle',
  688. :jump => 'MARK',
  689. :chain => 'PREROUTING',
  690. :set_mark => '0x32',
  691. },
  692. :args => ['-t', :mangle, '-p', :tcp, '-m', 'comment', '--comment', '058 set-mark 0x32', '-j', 'MARK', '--set-xmark', '0x32/0xffffffff'],
  693. },
  694. 'mark_set-mark_hex_with_hex_mask' => {
  695. :params => {
  696. :name => '058 set-mark 0x32/0xffffffff',
  697. :table => 'mangle',
  698. :jump => 'MARK',
  699. :chain => 'PREROUTING',
  700. :set_mark => '0x32/0xffffffff',
  701. },
  702. :args => ['-t', :mangle, '-p', :tcp, '-m', 'comment', '--comment', '058 set-mark 0x32/0xffffffff', '-j', 'MARK', '--set-xmark', '0x32/0xffffffff'],
  703. },
  704. 'mark_set-mark_hex_with_mask' => {
  705. :params => {
  706. :name => '058 set-mark 0x32/4',
  707. :table => 'mangle',
  708. :jump => 'MARK',
  709. :chain => 'PREROUTING',
  710. :set_mark => '0x32/4',
  711. },
  712. :args => ['-t', :mangle, '-p', :tcp, '-m', 'comment', '--comment', '058 set-mark 0x32/4', '-j', 'MARK', '--set-xmark', '0x32/0x4'],
  713. },
  714. 'iniface_1' => {
  715. :params => {
  716. :name => '060 iniface',
  717. :table => 'filter',
  718. :action => 'drop',
  719. :chain => 'INPUT',
  720. :iniface => 'eth0',
  721. },
  722. :args => ["-t", :filter, "-i", "eth0", "-p", :tcp, "-m", "comment", "--comment", "060 iniface", "-j", "DROP"],
  723. },
  724. 'iniface_with_vlans_1' => {
  725. :params => {
  726. :name => '060 iniface',
  727. :table => 'filter',
  728. :action => 'drop',
  729. :chain => 'INPUT',
  730. :iniface => 'eth0.234',
  731. },
  732. :args => ["-t", :filter, "-i", "eth0.234", "-p", :tcp, "-m", "comment", "--comment", "060 iniface", "-j", "DROP"],
  733. },
  734. 'iniface_with_plus_1' => {
  735. :params => {
  736. :name => '060 iniface',
  737. :table => 'filter',
  738. :action => 'drop',
  739. :chain => 'INPUT',
  740. :iniface => 'eth+',
  741. },
  742. :args => ["-t", :filter, "-i", "eth+", "-p", :tcp, "-m", "comment", "--comment", "060 iniface", "-j", "DROP"],
  743. },
  744. 'outiface_1' => {
  745. :params => {
  746. :name => '060 outiface',
  747. :table => 'filter',
  748. :action => 'drop',
  749. :chain => 'OUTPUT',
  750. :outiface => 'eth0',
  751. },
  752. :args => ["-t", :filter, "-o", "eth0", "-p", :tcp, "-m", "comment", "--comment", "060 outiface", "-j", "DROP"],
  753. },
  754. 'outiface_with_vlans_1' => {
  755. :params => {
  756. :name => '060 outiface',
  757. :table => 'filter',
  758. :action => 'drop',
  759. :chain => 'OUTPUT',
  760. :outiface => 'eth0.234',
  761. },
  762. :args => ["-t", :filter, "-o", "eth0.234", "-p", :tcp, "-m", "comment", "--comment", "060 outiface", "-j", "DROP"],
  763. },
  764. 'outiface_with_plus_1' => {
  765. :params => {
  766. :name => '060 outiface',
  767. :table => 'filter',
  768. :action => 'drop',
  769. :chain => 'OUTPUT',
  770. :outiface => 'eth+',
  771. },
  772. :args => ["-t", :filter, "-o", "eth+", "-p", :tcp, "-m", "comment", "--comment", "060 outiface", "-j", "DROP"],
  773. },
  774. 'pkttype multicast' => {
  775. :params => {
  776. :name => '062 pkttype multicast',
  777. :table => "filter",
  778. :action => 'accept',
  779. :chain => 'INPUT',
  780. :iniface => 'eth0',
  781. :pkttype => 'multicast',
  782. },
  783. :args => ["-t", :filter, "-i", "eth0", "-p", :tcp, "-m", "pkttype", "--pkt-type", :multicast, "-m", "comment", "--comment", "062 pkttype multicast", "-j", "ACCEPT"],
  784. },
  785. 'socket_option' => {
  786. :params => {
  787. :name => '050 socket option',
  788. :table => 'mangle',
  789. :action => 'accept',
  790. :chain => 'PREROUTING',
  791. :socket => true,
  792. },
  793. :args => ['-t', :mangle, '-p', :tcp, '-m', 'socket', '-m', 'comment', '--comment', '050 socket option', '-j', 'ACCEPT'],
  794. },
  795. 'isfragment_option' => {
  796. :params => {
  797. :name => '050 isfragment option',
  798. :table => 'filter',
  799. :proto => :all,
  800. :action => 'accept',
  801. :isfragment => true,
  802. },
  803. :args => ['-t', :filter, '-p', :all, '-f', '-m', 'comment', '--comment', '050 isfragment option', '-j', 'ACCEPT'],
  804. },
  805. 'isfragment_option not changing -f in comment' => {
  806. :params => {
  807. :name => '050 testcomment-with-fdashf',
  808. :table => 'filter',
  809. :proto => :all,
  810. :action => 'accept',
  811. },
  812. :args => ['-t', :filter, '-p', :all, '-m', 'comment', '--comment', '050 testcomment-with-fdashf', '-j', 'ACCEPT'],
  813. },
  814. }