短网址服务已推荐

Debian 9 中设置网络

软件及网络 shuodatong 951℃

一、对于有线网络,如果默认没有安装图形界面,进入了 multi-user.target中时,是没有使用NetworkManager管理网络的,此时需要手动配置才能上网

  1. 首先得到网卡名称:ip addr or ls /sys/class/net/,以下假设网卡名为eth0,实际中应替换为自己实际的名称。
  2. 设置文件为:/etc/network/interfaces
    1. 使用DHCP方式,在文件底部添加:
    auto eth0
    allow-hotplug eth0
    iface eth0 inet dhcp
    1. 手动设置IP上网,在文件底部添加:
    auto eth0
    iface eth0 inet static
        address 192.168.0.7
        netmask 255.255.255.0
        gateway 192.168.0.254
  3. 重启网络服务sudo systemctl restart networking.service
    详细的设置方法可以使用man interfaces得到
    也可以参考这里:https://wiki.debian.org/NetworkConfiguration

二、更推荐的作法是使用NetworkManager来管理网络

  1. sudo apt install networkmanager安装NetworkManager包后,命令行中多出两个命令,一个是nmcli纯命令的网络配置工具,一个是nmtui的终端图形配置工具。
  2. 确定在文件/etc/network/interfaces中没有手动配置过网络,即上面一、中配置的内容应该被删除掉。
  3. nmtui打开图形界面,直接配置就好,当然也可以在这里设置无线连接的。
  4. sudo systemctl restart NetworkManager.service重启服务。

转载请注明:Debian 9 中设置网络 - https://shuodatong.com/debian-9-network/

喜欢 (3)