Linux system--the basic configuration and troubleshooting of the network

Source: Internet
Author: User

In the Linux system, there are three kinds of network configuration, one is implemented directly on the terminal with command line, the other side is to modify the configuration file implementation, there is another way is setup text mode interface settings.

The difference is that after you modify the configuration file, it is permanent if you do not change it (you must restart the service, this Setup text mode), but the command is in time, but it fails after a reboot.


First, modify the configuration file

in the Linux system, whether it is connected to the Internet or the LAN must first have to configure the network card, network card the default path for the profile is in the /etc/sysconfig/network-scripts directory, which has a default of two blocks network card, a physical network card (eth0), and a loopback network card (LO), their configuration files are ifcfg- eth0 and Ifcfg-lo, if you add a new network card, then his configuration file is Ifcfg-eth1


[[email protected] ~] #vi/etc/sysconfig/network-scripts/ifcfg-eth0 #用vi编 adapter to open the NIC configuration file

Type=ethernet #网卡类型, generally do not modify

Device=eth0 #网卡接口名称, generally do not modify, if it is newly added note here to change to the corresponding

Onboot=yes #系统启动时是否自动加载

bootproto=static #启用地址协议--static: Static protocol--BOOTP Protocol--DHCP Protocol system is none by default, if you set a static IP address can not be modified, if it is obtained from the DHCP server, you will change to DHCP

ipaddr=192.168.1.11 #网卡IP地址

netmask=255.255.255.0 #网卡的子网掩码

gateway=192.168.1.1 #网卡网关地址

dns1=8.8.8.8 #网卡DNS地址, if there is more than one DNS, then dns2= ...

hwaddr=00:0c:29:13:5d:74 #网卡设备MAC地址

broadcast=192.168.1.255 #网卡广播地址


After you modify the configuration file, you need to restart the service or reload the configuration if you want it to take effect

[Email protected] ~]#/etc/init.d/network Reload #重新加载配置

[Email protected] ~]#/etc/init.d/network restart #重启服务

The service network Restart/reload can also be used directly here


Second, the direct command line temporary modification

[email protected] ~]# ifconfig eth0 192.168.1.1 netmask 255.255.255.0 #直接用命令方式修改网卡

Or

[Email protected] ~]# ifconfig eth0 10.1.1.10/24


[email protected] ~]# ifconfig eth0:0 127.0.0.1 #为网卡eth0添加一个虚拟地 address, two IP can be used


C. Setup Text mode configuration

[[Email protected] ~]# Setup

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/54/8B/wKiom1SFwffQ34ddAAGegSG9tzE466.jpg "style=" float: none; "title=" 1.jpg "alt=" Wkiom1sfwffq34ddaagegsg9tze466.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/54/89/wKioL1SFwouDW1h_AAE6eUqA-C8191.jpg "style=" float: none; "title=" 2.jpg "alt=" Wkiol1sfwoudw1h_aae6euqa-c8191.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/54/8B/wKiom1SFwfeAZpO_AAGrg4Wzqbw979.jpg "style=" float: none; "title=" 3.jpg "alt=" Wkiom1sfwfeazpo_aagrg4wzqbw979.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/54/89/wKioL1SFwovAEKU6AAHRCdqB_6Y492.jpg "style=" float: none; "title=" 4.jpg "alt=" Wkiol1sfwovaeku6aahrcdqb_6y492.jpg "/>



Iv. Configuring routing

[email protected] ~]# route-net 192.168.3.0/24 GW 192.168.2.1 #添加静态 Route-net followed by the network segment to reach GW followed by the next hop address

[Email protected] ~]# Route del-net 192.168.3.0/24 #删除静态路由

[email protected] ~]# route add/del default GW 192.168.1.1 #添加/delete default Routing


V. Start-up and shutdown of the network

[Email protected] ~]# ifdown eth0 #关闭网络

[Email protected] ~]# ifup eth0 #启动网络

Or

[Email protected] ~]# ifconfig eth0 up #启动网络

[Email protected] ~]# ifconfig eth0 down #关闭网络


Vi. various query commands

[Email protected] ~]# service network status #网卡状态查询

[Email protected] ~]# ifconfig #默认列出所有接口

[Email protected] ~]# ifconfig eth0 #列出eth0这块网卡信息


[Email protected] ~]# netstat-r #查看路由信息

[[email protected] ~]# route (-N) #查看路由信息, plus-n is displayed in digital form

[Email protected] ~]# traceroute 192.168.1.1 #跟踪路由


Summary: When we ping an IP address ping does not pass if the firewall is not blocked and the other network is normal, We should first check whether our network card is configured correctly (regardless of the physical layer problems such as the network cable is not picked up--# )

1, the network card is open

2, NIC parameters are configured correctly (their own IP, mask, gateway, DNS, etc.)

3, whether there is a route to each other, the route is configured correctly

4, the Network service is open

Another: Multi-reference error or System log error troubleshooting


This article is from the "Network growth path of the female kicked" blog, please make sure to keep this source http://shengjie.blog.51cto.com/8734352/1587708

Linux system--the basic configuration and troubleshooting of the network

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.