{"id":1301,"date":"2017-11-09T12:52:47","date_gmt":"2017-11-09T12:52:47","guid":{"rendered":"http:\/\/10sa.com\/sql_stories\/?p=1301"},"modified":"2017-11-09T12:52:47","modified_gmt":"2017-11-09T12:52:47","slug":"firewall-cmd-xargs-and-formatting","status":"publish","type":"post","link":"http:\/\/10sa.com\/sql_stories\/?p=1301","title":{"rendered":"firewall-cmd, xargs and formatting"},"content":{"rendered":"<pre lang=\"bash\">\r\nfirewall-cmd --direct --get-all-rules | xargs -n1 echo\r\nipv4\r\nnat\r\nPREROUTING\r\n1\r\n!\r\n--src\r\n172.30.25.0\/24\r\n--dst\r\n10.0.25.1\r\n-p\r\ntcp\r\n--dport\r\n3050\r\n-j\r\nDNAT\r\n--to\r\n172.30.25.168:3050\r\n-m\r\ncomment\r\n--comment\r\nLVS -> server\r\n<\/pre>\n<p>If you finished with such unformatted text, you can use the parameter -i<\/p>\n<pre lang=\"bash\">\r\n[root@db3 ~]# firewall-cmd --direct --get-all-rules | grep \"168\\|.25.1\\s\"| head -n 2  | xargs -n 1 -i echo \"{}\"\r\nipv4 nat PREROUTING 1 ! --src 172.30.25.0\/24 --dst 10.0.25.1 -p tcp --dport 3050 -j DNAT --to 172.30.25.168:3050 -m comment --comment LVS -> server\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>firewall-cmd &#8211;direct &#8211;get-all-rules | xargs -n1 echo ipv4 nat PREROUTING 1 ! &#8211;src 172.30.25.0\/24 &#8211;dst 10.0.25.1 -p tcp &#8211;dport 3050 -j DNAT &#8211;to 172.30.25.168:3050 -m comment &#8211;comment LVS -> server If you finished with such unformatted text, you can use the parameter -i [root@db3 ~]# firewall-cmd &#8211;direct &#8211;get-all-rules | grep &#8220;168\\|.25.1\\s&#8221;| head -n 2 | [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23],"tags":[],"_links":{"self":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/1301"}],"collection":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1301"}],"version-history":[{"count":1,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/1301\/revisions"}],"predecessor-version":[{"id":1302,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/1301\/revisions\/1302"}],"wp:attachment":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1301"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}