linux 单网卡绑定两个ip

#vi /etc/network/interfaces
OR
$ sudo vi /etc/network/interfaces
Modify as follows:

 1 auto eth0
 2 auto eth0:0
 3 auto eth0:1
 4 iface eth0 inet static
 5 address 192.168.1.1
 6 netmask 255.255.255.248
 7 gateway 192.168.1.254
 8 
 9 iface eth0:0 inet static
10 address 192.168.1.2
11 netmask 255.255.255.248
12 
13 iface eth0:1 inet static
14 address 192.168.1.3
15 netmask 255.255.255.248
16 
17 # add rest of alias / binds below

Save and close the file.

Now restart networking, enter:
# /etc/init.d/networking restart
OR
$ sudo /etc/init.d/networking restart

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。