In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "linux virtual machine network configuration and network configuration commands commonly used", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "linux virtual machine network configuration and network configuration commonly used commands"!
I. commands frequently used in linux network configuration
1) # ifconfig / / View the configured Nic / sbin/ifconfig
2) # vi / etc/resolv.conf / / there are four main keywords for modifying DNS resolv.conf, which are:
Nameserver # defines the IP address of the DNS server
Domain # define a local domain name
Search # defines a search list for domain names
Sortlist # sorts the returned domain names
The most important is the nameserver keyword, if you do not specify nameserver, you can not find the DNS server, other keywords are optional.
3) # vi / etc/sysconfig/network / / modify the gateway
NETWORKING=yes (indicates whether the system uses a network, which is generally set to yes. If set to no, the network cannot be used, and many system services will not start)
HOSTNAME=centos (set the hostname of this machine, which corresponds to the hostname set in / etc/hosts)
GATEWAY=192.168.1.1 (sets the IP address of the gateway connected locally. For example, the gateway is 10.0.0.2)
4) # vi / etc/sysconfig/network-scripts/ifcfg-eth0 / / modify Nic configuration
DEVICE=eth0 # describes the device alias corresponding to the Nic, for example, it is eth0 in the file of ifcfg-eth0
BOOTPROTO=static # sets the way the network card obtains the ip address. The possible options are static,dhcp or bootp, corresponding to the statically specified ip address, the ip address obtained through the dhcp protocol, and the ip address obtained through the bootp protocol.
Subnet broadcast address corresponding to BROADCAST=192.168.0.255 #
Physical address of the network card corresponding to HWADDR=00:07:E9:05:E8:B4 #
IPADDR=12.168.1.2 # if you set the way for the Nic to obtain the ip address statically, this field specifies the ip address corresponding to the Nic
IPV6INIT=no
IPV6_AUTOCONF=no
The network mask for the NETMASK=255.255.255.0 # Nic
NETWORK=192.168.1.0 # Network address corresponding to the Nic
ONBOOT=yes # whether to set this network interface when the system starts, and activate this device when the system starts up when it is set to yes. If you only have one network card and set it to no, you will not be able to surf the Internet.
II. Linux virtual machine network configuration (application)
1) using Nat method (simple and practical)
1. Locate the virtual machine device "" network adapter. Double-click to open the network adapter to customize the specified virtual network selection VMnet8 (Nat).
two。 Start the linux virtual machine and enter the linux command line. If you enter the Xwindow interface, please switch to the command line interface ctrl+Alt+Shift+F1
3.#ifconfig to check which network card you use, vi / etc/sysconfig/network-scripts/ifcfg-eth0 to modify the network card configuration. Set up the BOOTPROTO=dhcp. Delete IPADDR, we use automatic acquisition of IP and DNS here. (if it is not clear, please refer to the above (I.4))
4.#service network restart / / restart network. So the linux virtual machine can surf the Internet. Let's test it.
# ping www.baidu.com / / command line input, as long as you can ping it.
2) bridging (abbreviated)
3) adopt host-only (slightly)
three。 Independent linux host Internet access configuration (usually through the router)
1) automatically obtain ip and DNS:
# vi / etc/sysconfig/network / / modify the gateway and delete the GATEWAY, because we use automatic acquisition
# vi / etc/sysconfig/network-scripts/ifcfg-eth0 / / modify the configuration of the Nic
Modify BOOTPROTO=dhcp and delete IPADDR. (if it is not clear, please refer to the above (I.4))
# service network restart / / restart network. Passed the ping test.
2) assign ip to the Internet configuration
# vi / etc/resolv.com / / modify the DNS keyword nameserver=8.8.8.8, which is easy to ignore.
# vi / etc/sysconfig/network / / modify the gateway and add GATEWAY=192.168.1.0 depending on which IP address range you belong to.
# vi / etc/sysconfig/network-scripts/ifcfg-eth0 / / modify the configuration of the Nic
Modify BOOTPROTO=static and add (or set) IPADDR=192.168.1.4. (assign ip address)
# service network restart / / restart network. Passed the ping test.
four。 Summary
Network problems are generally complex and are only configured in a specific environment as mentioned above.
Thank you for your reading. These are the contents of "commands commonly used in network configuration and network configuration of linux virtual machines". After the study of this article, I believe you have a deeper understanding of the commands commonly used in network configuration and network configuration of linux virtual machines, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.