LINUX Red Hat Series system network management common methods

Source: Internet
Author: User

A few methods of static configuration network

1. ifconfig [Interface]

-A: View all interfaces that include an inactive state

Enable or disable: Ifconfig IFNAME up|down

or enable: Ifup IFNAME

Disabled: Ifdown IFNAME

Set IP address: Ifconfig IFACE ip/netmask [up]

Note: CIDR format masks, such as 172.18.0.1/16

Or: Ifconfig IFACE IP netmask netmask

Note: The full format mask, such as 255.255.0.0

The address is immediately sent to the kernel and takes effect immediately, but will not be permanently valid.

Route

Route-n displaying the native kernel routing table in numeric format

Add route: Route add [-net|-host] target [netmask Nm] [GW Gw][[dev] If]

-net followed by network address, indicating network routing

-host followed by host address, indicating host routing

Example: Route add-net 192.168.0.0/16 GW 172.18.0.1

Route Add-host 192.168.1.1 GW 172.18.0.1

Route add default GW 172.18.0.1

Delete route: Route del [-net|-host] target [GW GW] [netmask Nm][[dev] If]

Example: Route del-net 0.0.0.0 GW 172.18.0.1

Note: All configurations destined to the kernel stack are effective immediately, but will not take effect permanently. To change the configuration file for the corresponding static route if you want to be permanently active/etc/sysconfig/network-scripts/route-ifname

Configuration format One: Each row defines a route entry

such as: 192.18.0.0/16 via 172.18.0.1

192.18.1.1 via 172.18.0.1

Configuration format Two: Define one route entry per three lines

address#=

netmask#=

gateway#=

Note: These two methods cannot be mixed.

2. IP command

IP [OPTIONS] OBJECT {COMMAND | help}

OBJECT: = {link | addr | route}

①link: Link Interface property settings

Set: Set interface properties

IP link set DEVICE {up|down}

Promisc {On|off}: Promiscuous mode is supported

Name NEWNAME: Change the interface name

Show: Display interface status, such as startup features, HWADDR, etc.

IP link Show DEVICE

②ADDR: Management interface Address

Add: Adding an Address

Del: Delete Address

Example: IP addr add 172.18.10.10/16 dev eth0

Show: Displays all address information on the NIC

IP addr Show [Dev IFNAME]

Flush: Clears all protocol addresses

IP addr flush [Dev IFNAME]

③route: Managing Routes

List | Show: Show routes

Add: Adding routes

IP route add destination network via gateway [Dev IFNAME]

Example: Setting a default gateway

IP route add Defalut via 172.18.0.1

Del: Delete route

Example: IP route del 172.18.10.0/16

3, modify the network card corresponding file/etc/sysconfig/network-scripts/ifcfg-iface

Common parameter Description:

Device: Devices to which this profile applies

HWADDR: MAC address of the corresponding device

bootproto: Address Configuration protocol used when activating this device, common DHCP, static, none, BOOTP

NM_CONTROLLED:NM is the abbreviation of NetworkManager, whether the NIC accepts NM control; CentOS6 is recommended as "no

onboot: Whether this device is activated at system boot time

Type: interface types; common Ethernet, Bridge.

UUID: Unique identification of the device

ipaddr: Specify IP Address

NETMASK: Subnet mask or PREFIX=CIDR format mask

Gateway: Default gateways

DNS1: The first DNS server points to a

DNS2: The second DNS server points to a

Userctl: Whether a normal user can control this device

Peerdns: If the value of Bootproto is "DHCP", whether to allow DHCP server to assign a DNS server to direct the information to overwrite the/etc/resolv.conf file

After you modify the configuration file, you need to restart the service to take effect permanently.

CentOS 6 Restart Operation: Service network restart

CentOS 7 Restart operation: Systemctl restart Network.service

4. TUI Tools

Execute the program via text command, as follows:

CentOS 6 System: Command line Input Setup command, select Network Configutations

CentOS 7 System: Command line Input nmtui command, select Edit Aconnection

Second, the network state detection commonly used tools

1, netstat

The netstat command is used to print the status information of network systems in Linux, allowing you to learn about the network conditions of the entire Linux system.

Common options:

-T:TCP Protocol related

-U:UDP protocol Related

-w:raw Socket Related

-L: In listening state

-A: all States

-N: Displays the IP and port numerically;

-E: Extended format

-P: Show related processes and PID

-R: Show kernel routing table

Instance:

List all ports (both listening and not listening)

Netstat-a #列出所有端口

Netstat-at #列出所有tcp端口

Netstat-au #列出所有udp端口

List all Sockets in the listening state

Netstat-l #只显示监听端口

NETSTAT-LT #只列出所有监听 TCP port

Netstat-lu #只列出所有监听 UDP port

NETSTAT-LX #只列出所有监听 UNIX Ports

Continuous output netstat information

Netstat-c #每隔一秒输出网络信息

Show address families not supported by the system (addr families)

Netstat--verbose

Not all processes can be found, no permissions will not be displayed, use root permissions to view all the information.

Netstat-ap | grep ssh

Locate the process running on the specified port:

Netstat-an | grep ': 80 '

2. SS [OPTION] ... [FILTER]

Netstat by traversing the proc to obtain the socket information, SS uses NetLink to communicate with the kernel Tcp_diag module to obtain the socket information. The advantage of SS is that it can show more and more detailed information about TCP and connection status, and is faster and more efficient than netstat.

Options:

-H: Displays help information;

-V: Displays the instruction version information;

-N: Do not parse the service name and display it digitally;

-A: Displays all sockets;

-L: Displays the socket in the listening state;

-O: Displays timer information;

-M: Shows memory usage of sockets;

-P: Displays process information using sockets;

-I: Displays the internal TCP information;

-4: Only IPv4 sockets are displayed;

-6: Only IPv6 sockets are displayed;

-T: Only TCP sockets are displayed;

-u: Displays only UDP sockets;

-D: Show only DCCP sockets;

-W: Show only raw sockets;

-x: Only UNIX domain sockets are displayed.

Common usage

Ss-l Show all ports that are open locally

SS-PL Show each process specific open socket

Ss-t-A displays all TCP sockets

Ss-u-a displays all UDP Socekt

Ss-o State established ' (Dport =: ssh or sport =: SSH) ' Show all established SSH connections

Ss-o State established ' (Dport =: http or sport =:http) ' shows all established HTTP connections

SS-S List Current Socket details


LINUX Red Hat Series system network management common methods

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.