準(zhǔn)備工作
安裝好系統(tǒng)之后,檢查gcc和make是否已經(jīng)安裝
$ which gcc
/usr/bin/gcc
$ which make
/usr/bin/make
如果未安裝,則安裝gcc和make
$ apt install gcc
$ apt install make
安裝openssh-server
$ apt install openssh-server
安裝網(wǎng)絡(luò)工具和防火墻
$ apt install net-tools
$ apt install ufw
開通端口
$ ufw allow 22
一、有線網(wǎng)卡不可用
準(zhǔn)備設(shè)置靜態(tài)IP時,發(fā)現(xiàn)沒有有線網(wǎng)卡,無法正常插網(wǎng)線進行聯(lián)網(wǎng)。
執(zhí)行ipconfig 查看網(wǎng)卡配置是否有ethxx
或者enxx
,也沒有,則說明有線網(wǎng)卡的驅(qū)動需要更新。
前往Intel官網(wǎng)下載驅(qū)動 , 選擇3.8.4版本下載, 然后將下載的軟件e1000e-3.8.4.tar.gz通過U盤拷貝到服務(wù)器。
解壓e1000e-3.8.4.tar.gz安裝包文件
$ tar -zxvf e1000e-3.8.4.tar.gz
或者
$ gunzip e1000e-3.8.4.tar.gz
$ tar xvf e1000e-3.8.4.ta
編譯有線網(wǎng)卡驅(qū)動
$ cd e1000e-3.8.4/src
$ sudo make
*** disabled for this build.
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-142-generic'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-142-generic'
安裝有線網(wǎng)卡驅(qū)動
$ sudo make install
*** The target kernel has CONFIG_MODULE_SIG_ALL enabled, but
*** the signing key cannot be found. Module signing has been
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-142-generic'
Running depmod...
啟用有線網(wǎng)卡啟動,如果沒有報錯,正常情況下可以看到有線網(wǎng)卡已經(jīng)正??捎昧恕?/p>
$ sudo modprobe e1000e
如果遇到modprobe: ERROR: could not insert ‘e1000e’: Required key not available
,這是因為從內(nèi)核4.4.0-20
開始啟用EFI_SECURE_BOOT_SIG_ENFORCE
編譯選項,如果啟用UEFI Secure Boot
,將禁止加載未簽名的第三方驅(qū)動。
重啟電腦,按ESC進Blos-->secuity-->secure boot-->enabled
,重新進入系統(tǒng),以太網(wǎng)正常連接。
二、無法訪問外網(wǎng)
服務(wù)器上部署了docker鏡像后,調(diào)用接口提示無法訪問外網(wǎng),去服務(wù)器上查看,確實無法ping通百度。
$ ping www.baidu.com
ping: www.baidu.com: 未知的名稱或服務(wù)
修改并應(yīng)用網(wǎng)口信息,并重啟網(wǎng)絡(luò)
$ vim /etc/network/interfaces
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eno1
iface eno1 inet static
address 192.168.248.142
gateway 192.168.248.254
netmask 255.255.255.0
dns-nameserver 192.168.42.161
dns-nameserver 8.8.8.8
$ netplan apply
$ systemctl restart networking
再次ping百度還是不同
$ ping www.baidu.com
ping: www.baidu.com: 未知的名稱或服務(wù)
查看域名解析配置文件,發(fā)現(xiàn)里面的nameserver和我們的dns配置不一致。
$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0
修改域名解析配置文件如下,保存并退出
$ vim /etc/resolv.conf
nameserver 192.168.42.161
options eno1
再次ping百度,成功。
$ ping www.baidu.com
PING www.a.shifen.com (183.2.172.42) 56(84) bytes of data.
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=1 ttl=51 time=7.02 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=2 ttl=51 time=7.06 ms
^C
--- www.a.shifen.com ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 9079ms
rtt min/avg/max/mdev = 6.393/7.012/8.473/0.798 ms
如果你的docker鏡像啟動的時候network_mode
選擇的是host
,則還需要重啟一次容器,否則程序還是不能訪問到外網(wǎng)。
三、軟件下載慢
安裝系統(tǒng)完畢,網(wǎng)絡(luò)設(shè)置正常后一般都需要執(zhí)行對系統(tǒng)軟件進行更新、升級、安裝
$ apt-get update
$ apt-get upgrade -y
$ apt-get -f install
如果下載特別慢,就需要考慮替換軟件源為國內(nèi)的源。
查看原有的源列表文件
$ cat /etc/apt/sources.list
備份源文件
$ cd /etc/apt
$ cp sources.list sources.list.back
修改源文件文章來源:http://www.zghlxwxcb.cn/news/detail-824037.html
$ vim sources.list
##阿里云源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
保存源文件后,重新執(zhí)行更新操作。文章來源地址http://www.zghlxwxcb.cn/news/detail-824037.html
到了這里,關(guān)于ubuntu 18.04網(wǎng)絡(luò)問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!