The virtual machine Ubuntu18.04 can be connected to the Internet by modifying the static ip (professional test is feasible)

The virtual machine Ubuntu18.04 can be connected to the Internet by modifying the static ip (professional test is feasible)

In recent days, three Ubuntu 18.04 machines have been built using VMware, and many services in the big data ecosystem have been built, including Hadoop HA, Hive, Zookeeper, Kafka, and the rookie Flink of stream processing. But just one day after it was built, I turned it on again and found that the cluster was not connected. It turned out that the static ip was not configured, and the static ip setting of this version of Ubuntu18.04 is different from other versions, so I also looked for it at that time. Many articles are fruitless. In the end, it was a combination of two or three articles before the configuration was successful. It has a static ip and can be connected to the Internet. Let's talk about the configuration method. Friends who have the same problem can learn from it.

First you need to configure the network of the virtual machine

In the VMware virtual machine, find Edit – “Virtual Machine Network Editor –” Change Settings – “Select the network card whose VMnet8 network mode is NAT – “Uncheck Use local DHCP service to assign IP addresses to virtual machines.
insert image description here
insert image description here
Finally, click Apply. You also need to check the subnet mask and gateway ip of the current network. In the virtual network editor window, select the network card whose network mode is NAT in VMnet8 – "NAT settings.
insert image description here
insert image description here
These two information will be used when configuring Ubuntu static ip later.

configure static ip

First use the ifconfig command to view the information about the network card currently in use. The following ens33 is the name of the network card, which will be used in the following configuration.
insert image description here
Use the following command to open the file, if vim is not installed, you can also use vi to write.

sudo vim /etc/network/interfaces

Configured in the file as follows:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# ens33使用ifconfig查看到的网卡名称
auto ens33
iface ens33 inet static
# 想要设置成的静态ip
address 192.168.79.128
# 子网掩码
netmask 255.255.255.0
# 网关
gateway 192.168.79.2

Configure DNS

Open the file with

sudo vim /etc/systemd/resolved.conf

The file configuration is as follows:

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
# 这里使用的DNS为阿里的DNS
DNS=223.5.5.5
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

Remember to save and exit the above file after editing,
and finally restart the machine.

test

Since the above mine is already a screenshot of successful configuration, the ip queried by ifconfig is the same as the static ip set.
Start the test below: first use ifconfig to check whether the current ip address is the ip address configured by yourself:
insert image description here
then use the ping command to test whether you can connect to the network:
insert image description here
the connection is successful
OK! So far, the static ip of Ubuntu 18.04 has been configured successfully. If it helps you, please give me a thumbs up.

Guess you like

Origin blog.csdn.net/wFitting/article/details/106936283