# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5)。
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static //配置eth0使用默认的静态地址
address 192.168.77.133 //设置eth0的IP地址
netmask 255.255.255.0 //配置eth0的子网掩码
gateway 192.168.77.254 //配置当前主机的默认网关
“interfaces”文件中还有很多其他的设置项,如需要了解更多的信息,可以使用man命令查询“interfaces”文件的手册页。
#man interfaces
其中eth0指本机以太网卡一,类似的,eth1指本机的以太网卡2。一般一台电脑只有一个eth0。网卡的设备名/dev/eth0 和硬件的MAC 地址52:54:AB:DD:6F:61对应,MAC 地址是生产厂家定的,每个网卡拥有的唯一地址。
linux下,用ifconfig后,能看到eth0,可能还会看到eth0:1。其中eth0:1是指eth0的分ip存储文件,分ip存储文件格式为ifcfg-eth0:X, X为任意正整数(包括0)
具体作用是实现单网卡多ip,类似与windows的多ip。
1、首先,用 ifconfig 命令查询是否存在eth0网卡
2、vi /etc/sysconfig/network-scripts/ifcfg-eth0 编辑ifcfg-eth0文件,如图:
加上以下配置:
然后,wq 保存编辑。
3、service network restart 重启网卡
4、再用ifconfig命令查询,如图:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)