브리지를 갖도록 네트워크로 연결된 우분투 시스템을 구성하려고 하지만 인터넷을 볼 수 없습니다

브리지를 갖도록 네트워크로 연결된 우분투 시스템을 구성하려고 하지만 인터넷을 볼 수 없습니다

내 목표문제는 인터넷과 통신할 수 있는 여러 nspawn 컨테이너를 가질 수 있도록 머신을 구성하는 것입니다. 호스트는 인터넷과 통신할 수 있어야 하며 호스트에서 IP를 통해 컨테이너에 연결할 수 있어야 합니다. 컨테이너는 웹 서버를 실행합니다.

질문문제는 구성은 괜찮은 것 같은데, 인터넷에서 컴퓨터로 ping을 할 수 없고, 컴퓨터에 로그인해도 인터넷 통신이 안 된다는 겁니다.

질문:인터넷과 통신하도록 어떻게 구성합니까?

이것은 Oracle Cloud에서 실행되는 가상 머신이며 다음과 같습니다.

공용 IPv4 주소: 192.9.139.126 개인 IPv4 주소: 10.0.0.214

netplan 구성에서 systemd 네트워크 파일을 사용하는 구성으로 변경하려고 합니다.

다음 네트워크 계획 구성은 정상적으로 작동합니다.

ubuntu@instance-20240106-1821:~$ cat /etc/netplan/50-cloud-init.yaml 
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        ens3:
            dhcp4: true
            match:
                macaddress: 02:00:17:00:2a:9c
            set-name: ens3
ubuntu@instance-20240106-1821:~$ 

하지만 이제 위 기능을 비활성화하고 시스템 네트워크 구성을 통해 구현했으므로 인터넷과 통신할 수 없습니다.

내 네트워크 구성은 다음과 같습니다.

ubuntu@instance-20240106-1821:~$ cat /etc/systemd/network/br0.network

[Match]
Name=br0

[Network]
DHCP=no
Address=10.0.0.214/24
Gateway=10.0.0.1

ubuntu@instance-20240106-1821:~$ cat /etc/systemd/network/br0.netdev

[NetDev]
Name=br0
Kind=bridge

[Bridge]
MACAddress=02:00:17:00:2a:9c

ubuntu@instance-20240106-1821:~$ cat /etc/systemd/network/ens3.network

[Match]
Name=ens3

[Network]
Bridge=br0

ubuntu@instance-20240106-1821:~$ sudo networkctl status ens3

● 2: ens3                                                                      
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/ens3.network
                          Type: ether
                         State: enslaved (configured)
                  Online state: online                                         
             Alternative Names: enp0s3
                          Path: pci-0000:00:03.0
                        Driver: virtio_net
                        Vendor: Red Hat, Inc.
                         Model: Virtio network device
                    HW Address: 02:00:17:00:2a:9c
                           MTU: 9000 (min: 68, max: 65535)
                         QDisc: pfifo_fast
                        Master: br0
  IPv6 Address Generation Mode: none
          Queue Length (Tx/Rx): 1/1
              Auto negotiation: no
                         Speed: n/a
             Activation Policy: up
           Required For Online: yes

Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: ens3: Link UP
Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: ens3: Gained carrier
Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: ens3: Gained IPv6LL

ubuntu@instance-20240106-1821:~$ sudo networkctl status br0

● 3: br0                                                                       
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/br0.network
                          Type: bridge
                         State: routable (configured)
                  Online state: online                                         
                        Driver: bridge
                    HW Address: 5e:37:61:dc:ab:83
                           MTU: 9000 (min: 68, max: 65535)
                         QDisc: noqueue
  IPv6 Address Generation Mode: eui64
                 Forward Delay: 15s
                    Hello Time: 2s
                       Max Age: 20s
                   Ageing Time: 5min
                      Priority: 32768
                           STP: no
        Multicast IGMP Version: 2
                          Cost: 2000
                    Port State: disabled
          Queue Length (Tx/Rx): 1/1
              Auto negotiation: no
                         Speed: n/a
                       Address: 10.0.0.214
                                fe80::5c37:61ff:fedc:ab83
                       Gateway: 10.0.0.1
             Activation Policy: up
           Required For Online: yes
             DHCP6 Client DUID: DUID-EN/Vendor:0000ab110e53ac1395c0e1110000

Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: br0: netdev ready
Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: br0: Link UP
Jan 06 08:59:09 instance-20240106-1821 systemd-networkd[526]: br0: Gained carrier
Jan 06 08:59:11 instance-20240106-1821 systemd-networkd[526]: br0: Gained IPv6LL
ubuntu@instance-20240106-1821:~$ 

IP 하나

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 02:00:17:00:2a:9c brd ff:ff:ff:ff:ff:ff
    altname enp0s3
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP group default qlen 1000
    link/ether 5e:37:61:dc:ab:83 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.214/24 brd 10.0.0.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::5c37:61ff:fedc:ab83/64 scope link 
       valid_lft forever preferred_lft forever
ubuntu@instance-20240106-1821:~$ 

답변1

[NetDev]
Name=br0
Kind=bridge

[Bridge]
MACAddress=02:00:17:00:2a:9c

MACAddress=해당 [NetDev]부분만 기록되며 파일 [Bridge]의 일부는 기록되지 않습니다 *.netdev. 또는 [Link]파일에 섹션을 추가하여 br0.network내부에 넣을 수도 있습니다.

현재는 무시되는 것으로 보이며 브리지가 생성된 MAC 주소를 가져오는 중입니다.

● 3: br0                                                                       
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/br0.network
                          Type: bridge
                         State: routable (configured)
                  Online state: online                                         
                        Driver: bridge
                    HW Address: 5e:37:61:dc:ab:83   <---!!!

따라서 파일을 다음과 같이 변경해야 합니다 br0.netdev.

[NetDev]
Name=br0
Kind=bridge
MACAddress=02:00:17:00:2a:9c

[Bridge]

또는 파일 MacAddress=02:00:17:00:2a:9c에서 해당 행을 완전히 제거 하고 파일의 다음 섹션 br0.netdev에 배치 할 수 있습니다 .br0.network[Link]

[Match]
Name=br0

[Link]
MACAddress=02:00:17:00:2a:9c

[Network]
DHCP=no
Address=10.0.0.214/24
Gateway=10.0.0.1

답변2

마지막으로 문제는 DHCP=yes여야 한다는 것입니다.

br0.net을 다음으로 변경하세요:

[Match]
Name=br0

[Network]
DHCP=yes
#Address=10.0.0.214/24
#Gateway=10.0.0.1
DNS=8.8.8.8

[Link]
MACAddress=02:00:17:00:4a:bc

나는 가지고있다:

IP 하나

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 02:00:17:00:4a:bc brd ff:ff:ff:ff:ff:ff
    altname enp0s3
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP group default qlen 1000
    link/ether 02:00:17:00:4a:bc brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.209/24 metric 1024 brd 10.0.0.255 scope global dynamic br0
       valid_lft 86351sec preferred_lft 86351sec
    inet6 fe80::17ff:fe00:4abc/64 scope link
       valid_lft forever preferred_lft forever

이봐, 어서:

ubuntu@instance-20240106-2021:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=61 time=1.72 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=61 time=1.75 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=61 time=1.74 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=61 time=1.78 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=61 time=1.75 ms
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 1.718/1.746/1.775/0.018 ms
ubuntu@instance-20240106-2021:~$

관련 정보