目录
最近也慢慢的从 Centos 转到 Debian,两者的系统网卡配置文件有很大的区别,故记录一下,防止自己搞错(草)
系统环境 : Debian 11
网卡配置文件 : /etc/network/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 auto [Interface Name] iface [Interface Name] inet static address [Your IPv4 addr] gateway [Your IPv4 GW] dns-nameservers [DNS Server 1],[DNS Server 2] iface [Interface Name] inet6 static address [Your IPv6 addr] gateway [Your IPv6 GW] dns-nameservers [DNS Server 1],[DNS Server 2] iface [Interface Name] inet dhcp #网卡DHCP的配置
其中 auto 也可以替换成 allow-hotplug ,这两者的区别在于
如果设置的是auto,不管你插不插网线,网卡都会启用,而且运行systemctl restart networking.service 之后网卡能自动启动
如果设置的是allow-hotplug,它会在开机时启动插网线的网卡,运行 systemctl restart networking.service 之后网卡不能自动重启
网关,DNS其实都是可选项,没有就不填了(适用于IXP interface)
address 项 可以写 10.0.0.1/24 ,也可以只写 10.0.0.1 ,那就需要再加一项 netmask 255.255.255.0 (/24) , IPv6 同理 /48 = netmask 48
新建网卡/隧道配置
auto lo iface lo inet loopback auto eth10 iface eth10 inet6 static address [Your IPv6 addr] # --- BEGIN PVE --- post-up ip route add [Your IPv6 addr] dev eth10 post-up ip route add [Your IPv6 addr] dev eth10 pre-down ip route del default via [Your IPv6 addr] dev eth10 pre-down ip route del [Your IPv6 addr] dev eth10 # --- END PVE --- post-up ip route del default via [Your IPv6 addr] dev eth10 post-up ip route add default via [Your IPv6 addr] dev eth10 metric 1 post-up ip -6 rule add priority 100 from [Your IPv6 addr] table 254 post-up ip -6 rule add priority 199 from all table 101 pre-down ip -6 rule del priority 100 pre-down ip -6 rule del priority 199 iface tpl-dummy inet manual pre-up ip link add $IFACE type dummy post-down ip link del $IFACE up ip link set $IFACE up down ip link set $IFACE down iface tpl-ip6gre inet manual pre-up ip link add $IFACE type ip6gre post-down ip link del $IFACE up ip link set $IFACE up mtu 1456 down ip link set $IFACE down auto [Test 1] iface [Test 1] inet manual inherits tpl-dummy up ip addr add dev $IFACE [Your IPv6 addr] auto [Test 2] iface [Test 2] inet tunnel requires eth10 mode ip6gre address [Your IPv6 addr] netmask 112 endpoint [Your IPv6 addr] local [Your IPv6 addr] #pre-up modprobe ip6_gre pre-up ip -6 route add [Your IPv6 addr] via [Your IPv6 addr] dev eth10 || true ttl 255 mtu 1448