Change Network of Debian.md

有时候我们希望修改默认的 ip 地址以及 DNS 服务器,来获得更好的网络。

对 Debian 来说,修改两个文件,一个是/etc/network/interfaces,另一个是/etc/resolv.conf

对于interfaces来说

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens18
iface ens18 inet static
address 192.168.2.35
netmask 255.255.255.0
gateway 192.168.2.60

在网关是192.168.2.60的时候;

如果还需要配置 DNS,修改 /etc/resolv.conf

nameserver 192.168.2.60

禁止ipv6

/etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1

别忘了重启网络:systemctl restart networking.


也可以看看