{"id":307,"date":"2015-02-10T15:09:00","date_gmt":"2015-02-10T15:09:00","guid":{"rendered":"http:\/\/general.sio57.info\/wp\/?p=307"},"modified":"2021-05-14T14:05:09","modified_gmt":"2021-05-14T14:05:09","slug":"parametres-reseau-debian","status":"publish","type":"post","link":"http:\/\/general.sio57.info\/wp\/?p=307","title":{"rendered":"Param\u00e8tres r\u00e9seau Debian Ubuntu et Centos"},"content":{"rendered":"<p>Le minimum sur un syst\u00e8me est d&rsquo;acc\u00e9der au r\u00e9seau.<\/p>\n<p>Sur Debian il y a plusieurs mani\u00e8res de faire; avec l&rsquo;interface graphique (en haut \u00e0 droite sur l&rsquo;icone r\u00e9seau en choisissant modifier), et il y a aussi 2 m\u00e9thodes en ligne de commande (<span style=\"text-decoration: underline;\">en mode root su).<\/span><\/p>\n<p>Sur Ubuntu et\u00a0 Centos c&rsquo;est un peu diff\u00e9rent et expliqu\u00e9 apr\u00e8s<\/p>\n<p><!--more--><\/p>\n<h1>Dedian<\/h1>\n<p>L&rsquo;une est ponctuelle et devra \u00eatre refaite apr\u00e8s un red\u00e9marrage\u00a0\u00a0:<\/p>\n<ul>\n<li>Pour se mettre en DHCP (configuration dynamique)<br \/>\n<code class=\"prompt\"># <\/code><strong class=\"userinput\"><code>dhclient eth0<\/code><\/strong><\/li>\n<li>Pour mettre un adresse fixe :<br \/>\n<strong class=\"userinput\"><code># ifconfig eth0 192.168.0.42<br \/>\n<\/code><\/strong><code class=\"prompt\"># <\/code><strong class=\"userinput\"><code>route add default gw 192.168.0.1 dev eth0<br \/>\n<\/code><\/strong><strong class=\"userinput\"><code><em>C'est possible aussi en IP V6 mais n'a pas vraiment d'int\u00e9r\u00eat : ip v6 \u00e9tant bas\u00e9e sur l'auto configuration des interfaces !<br \/>\n<\/em><\/code><\/strong><em><code class=\"prompt\"># <\/code><strong class=\"userinput\"><code>ifconfig eth0 add 2001:db8::6726\/32<br \/>\n<\/code><\/strong><\/em><em><code class=\"prompt\"># <\/code><strong class=\"userinput\"><code>route --inet6 add default gw 2001:db8::1 dev eth0<\/code><\/strong><\/em><\/li>\n<li>Ajouter aussi la configuration DNS dans le fichier \/etc\/resolv.conf<br \/>\nnameserver 192.0.2.71 (en fonction de votre dns)<\/li>\n<\/ul>\n<p><span style=\"color: #000000;\"><strong class=\"userinput\"><code>La configuration permanente que je recommande :\u00a0<\/code><\/strong><\/span><\/p>\n<p><strong class=\"userinput\"><code>Dans le fichier \/etc\/network\/interfaces<\/code><\/strong><\/p>\n<p class=\"programlisting\">Modifier les param\u00e8tres suivants vos besoins :<\/p>\n<pre class=\"programlisting\">auto lo eth1 (interface a configurer au d\u00e9marrage, m\u00eame si le r\u00e9seau n'est pas branch\u00e9)\nallow-hotplug eth0 (interface a configurer que si le r\u00e9seau est branch\u00e9)<\/pre>\n<pre class=\"programlisting\" style=\"padding-left: 30px;\">iface eth0 inet dhcp (pour le dhcp)<\/pre>\n<pre class=\"programlisting\" style=\"padding-left: 30px;\">iface eth1 inet static (pour une adresse fixe)\n    address 192.168.0.42\n    netmask 255.255.255.0\n    gateway 192.195.0.1\n    dns-nameservers 192.0.2.71<\/pre>\n<pre class=\"screen\"><strong class=\"userinput\"><code>\nN'h\u00e9sitez a regarder <a title=\"if reseau linux\" href=\"http:\/\/formation-debian.via.ecp.fr\/ip.html\">ce site<\/a> pour plus d'infos<\/code><\/strong><\/pre>\n<h1 class=\"page-title\">Ubuntu : Configuration IP statique via Netplan<\/h1>\n<p>NETPLAN Ubuntu<\/p>\n<p>D\u2019abord faire un ifconfig pour voir le nom des interfaces<\/p>\n<p>Faire un ifconfig -a pour voir toutes les interfaces<\/p>\n<p>(le nom de l\u2019interface est repris dans le fichier yaml &#8211; voir copie \u00e9cran ci-dessous )<\/p>\n<p>Avec Vi (faire tr\u00e8s attention \u00e0 l\u2019indentation) cr\u00e9er un fichier dans le r\u00e9pertoire \/etc\/netplan<\/p>\n<p># Vi \/etc\/netplan\/01-netcfg.yaml<\/p>\n<ol>\n<li>network:<\/li>\n<li>\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 version: 2<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 renderer: networkd<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ethernets:<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 enp0s10f0:<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 dhcp: no<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 addresses: [192.168.1.151\/24]<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 gateway4: 192.168.1.254<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0 nameservers:<\/li>\n<li>\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0 \u00a0\u00a0 addresses: [192.168.1.100]<\/li>\n<\/ol>\n<p>Puis<\/p>\n<p>#netplan generate<\/p>\n<p>#netplan apply<\/p>\n<h3 id=\"relancer_le_service\" class=\"sectionedit6\">relancer le service<\/h3>\n<div class=\"level3\">\n<pre class=\"code\">systemctl restart systemd-networkd<\/pre>\n<\/div>\n<p>Tester un ping vers l\u2019adresse pour v\u00e9rifier le bon fonctionnement<\/p>\n<pre class=\"screen\"><strong class=\"userinput\"><code><\/code><a href=\"http:\/\/general.sio57.info\/wp\/wp-content\/uploads\/2015\/02\/netplan.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1248\" src=\"http:\/\/general.sio57.info\/wp\/wp-content\/uploads\/2015\/02\/netplan.png\" alt=\"\" width=\"1003\" height=\"338\" srcset=\"http:\/\/general.sio57.info\/wp\/wp-content\/uploads\/2015\/02\/netplan.png 1003w, http:\/\/general.sio57.info\/wp\/wp-content\/uploads\/2015\/02\/netplan-300x101.png 300w, http:\/\/general.sio57.info\/wp\/wp-content\/uploads\/2015\/02\/netplan-768x259.png 768w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/a><\/strong><\/pre>\n<pre class=\"screen\"><strong class=\"userinput\"><code><\/code><\/strong><\/pre>\n<h1 class=\"page-title\">CentOS: Configuration IP statique<\/h1>\n<pre class=\"screen\"><strong class=\"userinput\"><code><\/code>(cette partie de l'article est copier de ce site - au cas ou il disparaisse https:\/\/www.quennec.fr\/trucs-astuces\/syst%C3%A8mes\/centos-7\/r%C3%A9seau\/centos-configuration-ip-statique <\/strong><\/pre>\n<div class=\"region region-content\">\n<div id=\"block-system-main\" class=\"block block-system\">\n<div class=\"content\">\n<div class=\"content\">\n<div class=\"field field-name-body field-type-text-with-summary field-label-hidden\">\n<div class=\"field-items\">\n<div class=\"field-item even\">\n<p>Sous <strong>CentOS<\/strong>, la configuration de l&rsquo;interface r\u00e9seau avec une adresse IP statique diff\u00e8re de celle sous Debian ou Ubuntu.<\/p>\n<p>Pour identifier les cartes r\u00e9seaux pr\u00e9sentes sur la machine, ex\u00e9cuter la commande suivante:<\/p>\n<pre><code class=\"bash hljs\"><span class=\"hljs-comment\"># nmcli d<\/span><\/code><\/pre>\n<p>Pour une configuration avec un assistant, ex\u00e9cuter la commande suivante et suivre les indications \u00e0 l&rsquo;\u00e9cran:<\/p>\n<pre><code class=\"bash hljs\"><span class=\"hljs-comment\"># nmtui<\/span><\/code><\/pre>\n<p>Une fois la configuration r\u00e9seau termin\u00e9e, assist\u00e9e ou manuelle, red\u00e9marrer le service r\u00e9seau:<\/p>\n<pre><code class=\"bash hljs\"><span class=\"hljs-comment\"># systemctl restart network<\/span><\/code><\/pre>\n<p>Pour une configuration manuelle, voir ci-dessous.<\/p>\n<p>Sous CentOS, il faut cr\u00e9er un fichier <strong>ifcfg-eth0<\/strong>, correspondant bien s\u00fbr au nom de l&rsquo;interface r\u00e9seau \u00e0 configurer. Dans ce cas, il s&rsquo;agit de l&rsquo;interface <strong>eth0<\/strong>.<\/p>\n<p>Ce fichier est \u00e0 cr\u00e9er dans le dossier <strong>\/etc\/sysconfig\/network-scripts<\/strong><\/p>\n<p>Il doit contenir les informations suivantes:<\/p>\n<pre><code class=\"bash hljs\"><span class=\"hljs-comment\"># <\/span><strong><span class=\"hljs-comment\">cat \/etc\/sysconfig\/network-scripts\/ifcfg-eth0<\/span><\/strong>\nDEVICE=<span class=\"hljs-string\">\"eth0\"<\/span>\nHWADDR=<span class=\"hljs-string\">\"A6:B5:6C:4F:E5:C0\"<\/span>\nNM_CONTROLLED=<span class=\"hljs-string\">\"no\"<\/span>\nONBOOT=<span class=\"hljs-string\">\"yes\"<\/span>\nBOOTPROTO=static\n<span class=\"hljs-comment\"># BOOTPROTO=dhcp<\/span>\nIPADDR=<span class=\"hljs-number\">172.16<\/span>.<span class=\"hljs-number\">1.115<\/span>\nNETMASK=<span class=\"hljs-number\">255.255<\/span>.<span class=\"hljs-number\">255.0<\/span>\n<span class=\"hljs-comment\">#<\/span>\n<span class=\"hljs-comment\">#   the GATEWAY is sometimes in: \/etc\/sysconfig\/network<\/span>\nGATEWAY=<span class=\"hljs-number\">172.16<\/span>.<span class=\"hljs-number\">1.1<\/span><\/code><\/pre>\n<p>Les param\u00e8tres \u00e0 renseigner sont assez explicites.<\/p>\n<p>Il faut \u00e9galement modifier le fichier <strong>\/etc\/sysconfig\/network<\/strong><\/p>\n<pre><code class=\"bash hljs\"><span class=\"hljs-comment\"># <\/span><strong><span class=\"hljs-comment\">cat \/etc\/sysconfig\/network<\/span><\/strong>\nNETWORKING=<span class=\"hljs-string\">\"yes\"<\/span>\nDNS1=<span class=\"hljs-number\">8.8<\/span>.<span class=\"hljs-number\">8.8<\/span>\nDNS2=<span class=\"hljs-number\">8.8<\/span>.<span class=\"hljs-number\">4.4<\/span>\nSEARCH=mondomaine.fr<\/code><\/pre>\n<p>L\u00e0 \u00e9galement, les param\u00e8tres \u00e0 renseigner sont assez explicites.<\/p>\n<p>Reste \u00e0 ex\u00e9cuter la commande suivante afin d&rsquo;initialiser les diff\u00e9rents scripts.<\/p>\n<pre><code class=\"bash hljs\"><span class=\"hljs-comment\">#<\/span><strong><span class=\"hljs-comment\"> rpm -qd initscripts<\/span><\/strong><\/code><\/pre>\n<p>Et voil\u00e0, c&rsquo;est termin\u00e9. Red\u00e9marrer le serveur afin de prendre en compte les modifications.<\/p>\n<p>La commande <strong>ifconfig <\/strong>permet de v\u00e9rifier que tout est correct.<\/p>\n<p>Si la commande <strong>ifconfig <\/strong>n&rsquo;est pas install\u00e9e:<\/p>\n<pre><code class=\"bash hljs\"><span class=\"hljs-comment\"># <\/span><strong><span class=\"hljs-comment\">yum install net-tools.x86_64<\/span><\/strong><\/code><\/pre>\n<p>Puis:<\/p>\n<pre><code class=\"bash hljs\"><span class=\"hljs-comment\">#<\/span><strong><span class=\"hljs-comment\"> ifconfig<\/span><\/strong>\neth0: flags=<span class=\"hljs-number\">4163<\/span>&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu <span class=\"hljs-number\">1500<\/span>\n        inet <span class=\"hljs-number\">172.16<\/span>.<span class=\"hljs-number\">1.115<\/span>  netmask <span class=\"hljs-number\">255.255<\/span>.<span class=\"hljs-number\">255.0<\/span>  broadcast <span class=\"hljs-number\">172.16<\/span>.<span class=\"hljs-number\">1.255<\/span>\n        inet6 fe80::a4b5:<span class=\"hljs-number\">6<\/span>cff:fe4f:e5c0  prefixlen <span class=\"hljs-number\">64<\/span>  scopeid <span class=\"hljs-number\">0<\/span>x20&lt;link&gt;\n        ether a6:b5:<span class=\"hljs-number\">6<\/span>c:<span class=\"hljs-number\">4<\/span>f:e5:c0  txqueuelen <span class=\"hljs-number\">0<\/span>  (Ethernet)\n        RX packets <span class=\"hljs-number\">43646<\/span>  bytes <span class=\"hljs-number\">64538893<\/span> (<span class=\"hljs-number\">61.5<\/span> MiB)\n        RX errors <span class=\"hljs-number\">0<\/span>  dropped <span class=\"hljs-number\">0<\/span>  overruns <span class=\"hljs-number\">0<\/span>  frame <span class=\"hljs-number\">0<\/span>\n        TX packets <span class=\"hljs-number\">20396<\/span>  bytes <span class=\"hljs-number\">1157263<\/span> (<span class=\"hljs-number\">1.1<\/span> MiB)\n        TX errors <span class=\"hljs-number\">0<\/span>  dropped <span class=\"hljs-number\">0<\/span> overruns <span class=\"hljs-number\">0<\/span>  carrier <span class=\"hljs-number\">0<\/span>  collisions <span class=\"hljs-number\">0<\/span>\n\nlo: flags=<span class=\"hljs-number\">73<\/span>&lt;UP,LOOPBACK,RUNNING&gt;  mtu <span class=\"hljs-number\">65536<\/span>\n        inet <span class=\"hljs-number\">127.0<\/span>.<span class=\"hljs-number\">0.1<\/span>  netmask <span class=\"hljs-number\">255.0<\/span>.<span class=\"hljs-number\">0.0<\/span>\n        inet6 ::<span class=\"hljs-number\">1<\/span>  prefixlen <span class=\"hljs-number\">128<\/span>  scopeid <span class=\"hljs-number\">0<\/span>x10&lt;host&gt;\n        loop  txqueuelen <span class=\"hljs-number\">0<\/span>  (Local Loopback)\n        RX packets <span class=\"hljs-number\">0<\/span>  bytes <span class=\"hljs-number\">0<\/span> (<span class=\"hljs-number\">0.0<\/span> B)\n        RX errors <span class=\"hljs-number\">0<\/span>  dropped <span class=\"hljs-number\">0<\/span>  overruns <span class=\"hljs-number\">0<\/span>  frame <span class=\"hljs-number\">0<\/span>\n        TX packets <span class=\"hljs-number\">0<\/span>  bytes <span class=\"hljs-number\">0<\/span> (<span class=\"hljs-number\">0.0<\/span> B)\n        TX errors <span class=\"hljs-number\">0<\/span>  dropped <span class=\"hljs-number\">0<\/span> overruns <span class=\"hljs-number\">0<\/span>  carrier <span class=\"hljs-number\">0<\/span>  collisions <span class=\"hljs-number\">0<\/span>\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<pre class=\"screen\"><strong class=\"userinput\"><code><\/code><\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Le minimum sur un syst\u00e8me est d&rsquo;acc\u00e9der au r\u00e9seau. Sur Debian il y a plusieurs mani\u00e8res de faire; avec l&rsquo;interface graphique (en haut \u00e0 droite sur l&rsquo;icone r\u00e9seau en choisissant modifier), et il y a aussi 2 m\u00e9thodes en ligne de commande (en mode root su). Sur Ubuntu et\u00a0 Centos c&rsquo;est un peu diff\u00e9rent et [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,26,40,104],"tags":[47,48],"class_list":["post-307","post","type-post","status-publish","format-standard","hentry","category-linux","category-si1","category-sisr4","category-trucs-astuces","tag-debian","tag-parametre-reseau"],"_links":{"self":[{"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=307"}],"version-history":[{"count":9,"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/307\/revisions"}],"predecessor-version":[{"id":1498,"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/307\/revisions\/1498"}],"wp:attachment":[{"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=307"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/general.sio57.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}