Debian设置静态IP和多IP

debian12 例子

# 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 ens33
iface ens33 inet static
	address 172.16.13.234
	netmask 255.255.240.0
	gateway 172.16.0.1
	dns-nameservers 223.5.5.5
iface ens33 inet static 
#static表示使用固定ip,dhcp表述使用动态ip

address 192.168.1.100 
#设置ip地址 【为ipconfig中地址一致,最后一位端口改前ping一下确定端口没人用】

netmask 255.255.255.0 
#设置子网掩码

gateway 192.168.1.1 
#设置网关

nameserver 8.8.8.8
nameserver 119.29.29.29

auto ens33:1
iface ens33:1 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
nameserver 8.8.8.8
nameserver 119.29.29.29

保存后重启网卡或者重启系统

配置DNS

vim /etc/resolv.conf

nameserver 8.8.8.8
nameserver 119.29.29.29
sanradar
sanradar
文章: 103