Linux

無法啟動提升網路介面。Hyper-V Ubuntu 伺服器

  • June 20, 2019

我在 Hyper-V 中執行 Ubuntu 虛擬機。在啟動過程中,出現無法啟動網路的錯誤。

osis@projmngsys:~$ sudo systemctl status networking
● networking.service - Raise network interfaces
  Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
 Drop-In: /run/systemd/generator/networking.service.d
          └─50-insserv.conf-$network.conf
  Active: failed (Result: exit-code) since Вт 2019-06-18 20:25:45 MSK; 14min ago
    Docs: man:interfaces(5)
 Process: 794 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
 Process: 778 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --lis
Main PID: 794 (code=exited, status=1/FAILURE)

июн 18 20:25:44 projmngsys systemd[1]: Starting Raise network interfaces...
июн 18 20:25:45 projmngsys ifup[794]: RTNETLINK answers: File exists
июн 18 20:25:45 projmngsys ifup[794]: Failed to bring up eth0.
июн 18 20:25:45 projmngsys systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
июн 18 20:25:45 projmngsys systemd[1]: Failed to start Raise network interfaces.
июн 18 20:25:45 projmngsys systemd[1]: networking.service: Unit entered failed state.
июн 18 20:25:45 projmngsys systemd[1]: networking.service: Failed with result 'exit-code'.

[2]+  Stopped                 sudo systemctl status networking

裡面 sudo nano /etc/network/interfaces 我有:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

auto eth0
iface eth0 inet static
address 192.168.1.69
#netmask 255.255.0.0
#gateway 192.168.1.254
#dns-nameservers 8.8.8.8 8.8.4.4 192.168.1.254
#dns-search google.com

對此,問題是如何一步步配置Ubuntu和Hyper-V,讓Internet和SSH在其中工作。

ps

osis@projmngsys:~$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
   link/ether 00:15:5d:64:26:04 brd ff:ff:ff:ff:ff:ff

osis@projmngsys:~$ sudo lshw -C network | grep name
      logical name: eth0

osis@projmngsys:~$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:15:5d:64:26:04
         inet addr:192.168.1.69  Bcast:192.168.1.255  Mask:255.255.255.0
         inet6 addr: 2a00:1370:8125:dfcc:215:5dff:fe64:2604/64 Scope:Global
         inet6 addr: fda5:efaf:2260:1:215:5dff:fe64:2604/64 Scope:Global
         inet6 addr: fe80::215:5dff:fe64:2604/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:7082 errors:0 dropped:0 overruns:0 frame:0
         TX packets:4055 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:1053006 (1.0 MB)  TX bytes:4096922 (4.0 MB)

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:203528 errors:0 dropped:0 overruns:0 frame:0
         TX packets:203528 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1
         RX bytes:180782039 (180.7 MB)  TX bytes:180782039 (180.7 MB)

osis@projmngsys:~$ sudo nano /etc/resolv.conf -文件清除

osis@projmngsys:~$ sudo nano /etc/hosts
127.0.0.1       localhost

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

osis@projmngsys:~$ sudo journalctl -xe
sudo: unable to resolve host projmngsys
-- Результат: failed.
июн 18 21:13:53 projmngsys systemd[1]: networking.service: Unit entered failed state.
июн 18 21:13:53 projmngsys systemd[1]: networking.service: Failed with result 'exit-code'.
июн 18 21:13:53 projmngsys sudo[1813]: pam_unix(sudo:session): session closed for user root
июн 18 21:13:59 projmngsys sudo[1921]:     osis : unable to resolve host projmngsys
июн 18 21:13:59 projmngsys sudo[1921]:     osis : TTY=pts/0 ; PWD=/home/osis ; USER=root ; COMMAND=/bin/systemctl start networking
июн 18 21:13:59 projmngsys sudo[1921]: pam_unix(sudo:session): session opened for user root by osis(uid=0)
июн 18 21:13:59 projmngsys systemd[1]: Starting Raise network interfaces...
-- Subject: Начинается запуск юнита networking.service
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Начат процесс запуска юнита networking.service.
июн 18 21:13:59 projmngsys ifup[1932]: RTNETLINK answers: File exists
июн 18 21:13:59 projmngsys ifup[1932]: Failed to bring up eth0.
июн 18 21:13:59 projmngsys systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
июн 18 21:13:59 projmngsys sudo[1921]: pam_unix(sudo:session): session closed for user root
июн 18 21:13:59 projmngsys systemd[1]: Failed to start Raise network interfaces.
-- Subject: Ошибка юнита networking.service
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Произошел сбой юнита networking.service.
--
-- Результат: failed.
июн 18 21:13:59 projmngsys systemd[1]: networking.service: Unit entered failed state.
июн 18 21:13:59 projmngsys systemd[1]: networking.service: Failed with result 'exit-code'.
июн 18 21:14:11 projmngsys sudo[1995]:     osis : unable to resolve host projmngsys
июн 18 21:14:11 projmngsys sudo[1995]:     osis : TTY=pts/0 ; PWD=/home/osis ; USER=root ; COMMAND=/bin/journalctl -xe
июн 18 21:14:11 projmngsys sudo[1995]: pam_unix(sudo:session): session opened for user root by osis(uid=0)

/etc/network/interfaces.d/ - clear

我同時遇到了幾個問題。Docker刪除後留下了垃圾,我執行了命令:

apt remove --purge ubuntu-fan
sudo apt autoremove

接下來,我清理了 Samba 共享文件刪除了掛載設置

sudo nano /etc/fstab

正確地將主機名寫入文件

hostname

我將生成的名稱添加到文件中

sudo nano /etc/hosts

我在文件開頭添加了主機資訊:

127.0.0.1 MYHOSTNAME

在文件中,我將所有內容都恢復為標准設置

sudo nano /etc/network/interfaces

我意識到您需要仔細閱讀錯誤文本並始終如一地解決這些錯誤。為此,我閱讀了中的資訊

sudo journalctl -xe

sudo systemctl status networking

仔細閱讀文本的錯誤資訊有很多,感謝大家的幫助。

引用自:https://serverfault.com/questions/971946