netplanでDNSを設定する

netplanでDNSを設定する

Ubuntuは仮想マシンにインストールされます。リモート会社のリポジトリにアクセスするには、DNSを設定する必要があります。この時点でPINGコマンドを使用すると、次の応答が得られます。

user@ubuntu:~/projects$ ping -c 3 gitlab.companyname.com
PING gitlab.companyname.com (10.0.176.231) 56(84) bytes of data.

--- gitlab.companyname.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2053ms

(会社の実名は「会社名」に置き換えられました。)

I tried to change the file /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.
# 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:
    ethernets:
        ens33:
            dhcp4: true
            nameservers:
              addresses:
                - X.X.X.X
    version: 2

次に、sudo netplan applyコマンドを使用して変更を適用します。

最初の数秒以内にPINGコマンドを使用すると、すべてが正常になります。

user@ubuntu:~/projects$ sudo netplan apply 
user@ubuntu:~/projects$ ping -c 3 gitlab.companyname.com
PING gitlab.companyname.com (10.0.176.231) 56(84) bytes of data.
64 bytes from 10.0.176.231 (10.0.176.231): icmp_seq=1 ttl=62 time=0.877 ms
64 bytes from 10.0.176.231 (10.0.176.231): icmp_seq=2 ttl=62 time=0.723 ms
64 bytes from 10.0.176.231 (10.0.176.231): icmp_seq=3 ttl=62 time=0.778 ms

--- gitlab.companyname.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2015ms
rtt min/avg/max/mdev = 0.723/0.792/0.877/0.071 ms

しかし、問題は、約10秒が経過すると接続が再び切断されることです。

user@ubuntu:~/projects$ ping -c 3 gitlab.companyname.com
PING gitlab.companyname.com (10.0.176.231) 56(84) bytes of data.

--- gitlab.companyname.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2025ms

ベストアンサー1

おすすめ記事