Linux Learning Notes (ii)

Source: Internet
Author: User

November 10, 2015 study notes (II)

Minimal installation is missing some tools and needs to be networked and solved later with Yum tools.

The bridge mode has been set up before, and it is possible to obtain an IP from a router on the same network.

Ifconfig-a

The #加-a option allows you to view all network adapter information that starts and does not start (that is, you can see the network card information that is down), because there is only one NIC, so it only displays information such as eth0 and its IP. If you add a network card later, the eth1 information will be displayed under Eth0. The LO loopback address (used for internal communication).

#刚装完系统, the first view with the Ifconfig command, only show the loopback address lo, does not display eth0 network card information, very strange. Then just use the command: ifconfig eth0 up. This way the eth0 is displayed normally.


Ifdown eth0 #down掉eth0;

Ifup eth0 #开启eth0;


Dhclient

#因为是桥接, you can get the NIC eth0 to obtain an IP address through the DHCP service.

Dhclient-r #释放一个IP地址


#我在输入dhclient命令后, use Ifconfig-a to see that eth0 did not obtain an IP address. And at startup, the bridge on the device vmnet0 temporarily stops running because the bridged Ethernet interface is off.

Baidu, learned that this phenomenon occurs because the virtual machine lost files caused by the proposed reinstallation of VMware software. After reinstalling the software, use the dhclient command to obtain the IP.


Configure IP:

Vi/etc/sysconfig/network-scripts/ifcfg-eth0 #用vi命令打开eth0的配置文件, if you cannot remember the directory name or file name, you can use the TAB key to complete the completion.

#按i进入编辑模式, enter the desired character, press ESC to enter the general mode, enter a colon into the command mode, such as: Wq to save and exit.

Onboot=yes #表示开机启动, if no means not to boot with boot.

Bootproto=static #BOOTPROTO =static indicates that the IP is obtained by statically setting. You can also dynamically obtain the IP by DHCP mode instead.

Ipaddr= 192.168.31.105 #IP地址 because it is bridged, so the virtual machine is the same network segment as the physical mechanism.

netmask= 255.255.255.0 #子网掩码

gateway=192.168.31.1 #网关地址

dns1=192.168.31.1 #DNS地址, you can set the DNS address as the gateway address.

dns2=8.8.8.8 #DNS2的地址设置成谷歌的DNS服务器地址.


: Wq #保存修改并退出.


Service Network Restart #重启网络服务


Ping 192.168.31.1 #ping网关看通不通, use CTRL + C to terminate the ping command.

Ping www.baidu.com #ping外网也是通的.



This article is from the "Sunwangbackup" blog, make sure to keep this source http://sunwangbackup.blog.51cto.com/10866322/1711734

Linux Learning Notes (ii)

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.