打赏

ubuntu虚拟机启用双网卡IP配置

首先要登入自己的虚拟机,这里以ubuntu为例。

配置两块网卡,一块eth0为NAT模式,另一块为eth1仅主机模式

 

# 进入网卡配置页面
vi /etc/network/interfaces
# 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

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.60.202
        netmask 255.255.255.0
        network 192.168.60.0
        broadcast 192.168.60.255
        gateway 192.168.60.2
auto eth1
iface eth1 inet static
        address 192.168.15.202
        netmask 255.255.255.0
        network 192.168.15.0
        broadcast 192.168.15.255
     # 此块网卡不配置网关

然后重启网卡即可

/etc/init.d/networking restart

如果ping不通域名

则需要修改此文件

vim /etc/resolv.conf

修改添加一下内容,即可

search localdomain
nameserver 8.8.8.8

 

posted @ 2020-06-12 07:51  不像话  阅读(1237)  评论(0编辑  收藏  举报