linux单网卡绑定两个IP

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

auto eth0
auto eth0:0
auto eth0:1
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.248

gateway 192.168.1.254


iface eth0:0 inet static address 192.168.1.2

netmask 255.255.255.248


iface eth0:1 inet static address 192.168.1.3

netmask 255.255.255.248


# 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



你可能感兴趣的:(linux,单网卡,两个IP)