{"id":1145,"date":"2016-02-19T12:42:14","date_gmt":"2016-02-19T12:42:14","guid":{"rendered":"http:\/\/10sa.com\/sql_stories\/?p=1145"},"modified":"2016-02-19T12:42:14","modified_gmt":"2016-02-19T12:42:14","slug":"docker-get-relation-between-container-and-interface-veth","status":"publish","type":"post","link":"http:\/\/10sa.com\/sql_stories\/?p=1145","title":{"rendered":"Docker: get relation between container and interface veth"},"content":{"rendered":"<p>The idea is to receive the index of the next interface.<\/p>\n<pre>\r\n# Get veth interface:\r\nMY_CONTAINER_NAME=\"mysql_server_1\"\r\nLINK_INDEX=`docker exec -it $MY_CONTAINER_NAME ip a l eth0  | awk -F \":\" '{if (NR==1) print $1+1}'`\r\nip link ls | grep \"^$LINK_INDEX\" | awk -F\":\" '{ gsub (\" \", \"\", $2); print $2}'\r\n<\/pre>\n<p>Now you can easily observe the network traffic of your container. <\/p>\n<pre>\r\n# for virtual ethernet device vetha41c95c \r\ntcpdump -nn  -i vetha41c95c -s 0 -w - \"src host SOME.IP.ADDR.\" -c 100 | strings\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The idea is to receive the index of the next interface. # Get veth interface: MY_CONTAINER_NAME=&#8221;mysql_server_1&#8243; LINK_INDEX=`docker exec -it $MY_CONTAINER_NAME ip a l eth0 | awk -F &#8220;:&#8221; &#8216;{if (NR==1) print $1+1}&#8217;` ip link ls | grep &#8220;^$LINK_INDEX&#8221; | awk -F&#8221;:&#8221; &#8216;{ gsub (&#8221; &#8220;, &#8220;&#8221;, $2); print $2}&#8217; Now you can easily observe the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,19],"tags":[],"_links":{"self":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/1145"}],"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=1145"}],"version-history":[{"count":2,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/1145\/revisions"}],"predecessor-version":[{"id":1153,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/1145\/revisions\/1153"}],"wp:attachment":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1145"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}