Network Settings under CentOS--Network Command chapter

Source: Internet
Author: User
Tags change settings ssh

3. Network basic commands
(1) Network Service System Royal network interface configuration information changes, network services must be restarted to activate the new configuration of the network to make the configuration effective, this part of the operation and restart the system as always. Imperial (Control) is/etc/init.d/network This file, you can use this file followed by the following parameters to operate network services. For example:
[Root@linux ~]#/etc/init.d/networkrestart
You can also use the Service command to operate network services such as:
[Root@linux ~] #service Network restart
start← start
stop← stop
restart← restart
reload← and restart the same (... )
status← Status representation
If the server software is installed in RPM mode, most of the above content corresponds.
(2) network Management Command Network management There are also some commonly used commands, the following several commonly used commands.
Ifconfig
Netstat
Hostname
Ping
Traceroute
Ifconfig
This command can be used to start/Stop the network interface, to change settings and to represent the network state, and without adding any parameters, this ifconfig can represent the state of the network interface. For example:
[Root@linux ~]# Ifconfig
Eth0 Link encap:ethernet hwaddr00:xx:xx:xx:04:45
inet addr:192.168.1.81 bcast:192.168.1.255 mask:255.255.255.0
Inet6 ADDR:FE80::20C:29FF:FE61:445/64 Scopeink
Upbroadcast RUNNING Multicast mtu:1500 metric:1
rxpackets:472 errors:0 dropped:0 overruns:0 frame:0
txpackets:445 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
rxbytes:35804 (34.9 KiB) TX bytes:53012 (51.7 KiB)
interrupt:185 Base address:0x1080
Lo Link encapocal Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Uploopback RUNNING mtu:16436 metric:1
Rxpackets:8 errors:0 dropped:0 overruns:0 frame:0
Txpackets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
rxbytes:560 (560.0 B) TX bytes:560 (560.0b)
[Root@linux ~]#
Look at the output of ifconfig.
1. Link encap←
2. Hwaddr←mac Address
3.inet Addr←ip Address (IPV4)
4. bcast← Broadcast Address
5. mask← Diffraction Code
6. Inet6 Addr←ip Address (IPV6)
7. In up← start-up
8. broadcast← Broadcast Address valid
9. running← Action
MTU of the Mtu← network interface (Maximumtransfer unit:ethernet maximum transfer frame value)
metric←.
RX packets← Envelope Count
Number of Messenger packages packets← TX
collisions←
INTERRUPT←IRQ number
BASEADDRESS←I/O Address
Through this command you can also up (turn) and down (off) a network interface (NIC), such as we close eth0 can use the following command:
[Root@linux ~] #ifconfigeth0 down
The opposite opens as follows:
[Root@linux ~] #ifconfigeth0 up
This command can also set the network interface (NIC), for example, we will eth0 IP set to 192.168.1.11, the subnet code is set to 255.255.255.0 as follows:
[Root@linux ~] #ifconfigetho inet 192.168.1.11 netmask 255.255.255.0
In the case of multiple network interfaces, the x portion of ETHX is replaced with a network interface code (numbers, such as Eth0,eth1,eth2).
Netstat
This command is a command that displays the various circumstances of the network, and will represent active Internet connections and Activeunix domain sockets in cases where no parameters are executed.
Check out the following output information:
This is the case where 192.168.1.56 is connecting to 192.168.1.81 via SSH
[Root@linux ~] #netstat
Active internetconnections (w/o servers)
Proto recv-q send-qlocal Address foreignaddress State
TCP 0 0:: Ffff:192.168.1.81:ssh:: ffff:192.168.1.56:4757 established
Active UNIX domainsockets (w/o servers)
Proto refcntflags Type State I-node Path
UNIX One [] dgram 5202/dev/log
UNIX 2 [] Dgram 5997 @/var/run/hal/hotplug_socket
UNIX 2 [] dgram 2536 @udevd
UNIX 2 [] Dgram 7474
UNIX 3 [] STREAM CONNECTED 5995/var/run/dbus/system_bus_socket
UNIX 3 [] STREAM CONNECTED 5994
UNIX 3 [] STREAM CONNECTED 5974
UNIX 3 [] STREAM CONNECTED 5973
UNIX 2 [] Dgram 5933
UNIX 2 [] Dgram 5923
UNIX 2 [] Dgram 5876
UNIX 2 [] Dgram 5819
UNIX 2 [] Dgram 5805
UNIX 2 [] Dgram 5786
UNIX 2 [] Dgram 5723
UNIX 3 [] STREAM CONNECTED 5388
UNIX 3 [] STREAM CONNECTED 5387
UNIX 2 [] Dgram 5280
UNIX 2 [] Dgram 5210
[Root@linux ~]#
The main options:
-a displays all sockets, including those that are listening.
-C is displayed again every 1 seconds until the user interrupts it.
-I displays information for all network interfaces in the form of "ipconfig-e".
-N Displays the network connection situation with the network IP address instead of the name.
-R Displays the core routing table in the same format as "Route-e".
-T displays the TCP protocol connection.
-U Displays the connection condition of the UDP protocol.
-V Displays the work in progress.
The above options can be used in combination, for example, if we want to know which TCP ports are open, we can use the following situation to observe:
[Root@linux ~] #netstat-at
Active Internetconnections (servers and established)
Proto recv-q send-qlocal Address foreignaddress State
TCP 0 0 *:617 *:* LISTEN
TCP 0 0 *:sunrpc *:* LISTEN
TCP 0 0 *:ipp *:* LISTEN
TCP 0 0 linux.xiaoqi.ddo.jp:smtp *:* LISTEN
TCP 0 0 *:ssh *:* LISTEN
TCP 0 132:: Ffff:192.168.1.81:ssh:: ffff:192.168.1.56:4757 established
[Root@linux ~]#
Other ways to use them ...
Hostname
This command is for hostname and set hostname, and will represent the current hostname, such as the following output, without following any options being executed:
[Root@linux ~] #hostname
linux.xiaoqi.ddo.jp
[Root@linux ~]#
In the case of root login, you can change the hostname, for example, if we rename the current hostname to CentOS as follows:
[Root@linux ~] #hostname CentOS
[Root@linux ~] #hostname
Centos
[Root@linux ~]#
Ping
This command determines whether the target host is working or network-connected by sending an ICMP packet to the destination address. The parameter is the IP address of the target host, for example, we need to know whether the network configuration of our host is normal, and can be judged by ping own host, the situation is as follows:
[Root@linux ~]# pinglocalhost//This place localhost can be replaced by the 127.0 0.1来, or the destination address IP address or domain name, and often use this command to access the DNS server to obtain the target host's IP address or domain name and other uses
PING linux.xiaoqi.ddo.jp (127.0.0.1) bytes ofdata.
Bytes fromlinux.xiaoqi.ddo.jp (127.0.0.1): icmp_seq=0 ttl=64 time=0.999 ms
Bytes fromlinux.xiaoqi.ddo.jp (127.0.0.1): icmp_seq=1 ttl=64 time=0.630 ms
---linux.xiaoqi.ddo.jp ping statistics---
2 packetstransmitted, 2 received, 0% packet loss, time 1001ms/Note this place has a 0% indicating that the network is normal, and when percent X is 0 it indicates a problem with the network, or when the ping command is executed , you will see words such as time out.
RTT min/avg/max/mdev= 0.630/0.814/0.999/0.186 MS, pipe 2
[Root@linux ~]#
The main options for the ping command are as follows:
The-c number stops after sending the specified number of packages.
-D Sets the So_debug option.
-F sends a large and fast network envelope to a machine to see its response.
-I seconds set interval a few seconds to send a network packet to a machine, the default is a second send.
-L The fastest way to send packet data to a specified machine, within a specified number of times (only Superuser can use this option).
-Q Displays no information about the delivery packet and displays only the final results.
-R sends packets directly to a machine without a gateway, usually to see if there is a problem with the network interface on this computer.
-S bytes Specifies the number of bytes sent, the default value is 56, plus the 8-byte ICMP header, which is a total of 64ICMP data bytes.
More information and more commands can be used in the process of learning a little bit, encounter problems when you can pass
#man命令
To view the usage of the command

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.