Linux Network configuration

Source: Internet
Author: User
Tags nameserver

(from the Internet, non-original, easy to find)

A. Linux network configuration frequently used commands

1) #ifconfig//View the configured NIC/sbin/ifconfig
2) # vi/etc/resolv.conf//Modify the DNS resolv.conf keywords are mainly four, respectively:
NameServer #定义DNS服务器的IP地址
Domain #定义本地域名
Search #定义域名的搜索列表
Sortlist #对返回的域名进行排序
The most important is the nameserver keyword, if you do not specify nameserver can not find the DNS server, other keywords are optional.
3) #vi/etc/sysconfig/network//Modify Gateway
Networking=yes (Indicates whether the system uses a network and is generally set to Yes.) If set to no, the network cannot be used, and many system services programs will not start.
Hostname=centos (Set the hostname of this machine, the host name set here should correspond to the hostname set in/etc/hosts)
gateway=192.168.1.1 (Sets the IP address of the gateway for the native connection. For example, the gateway is 10.0.0.2)
4) #vi/etc/sysconfig/network-scripts/ifcfg-eth0//Modify NIC Configuration
Device=eth0 #描述网卡对应的设备别名, for example, in Ifcfg-eth0 file it is eth0
Bootproto=static #设置网卡获得ip地址的方式, the possible options are static,dhcp or BOOTP, corresponding to statically specified IP addresses, IP addresses obtained through the DHCP protocol, IP addresses obtained through the BOOTP protocol
broadcast=192.168.0.255 #对应的子网广播地址
HWADDR=00:07:E9:05:E8:B4 #对应的网卡物理地址
ipaddr=12.168.1.2 #如果设置网卡获得 IP address is statically specified, this field specifies the IP address of the NIC
Ipv6init=no
Ipv6_autoconf=no
netmask=255.255.255.0 #网卡对应的网络掩码
network=192.168.1.0 #网卡对应的网络地址
Onboot=yes #系统启动时是否设置此网络接口, when set to Yes, activates the device when the system starts. If you have only one network card and set to No, you will not be able to surf the Internet.

Two. Linux Virtual Machine network configuration (application)

1) using NAT (Simple and practical)
1. Locate the virtual Machine Device "network adapter. Double-click Open Network adapter to customize the specified virtual network selection VMnet8 (Nat).
2. Start the Linux virtual machine and go to the Linux command line. If you enter the Xwindow interface, switch to the command line interface CTRL+ALT+SHIFT+F1
3. #ifconfig See if you use the NIC, Vi/etc/sysconfig/network-scripts/ifcfg-eth0 modify the NIC configuration. Set the BOOTPROTO=DHCP. Remove IPAddr, we use the automatic acquisition of IP and DNS. (If there is no clear can refer to above (I. 4))
4. #service Network restart//restart network. This way the Linux virtual machine will be able to surf the Internet. Let's test it.
#ping www.baidu.com//command line input, you can ping the line.
2) using bridging (slightly)
3) Adopt host-only (slightly)

Three. Standalone Linux host network configuration (usually through the router Internet)

1) Obtain IP and DNS automatically:
#vi/etc/sysconfig/network//Modify the gateway to remove the gateways, as we are using automatic access
#vi/etc/sysconfig/network-scripts/ifcfg-eth0//Modify NIC Configuration
Modify BOOTPROTO=DHCP, delete ipaddr. (If there is no clear can refer to above (I. 4))
#service Network restart//restart network. Pass the ping test.

2) Use assigned IP network configuration
#vi/etc/resolv.com//Modify DNS Primary settings keyword nameserver=8.8.8.8 This is easier to ignore.
#vi/etc/sysconfig/network//Modify the gateway, add gateway=192.168.1.0 to see which segment you belong to.
#vi/etc/sysconfig/network-scripts/ifcfg-eth0//Modify NIC Configuration
Modify Bootproto=static, add (or set) ipaddr=192.168.1.4. (Assigning IP addresses)
#service Network restart//restart network. Pass the ping test.

Four. Summary

Network problems are generally more complex, as described above in a specific environment

Linux Network configuration

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.