Debian 静态网络配置
<h1 id="静态网络配置"><strong>静态网络配置</strong></h1><h6 id="基础系统网络配置">基础系统网络配置</h6>
<p>说明: 路由网关可以使用其他终端来查看, 使用其他电脑 手机 ipad .... 查看都行.</p>
<h3 id="网卡配置">网卡配置</h3>
<p>使用vim编辑<strong>/etc/network/interfaces</strong>文件</p>
<pre><code class="language-bash"># 本地网卡静态配置
auto lo # 循环网卡名称
iface lo inet loopback #循环网卡
auto eth0 # 本地网卡地址
iface eth0 inet static # 静态地址
iface wlan0 inet dhcp # 动态地址
address 192.168.0.42 # ip地址
network 192.168.0.0 # 网关
netmask 255.255.255.0 # 子网掩码
broadcast 192.168.0.255 # ip上限
gateway 192.168.0.1 # unknown**
# 以下为无线网卡配置
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "TP-LINK_8D0B8A"
wpa-psk "12345678"
</code></pre>
<h3 id="dns配置">DNS配置</h3>
<p><strong>在/etc/resolv.conf文件内添加以下</strong></p>
<pre><code class="language-bash">nameserver 8.8.8.8 # googleDNS
nameserver 114.114.114.114 # 电信DNS
nameserver 192.168.1.1 # 本地DNS
</code></pre>
<h3 id="加入路由">加入路由</h3>
<p><strong>临时添加</strong><br>
<code>route add default gw 192.168.1.1 eth0 # 添加本主机到路由网关</code></p>
<p>或者</p>
<pre><code class="language-bash">ip route show # 显示系统路由
ip route add default via 192.168.1.254 # 设置系统默认路由
ip route list
</code></pre>
<p><strong>如果想永健生效可以在以下文件内添加该命令</strong></p>
<ol>
<li><strong>在/etc/rc.local里添加</strong> <code>any net 192.168.1.123/24 gw 192.168.1.1</code></li>
<li><strong>在/etc/sysconfig/network里添加到末尾</strong> <code>any net 192.168.1.123/24 gw 192.168.1.1</code></li>
<li><strong>/etc/sysconfig/static-router :</strong></li>
</ol>
<pre><code class="language-shell**any">auto eth0
iface eth0 inet dhcp
up route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.2
up route add default gw 192.168.1.200
down route del default gw 192.168.1.200
down route del -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.2
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
</code></pre>
<h2 id="相关链接">相关链接:</h2>
<p>((20220106002346-bfmn6wk "ip 命令"))</p>
<p>((20211230075607-cpkuchg "Debian 网络软件"))</p>
</div>
<div id="MySignature" role="contentinfo">
文章编写or整理的内容由作者完成,引用or参考会给出原文链接。<br><br>
来源:https://www.cnblogs.com/xs-xs/p/16329067.html
頁:
[1]