Linux CentOS 7 IP address configuration and network troubleshooting

Source: Internet
Author: User
Tags network troubleshooting

One, Linux CentOS 7 IP address configuration

Enter the command "Ifconfig" To view the native IP address.
[[Email protected] ~]# ifconfig    ens33: flags=4163<up,broadcast, running,multicast>  mtu 1500        inet  192.168.42.170  netmask 255.255.255.0  broadcast      192.168.42.255        ether 00:0c:29:36:d5:9f   txqueuelen 1000   (Ethernet)         rx packets  40378  bytes 27958358  (26.6&NBSP;MIB)          RX errors 0  dropped 0  overruns 0  frame 0         TX packets 36113  bytes 27437301  (26.1 &NBSP;MIB)         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
If the following interface prompt appears:
[Email protected] ~]# ifconfig-bash:ifconfig:comment not found
Because there is no package Net-tools installed for the package, you can install it by using the following command:
Yum Install-y Net-tools
Because you cannot surf the Internet, you must solve the Internet problem to run the "Yum install-y net-tools" command to install.
The following steps to solve the Internet problem: 1. If you cannot view the IP with the ifconfig command, you can view it through IP Add.
[[email protected] ~]# ip add1: lo: <loopback,up,lower_up> mtu  65536 qdisc noqueue state unknown qlen 1    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 forever2: ens33: <broadcast, multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000     link/ether 00:0c:29:36:d5:9f brd ff:ff:ff:ff:ff:ff     inet 192.168.42.170/24 brd 192.168.42.255 scope global enp0s18        valId_lft forever preferred_lft forever 
 If there is only one "Lo"   in the network card found, there is no network card similar to the ENS33 name, as follows: 
[[email protected] ~]# ip add1: lo: <loopback,up,lower_up> mtu  65536 qdisc noqueue state unknown qlen 1    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 

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/E95546A94D2D455BB3A755644DCE73FD?method= DOWNLOAD&SHAREKEY=33ADE3C3F2E42DEA1B575A68A25211A1 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

Workaround:

View this virtual machine configuration information: Locate the virtual machine storage location is F:\Virtual machines\centos-7.3-01\

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/E1DB626651074C59B56FBF649AB56602?method= Download&sharekey=14e26b89ee61be1be5c65f5172a34a34 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/BB3EFC3300BA495BB7A278E84B300CCD?method= DOWNLOAD&SHAREKEY=1B9A846A2060DE929389A556B6F0BCDE "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

Go to directory: Locate the Centos-7.3-01.vmx file, open it in Notepad, and edit it. Join the next line: Ethernet0.virtualdev = "e1000"

650) this.width=650; "Src=" Http://note.youdao.com/yws/api/personal/file/26F17714176C4B88911FD57D1839A4C4?method =download&sharekey=91b64713fd98ce37d30b3eca2e291ed8 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/7D109E45771349A79C419895B777DF61?method= Download&sharekey=b029654a3e91046ec0428eb6e38229a6 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

Save.    Restart the virtual machine. Enter the system: and then enter the "IP Add", after the discovery of more than a piece of ENS33 network card. Then enter the "dhclient" command to obtain the IP address automatically.

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/DFE9487FD7FA4BAEA469BBF269E7D7B3?method= Download&sharekey=fd046932c0b298565941acb5e2ae18e6 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

Enter "IP Add" and ping www.qq.com to test. See if you can surf the Internet.

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/6633BE57725E421D89EE095BF3C959D1?method= download&sharekey=67d5dd6b0885908d762c4c0eb6d6e678 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

2. Configure the network card static IP address.
To solve the problem of Internet access, if the next restart of the network card address may change, this requires the configuration of a static IP address. To edit the network card profile, the configuration file can appear without the image, if there is no configuration file, directly edit a configuration file can be.
Vi/etc/sysconfig/network-scripts/ifcfg-ens33
Press the "I" key again to add the following:
device=ens33name=ens33onboot=yesbootporo=staticipaddr=192.168.42.180netmask=255.255.255.0gateway= 192.168.42.1dns1=8.8.8.8
Enter ": Wq" to save the exit. Restart the NIC service to see if it works:
Systemctl Restart Network.service
Finally, you can restart the virtual machine for testing.
3.yum Mounting Net-tools
Yum Install-y Net-tools
The ifconfig command can be used when the installation is complete.
Second, troubleshoot network problems ping www.qq.com hint connect:network is unreachable1. NAT is unable to surf the internet, switch bridge mode to try.

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/1B31D364AA584F1E8DCD65A5CB9E3AEF?method= download&sharekey=77e93dbc57fc8465965f6dfb756a453d "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

2. Dhclient-r kills the dhclient process and automatically acquires an IP address again. 3. Virtual machine configuration IP and PC host on the same network segment:
Enter CMD in the Start Menu "Run" of Windows and enter the IP address of the Ipconfig PC host. Configure the virtual machine to the same network segment IP to be able to surf the Internet.

650) this.width=650; "Src=" Http://note.youdao.com/yws/api/personal/file/ED7228C074494F6B931AEB6A7EF60574?method =download&sharekey=9c3a39e8e7c7186145bec4fc5aaebf43 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

650) this.width=650; "Src=" Http://note.youdao.com/yws/api/personal/file/9EBF61D12A1D4BF48C8905B7E4922EC4?method =download&sharekey=bdca3b7268ed01d611680a53d4c44a73 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/445FD416BA3147ED850FB47469687121?method= Download&sharekey=bbccba304a41e8e7a87dd90226b80b17 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

4. Reset the virtual machine NAT network:
Remove the NAT network. Add the VMnet8 to NAT mode and change the IP-heavy.

650) this.width=650; "Src=" Http://note.youdao.com/yws/api/personal/file/28C043C1B6034815BA4C9FDCA88E24CE?method =download&sharekey=db2cb07d5bebd7f217047829a770f429 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

650) this.width=650; "Src=" http://note.youdao.com/yws/api/personal/file/7B9327C2AAD443C6B54A6553D64A83E6?method= DOWNLOAD&SHAREKEY=2E92350A747F2D62F6F8BDD811EBDDC5 "alt=" image "Style=" Border-style:none;background-color: RGB (255,255,255); "/>

5. Ping the gateway address to see if it makes sense:
Route-n See if the gateway is present.
[[email protected] ~]# route -nkernel ip routing tabledestination      Gateway         Genmask          flags metric ref    use iface0.0.0.0          192.168.42.1    0.0.0.0          UG    100    0         0 ens33192.168.42.0    0.0.0.0          255.255.255.0   U     100     0        0 ens33[[email protected] ~] #
If the gateway does not exist, edit the network card profile and check the gateway and DNS. and restart the network service. Vi/etc/sysconfig/network-scripts/ifcfg-ens33systemctl Restart Network.service
6. Finally ping www.qq.com to test.


This article is from the "Feng Xiaoqing blog" blog, make sure to keep this source http://fengyunshan911.blog.51cto.com/995251/1952945

Linux CentOS 7 IP address configuration and network troubleshooting

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.