歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> VirtualBox安裝Ubuntu後的靜態ip配置

VirtualBox安裝Ubuntu後的靜態ip配置

日期:2017/2/28 13:49:17   编辑:Linux教程

1、VirtualBox安裝完Ubuntu後,默認應該是開啟一塊網卡,連接方式根據宿主電腦的連接方式來(如果物理機是通過有線上網,那麼需要使用NAT網絡連接方式,如果是無線網絡,那麼需要使用橋接方式上網),該網卡負責虛擬機的上網。

2、添加一塊網卡,連接方式選擇僅主機(Host-Only)適配器。

3、進入ubuntu系統,執行ifconfig -a,查看當前網卡信息,根據HWaddr字段查看是否和VirtualBox裡面看到的兩個網卡對應

ifconfig -a
enp0s3 Link encap:Ethernet HWaddr 08:00:25:59:f2:aa
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe59:f2aa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17 errors:0 dropped:0 overruns:0 frame:0
TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2619 (2.6 KB) TX bytes:2625 (2.6 KB)

enp0s8 Link encap:Ethernet HWaddr 08:00:25:45:a1:25
inet addr:192.168.10.11 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe45:a125/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:765 errors:0 dropped:0 overruns:0 frame:0
TX packets:533 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:74156 (74.1 KB) TX bytes:86182 (86.1 KB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:77 errors:0 dropped:0 overruns:0 frame:0
TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:34601 (34.6 KB) TX bytes:34601 (34.6 KB)

4、可以看到enp0s8是我們添加的Host-Only網卡信息,上面已經是配置好後的信息,已經有了靜態ip了。如果沒有配置的情況下,是看不到相應的ip信息。

5、開始配置靜態ip

sudo vim /etc/network/interfaces

auto enp0s8
iface enp0s8 inet static
address 192.168.10.11
netmask 255.255.255.0

sudo /etc/init.d/networking restart

這裡已經配置好了靜態ip

6、配置dns服務

sudo vim /etc/resolv.conf

添加
nameserver 223.5.5.5(這裡填寫一個公共dns解析ip地址)
sudo /etc/init.d/networking restart

到這裡差不多是可以了,如果還是不行,可以重啟(萬能操作)試一下。

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved