{"id":371,"date":"2020-11-26T17:12:21","date_gmt":"2020-11-26T20:12:21","guid":{"rendered":"http:\/\/xaxowareti.com.br\/?p=371"},"modified":"2020-11-26T17:12:25","modified_gmt":"2020-11-26T20:12:25","slug":"agregacao-de-interfaces-de-rede","status":"publish","type":"post","link":"https:\/\/xaxowareti.com.br\/?p=371","title":{"rendered":"Agrega\u00e7\u00e3o de interfaces de rede"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"agregacao_de_interfaces_de_rede\">Agrega\u00e7\u00e3o de interfaces de rede<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"objectivo\">Objectivo<\/h2>\n\n\n\n<p>A maior parte dos sistemas actuais disp\u00f5e de 2 liga\u00e7\u00f5es&nbsp;<em>Ethernet<\/em>. Estas podem ser utilizadas em separado ou em paralelo, numa t\u00e9cnica chamada&nbsp;<em>bonding<\/em>. Esta t\u00e9cnica \u00e9 muito interessante, uma vez que possibilita o balanceamento de dados (os dados s\u00e3o transmitidos pelas 2 interfaces) e toler\u00e2ncia a falhas (caso uma liga\u00e7\u00e3o falhe, a transmiss\u00e3o \u00e9 assegurada pela outra).<\/p>\n\n\n\n<p>No nosso servidor, iremos agregar as duas interfaces f\u00edsicas do sistema&nbsp;<em>eth0<\/em>&nbsp;e&nbsp;<em>eth1<\/em>&nbsp;para criar uma nova interface de rede&nbsp;<em>bond0<\/em>&nbsp;de alta disponibilidade.<strong>Ethernet bonding<\/strong><br><em>Ethernet bonding<\/em>, regulado pela norma&nbsp;<em>IEEE 802.3ad<\/em>&nbsp;com o t\u00edtulo&nbsp;<em>link aggregation<\/em>&nbsp;\u00e9 um termo da disciplina de redes de computadores que descreve o acoplamento de dois ou mais canais Ethernet em paralelo para produzir um \u00fanico canal de maior velocidade e\/ou aumentar a disponibilidade e redund\u00e2ncia desse canal.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"instalacao\">Instala\u00e7\u00e3o<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">root@server~# aptitude install ifenslave<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuracao\">Configura\u00e7\u00e3o<\/h2>\n\n\n\n<p>Para criar a interface&nbsp;<em>bond0<\/em>&nbsp;dever\u00e1 ser carregado e configurado o m\u00f3dulo&nbsp;<em>bonding<\/em>&nbsp;do&nbsp;<em>kernel<\/em>. Este m\u00f3dulo ser\u00e1 carregado automaticamente ap\u00f3s a configura\u00e7\u00e3o; por agora dever\u00e1 ser carregado manualmente:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@server:~# modprobe bonding<\/pre>\n\n\n\n<p>Verificar que est\u00e1 realmente carregado:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@server:~# lsmod | grep bonding\nbonding                65204  0<\/pre>\n\n\n\n<p>O passo seguinte \u00e9 a parametriza\u00e7\u00e3o da nova interface de rede e remo\u00e7\u00e3o (ou comentar) qualquer refer\u00eancia \u00e0s interfaces f\u00edsicas por ela usadas, o que \u00e9 feito no ficheiro&nbsp;<em>\/etc\/network\/interfaces<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># This file describes the network interfaces available on your system\n# and how to activate them. For more information, see interfaces(5).\n\n# The loopback network interface\nauto lo\niface lo inet loopback\n\n# The primary network interface\n# allow-hotplug eth0\n# iface eth0 inet dhcp\n\n# Static IP address\n# auto eth0\n# iface eth0 inet static\n#        address 192.168.1.100\n#        netmask 255.255.255.0\n#        network 192.168.1.0\n#        broadcast 192.168.1.255\n#        gateway 192.168.1.1\n\n# Interface bonding\n# Static IP address\nauto bond0\niface bond0 inet static\n        bond-slaves eth0 eth1\n        bond-mode balance-rr\n        bond-miimon 100\n        bond-primary eth0 eth1\n\n        address 192.168.1.100\n        netmask 255.255.255.0\n        network 192.168.1.0\n        broadcast 192.168.1.255\n        gateway 192.168.1.1<\/pre>\n\n\n\n<p>O par\u00e2metro&nbsp;<strong>bond-mode balance-rr<\/strong>&nbsp;indica que a interface ir\u00e1 operar em modo&nbsp;<em>balance-rr<\/em>, em que os dados ser\u00e3o transmitidos alternadamente pelas diversas interfaces f\u00edsicas que comp\u00f5em a nova interface&nbsp;<em>bond0<\/em>.<\/p>\n\n\n\n<p>Finalmente, reiniciar os servi\u00e7os de rede:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@server:~# \/etc\/init.d\/networking restart<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"verificacao\">Verifica\u00e7\u00e3o<\/h2>\n\n\n\n<p>O comando&nbsp;<strong>ifconfig<\/strong>&nbsp;permite verificar o estado das interfaces de rede:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@server:~# ifconfig\nbond0     Link encap:Ethernet  HWaddr 00:30:1b:b0:6e:84\n          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0\n          inet6 addr: fe80::230:1bff:feb0:6e84\/64 Scope:Link\n          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1\n          RX packets:23339499 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:11308048 errors:0 dropped:0 overruns:5 carrier:0\n          collisions:0 txqueuelen:0\n          RX bytes:182934407 (174.4 MiB)  TX bytes:1008040228 (961.3 MiB)\n\neth0      Link encap:Ethernet  HWaddr 00:30:1b:b0:6e:84\n          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1\n          RX packets:12004063 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:5654023 errors:0 dropped:0 overruns:5 carrier:0\n          collisions:0 txqueuelen:1000\n          RX bytes:597782690 (570.0 MiB)  TX bytes:519229722 (495.1 MiB)\n          Interrupt:18 Base address:0xa000\n\neth1      Link encap:Ethernet  HWaddr 00:30:1b:b0:6e:84\n          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1\n          RX packets:11335436 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:5654025 errors:0 dropped:0 overruns:0 carrier:0\n          collisions:0 txqueuelen:1000\n          RX bytes:3880119013 (3.6 GiB)  TX bytes:488810506 (466.1 MiB)\n\nlo        Link encap:Local Loopback\n          inet addr:127.0.0.1  Mask:255.0.0.0\n          inet6 addr: ::1\/128 Scope:Host\n          UP LOOPBACK RUNNING  MTU:16436  Metric:1\n          RX packets:193243 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:193243 errors:0 dropped:0 overruns:0 carrier:0\n          collisions:0 txqueuelen:0\n          RX bytes:31609190 (30.1 MiB)  TX bytes:31609190 (30.1 MiB)<\/pre>\n\n\n\n<p>A interface&nbsp;<em>bond0<\/em>&nbsp;tem atribu\u00eddo um endere\u00e7o Internet e as 3 interfaces (<em>bond0<\/em>,&nbsp;<em>eth0<\/em>&nbsp;e&nbsp;<em>eth1<\/em>) t\u00eam o mesmo endere\u00e7o f\u00edsico (\u201cHWaddr 00:30:1b:b0:6e:84\u201d), para que sejam \u201cvistas\u201d pelo resto da rede como sendo apenas uma.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Agrega\u00e7\u00e3o de interfaces de rede Objectivo A maior parte dos sistemas actuais disp\u00f5e de 2 liga\u00e7\u00f5es&nbsp;Ethernet. Estas podem ser utilizadas em separado ou em paralelo, numa t\u00e9cnica chamada&nbsp;bonding. Esta t\u00e9cnica \u00e9 muito interessante, uma vez que possibilita o balanceamento de dados (os dados s\u00e3o transmitidos pelas 2 interfaces) e toler\u00e2ncia a falhas (caso uma liga\u00e7\u00e3o [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-371","post","type-post","status-publish","format-standard","hentry","category-sem-categoria"],"_links":{"self":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=371"}],"version-history":[{"count":1,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/371\/revisions"}],"predecessor-version":[{"id":372,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/371\/revisions\/372"}],"wp:attachment":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}