温馨提示×

Debian Stream 8如何进行网络配置

小樊
43
2025-08-20 12:08:38
栏目: 智能运维

Debian Stream 8 通常使用 /etc/network/interfaces 文件配置网络(部分场景可能使用 Netplan,但非主流)。以下是具体步骤:

1. 查看网卡名称

先确认网卡名称(如 eth0enp3s0 等):

ip addr show  

2. 配置静态 IP(推荐)

编辑网络配置文件:

sudo nano /etc/network/interfaces  

添加以下内容(以 eth0 为例):

auto eth0  
iface eth0 inet static  
    address 192.168.1.100/24  # IP地址+子网掩码  
    gateway 192.168.1.1       # 网关  
    dns-nameservers 8.8.8.8 8.8.4.4  # DNS服务器  

保存后重启网络:

sudo systemctl restart networking  

3. 配置动态 IP(DHCP)

若需自动获取 IP,修改配置为:

auto eth0  
iface eth0 inet dhcp  

保存后重启网络:

sudo systemctl restart networking  

4. 验证配置

  • 查看 IP 是否生效:
    ip addr show eth0  
    
  • 测试网络连通性:
    ping 8.8.8.8  
    

注意事项

  • Debian Stream 8 仍使用传统网络配置方式,与 CentOS Stream 8 的 Netplan 不同。
  • 若使用 NetworkManager(图形界面工具),可通过 nm-connection-editor 配置,但需先安装:
    sudo apt install network-manager  
    

以上配置适用于 Debian 10/11 及 Stream 8 等版本。

0