1. 程式人生 > 實用技巧 >Ubuntu16.04網絡卡配置

Ubuntu16.04網絡卡配置

新安裝的Ubuntu16.04系統容易出現無法連線有線網路的問題,主要是因為網絡卡配置不完善,下面通過實操講解如何解決該問題。

1. 檢視網路裝置

ifconfig

發現只有enp2s0lo,沒有eth0,一般Linux有線網路使用的是eth0網絡卡進行網路連線。

2. 修改網絡卡為eth0

sudo vim /etc/default/grub

找到GRUB_CMDLINE_LINUX=""
改為GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
然後sudo grub-mkconfig -o /boot/grub/grub.cfg
重啟,執行ifconfig可以看到,網絡卡名即變成了eth0和wlan0

3. 設定eth0網絡卡的連線方式

開啟ubuntu的/etc/network/interfaces檔案預設的內容如下:

auto lo 
iface lo inet loopback 

在後面新增內容

(1)獲取動態配置:

auto eth0 
iface eth0 inet dhcp 

(2)獲取靜態配置:

auto eth0
iface eth0 inet
static address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.1

重啟,再一次執行ifconfig,可以看到eth0網絡卡已經有inet addr、Bcast、Mask、inet6 addr等ip地址。

參考資料

[1]ubuntu16.04配置網絡卡[https://blog.csdn.net/stay_zezo/article/details/80718369]
[2]Ubuntu網絡卡服務重新啟動,設定 DNS和主機名[https://jingyan.baidu.com/article/9113f81b7995df2b3214c702.html]
[3]ubuntu16.04修改網絡卡名稱enp2s0為eth0[http://www.voidcn.com/article/p-dcdiwcqz-xe.html]