deb-sysd-static-ip.html
1 <!DOCTYPE html> 2 <html lang="de"> 3 <head> 4 <meta charset="UTF-8" /> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 6 <meta http-equiv="onion-location" content="http://bopbopl6lohkl2rts3ltesjnag4hzs4jrx2h6k6etgq5xasbpqekzlqd.onion" /> 7 <title>BOP Wiki: Static local IPv4 & IPv6 GUA in Debian</title> 8 <link rel="stylesheet" href="/assets/stylesheet.css" /> 9 <link rel="icon" type="image/x-icon" href="/assets/img/favicon.png"> 10 </head> 11 <body> 12 <header> 13 14 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 15 16 <script src="/assets/js/navbar-OpenClose.js"></script> 17 <script src="/assets/js/lightbox.js"></script> 18 <script src="/assets/js/copyCodeButton.js"></script> 19 <link rel="stylesheet" href="/resources/js-libraries/highlightJS/atom-one-dark.min.css"> 20 <script src="/resources/js-libraries/highlightJS/highlight.min.js"></script> 21 <script src="/resources/js-libraries/highlightJS/highlightjs-line-numbers.min.js"></script> 22 <script>hljs.highlightAll();</script> 23 <script>hljs.initLineNumbersOnLoad();</script> 24 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 25 <div class="branding"> 26 <button class="toggle-btn-navbar" id="navbarOpenButton">☰</button> 27 <a href="/"> 28 <img class="logo" src="/assets/img/logo.png"> 29 </a> 30 <div class="typing-animation">BytesOfProgress</div> 31 </div> 32 </header> 33 <div id="navbarContainer" class="navbar-container"> 34 <iframe class="navbar-iframe" src="/assets/navbar/navbar.html" frameBorder= "0"></iframe> 35 </div> 36 <main> 37 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 38 39 <article class="site-post"> 40 <header class="post-header"> 41 <h1 class="post-title">Static local IPv4 & IPv6 GUA in Debian</h1> 42 <div class="post-meta"> 43 </div> 44 </header> 45 </article> 46 <nav class="breadcrumb"> 47 <a href="/">Home</a> 48 <span class="divider">›</span> 49 <a href="/wiki/">Wiki</a> 50 <span class="divider">›</span> 51 <a href="/wiki/linux/A1linux.html">GNU / Linux</a> 52 <span class="divider">›</span> 53 <a href="/wiki/linux/HowDoI/A1HowDoI.html">HowDoI</a> 54 <span class="divider">›</span> 55 <span class="current">Static local IPv4 & IPv6 GUA in Debian</span> 56 </nav> 57 <section class="post-content"> 58 59 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 60 61 <h2>Debian 12 method:</h2> 62 63 <p> 64 First, we have to find out the interface name. 65 </p> 66 67 <blockquote> 68 # ip link show 69 </blockquote> 70 <p> 71 The Output should look something like this: 72 </p> 73 <div class="code-box"> 74 <pre><code>1: lo: LOOPBACK,UP,LOWER_UP mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 75 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 76 2: ens18: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 77 link/ether 00:0c:29:0d:d5:a2 brd ff:ff:ff:ff:ff:ff 78 altname enp11s0</code></pre> 79 </div> 80 <br> 81 <p> 82 The device we want to edit the config for is named "ens192" in this example. 83 Now we can go ahead and make some changes to the config file using a text editor like e.g. nano. 84 In Debian, the config file's path is "/etc/network/interfaces" 85 </p> 86 <p> 87 The content of the file should look something like this: 88 </p> 89 <div class="code-box"> 90 <pre><code># This file describes the network interfaces available on your system 91 # and how to activate them. For more information, see interfaces(5). 92 93 source /etc/network/interfaces.d/* 94 95 # The loopback network interface 96 auto lo 97 iface lo inet loopback 98 99 # The primary network interface 100 #allow-hotplug ens18 101 #iface ens18 inet dhcp 102 auto ens18 103 iface ens18 inet static 104 address YOUR_STATIC_IP 105 netmask YOUR_NETMASK 106 gateway YOUR_GATEWAY 107 dns-nameservers DNS_YOU_WANT_TO_USE 108 109 # Allowing IPv6 DHCP 110 iface ens18 inet6 dhcp</code></pre> 111 </div> 112 <br> 113 <p> 114 As you can see, we commented out the line containing things like 115 "dhcp" and "allow-hotplug", and then added our own configuration. 116 The only thing left to do now, is restarting the networking systemd service: 117 </p> 118 119 <blockquote> 120 # systemctl restart networking 121 </blockquote> 122 <p> 123 Congratulations! Your server has now a static local IP-Address. 124 To double-check whether it has worked, you can look up your IP with: 125 </p> 126 <blockquote> 127 # ip a 128 </blockquote> 129 130 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 131 132 <hr /> 133 134 <h2>Debian 13 method:</h2> 135 136 <p> 137 First, 138 </p> 139 140 <blockquote> 141 # apt install systemd-resolved 142 </blockquote> 143 144 <p> 145 After that, create a textfile in "/etc/systemd/network/10-ens18.network". 146 It needs the following contents: 147 </p> 148 149 <div class="code-box"> 150 <pre><code>[Match] 151 Name=ens18 152 153 [Network] 154 #DHCP=no 155 Address=192.168.15.15/24 156 Gateway=192.168.15.254 157 DNS=1.1.1.1 158 DNS=2606:4700:4700::1111 159 IPv6AcceptRA=yes 160 161 [IPv6AcceptRA] 162 UseDNS=yes 163 UseAutonomousPrefix=yes 164 UseRoutes=yes</code></pre> 165 </div> 166 167 <p> 168 Then, enable the systemd network services: 169 </p> 170 171 <blockquote> 172 # systemctl enable systemd-networkd --now && systemctl enable systemd-resolved --now 173 </blockquote> 174 175 <p> 176 Then, link the systemd-resolved file to "/etc/resolv.conf": 177 </p> 178 179 <blockquote> 180 # ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf 181 </blockquote> 182 183 <p> 184 After that, check the interface status: 185 </p> 186 187 <blockquote> 188 # networkctl status ens18 189 </blockquote> 190 191 <p> 192 Perform a reboot. After that: 193 </p> 194 195 <blockquote> 196 # systemctl restart systemd-networkd 197 </blockquote> 198 199 <p> 200 Check resolvectl status: 201 </p> 202 203 <blockquote> 204 # resolvectl status 205 </blockquote> 206 207 <p> 208 If this times out, you can try to restart it with: 209 </p> 210 211 <blockquote> 212 # systemctl restart systemd-resolved 213 </blockquote> 214 215 <p> 216 At the last step, you can disable and stop the old networking service: 217 </p> 218 219 <blockquote> 220 # systemctl disable networking --now 221 </blockquote> 222 223 <p> 224 Finally, test if you have got the right address with "ip a". 225 </p> 226 227 <hr /> 228 229 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 230 231 </section> 232 <footer class="post-footer"> 233 <a href="/wiki/linux/HowDoI/A1HowDoI.html" class="cta-button">← Back</a> 234 </footer> 235 </main> 236 </body> 237 </html>