/etc/network/interfacesで1つのNICを手動で設定すると、他のすべてのNICが無効になります。

/etc/network/interfacesで1つのNICを手動で設定すると、他のすべてのNICが無効になります。

ケースシナリオ;ラズベリーパイLinuxv9.1に接続ネットワークRJ45経由:

luis@Fresoncio:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.25.248  netmask 255.255.255.0  broadcast 172.18.25.255
        inet6 fe80::5c59:95e9:c658:8ad2  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:92:fe:b3  txqueuelen 1000  (Ethernet)
        RX packets 24160  bytes 1673645 (1.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1968  bytes 196942 (192.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 4  bytes 156 (156.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 156 (156.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

DHCPから取得したIPは172.18.25.248です。

場合によっては、他のネットワークに接続する必要がある場合があるため、追加します。複数のネットワークカード次のデバイス:

luis@Fresoncio:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.25.248  netmask 255.255.255.0  broadcast 172.18.25.255
        inet6 fe80::5c59:95e9:c658:8ad2  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:92:fe:b3  txqueuelen 1000  (Ethernet)
        RX packets 24160  bytes 1673645 (1.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1968  bytes 196942 (192.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.35.101  netmask 255.255.255.0  broadcast 192.168.35.255
        inet6 fe80::2064:deee:d534:1a83  prefixlen 64  scopeid 0x20<link>
        ether a0:ce:c8:09:f8:84  txqueuelen 1000  (Ethernet)
        RX packets 2378  bytes 177246 (173.0 KiB)
        RX errors 0  dropped 4  overruns 0  frame 0
        TX packets 54  bytes 9354 (9.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.33  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a170:6c36:802a:c19  prefixlen 64  scopeid 0x20<link>
        ether 3c:18:a0:07:63:8b  txqueuelen 1000  (Ethernet)
        RX packets 797  bytes 61728 (60.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 37  bytes 4845 (4.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

...ちょっと待って、
今まではすべて大丈夫です。

これ質問私が来たいとき置く(DHCPまたは静的)IP設定すべてのNIC(例:基本NIC)(常にeth0):

luis@Fresoncio:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

auto eth0
iface eth0 inet dhcp

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

再起動(またはネットワークの再起動)後、eth0アダプタの設定は正しく機能しますが、他のNICは表示されなくなり、動作が停止したようです。

luis@Fresoncio:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.25.248  netmask 255.255.255.0  broadcast 172.18.25.255
        inet6 fe80::5c59:95e9:c658:8ad2  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:92:fe:b3  txqueuelen 1000  (Ethernet)
        RX packets 24160  bytes 1673645 (1.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1968  bytes 196942 (192.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 4  bytes 156 (156.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 156 (156.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

彼らはまだそこにいても広く受け入れられている:

luis@Fresoncio:~$ ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.25.248  netmask 255.255.255.0  broadcast 172.18.25.255
        inet6 fe80::ba27:ebff:fe92:feb3  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:92:fe:b3  txqueuelen 1000  (Ethernet)
        RX packets 1430  bytes 109681 (107.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 194  bytes 33418 (32.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether a0:ce:c8:09:f8:84  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:0e:c6:d4:10:b6  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth3: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 3c:18:a0:07:63:8b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 4  bytes 156 (156.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 156 (156.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

もちろん/etc/network/interfacesリセットに行くこともできますeth1eth2しかし、一つもありません。より実用的などのように?

これは:特定のネットワークカードのIP設定を設定する方法存在する/etc/network/interfaces 行動を変えないこと他の人?

より多くのデータ:

  • Ubuntu v16.04を実行しているデスクトップPCと同じ結果です。

編集01:

一般的なLinuxインストールでは、通常/etc/network/interfacesは次のように検索します。

luis@Fresoncio:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

変更されていないこのソース/etc/network/interfacesファイルでは、すべてのネットワークカードが起動し(私の場合はDHCP)、正しく設定されます。

手動設定eth1などeth2は(一部の場合)実際に問題を解決する方法と見なすことができますが、質問ではそうではありません。問題は、接続されているすべてのNIC(eth9、、、...など)が自動的に起動し、変更されていないファイルで(DHCPとして)設定されwlan3ているように見え、この動作を維持したいと思います。enp2s0/etc/network/interfaces

ベストアンサー1

ifconfig -a認識され、適切なドライバを持つすべてのデバイスが表示されます。

一般ifconfigには、起動して設定されたデバイスのみが表示されます。

ファイルはアダプターとアダプター/etc/network/interfacesのみを構成します。起動時に他のデバイス(など)を設定しないため、そのデバイスをオンラインでインポートして有効にする方法はありません。 (下のファイルで何かをしない限り?)loeth0eth1/etc/network/interfaces.d

/etc/network/interfaces.d/etc/network/interfacesこのように設定できないと仮定すると、eth0はまだDHCPを実行し、デフォルトゲートウェイを提供し、他のデバイスは接続されたゲートウェイなしでそのサブネットにあります。

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
ifact eth1 inet static
   address 192.168.35.101
   netmask 255.255.255.0

auto eth2
ifact eth2 inet static
   address 192.168.1.33
   netmask 255.255.255.0

単一のNICと仮想インターフェイスを使用して同じことを実行できます。

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth0:1
ifact eth0:1 inet static
   address 192.168.35.101
   netmask 255.255.255.0

auto eth0:2
ifact eth0:2 inet static
   address 192.168.1.33
   netmask 255.255.255.0

おすすめ記事