Skip to main content

/etc/network


/etc/network 是 Debian 体系里“老一代网络配置”的地盘,主要给 ifupdown 用的, 和 netplan / systemd-networkd 是不同年代、不同体系的东西。


Examples

post-up 是静态路由,eth1 是三线接口。

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.x.x/28
    config_netfail off
    is_hotplugged off
    post-up ip route add 192.168.0.0/16 via 192.168.x.x
    pre-down ip route del 192.168.0.0/16 via 192.168.x.x

auto eth1
iface eth1 inet static
    address x.x.x.x/24
    config_netfail off
    is_hotplugged off
    post-up route add default gw x.x.x.x || true
    pre-down route del default gw x.x.x.x || true

# control-alias eth1
iface eth1 inet static
    address x.x.x.x/24

# control-alias eth1
iface eth1 inet static
    address x.x.x.x/24

Restart Interface

ifdown eth0 && ifup eth0