Linux Basic network Management

Source: Internet
Author: User
Tags ack name database

1. Connect a Linux host to the network and need to configure network-related settings

Generally includes:

Host Name

Ip/netmask

Routing: Default gateway

DNS Server

Primary DNS Server

Secondary DNS server

Second time DNS server

2. Static designation:

Ifcfg:ifconfig,route,netstat

Ip:object{link,addr,route},ss,tc

System-config-network-tui (Setup)

Configuration file

Centos 7: Network Configuration Tool

Nmcli,nmtui,nm-connection-editor

Dynamic allocation:

Dhcp:dynamic Host Configuration Protocol

Ifconfig

Ifconfig-a

Ifconfig eth0 (Up|down)

Ifconfig eth0 Ip/netmask [Up|down]

#立即生效

Route command:

View routes: Route-n

Add route: Route add

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

Target: 10.1.249.112 Gateway: 10.1.0.1

[Email protected]]# Route add-host 10.1.249.112 GW 10.1.0.1 Dev eth0

Target: 10.1.249.0 Gateway: 10.1.0.1

[Email protected]]# Route add-net 10.1.249.0 netmask 255.255.0.0 gw 10.1.0.1 Dev eth0

[Email protected]]# Route add-net 10.1.249.0/16 GW 10.1.0.1 Dev eth0

Default Route Gateway 10.1.0.1

[Email protected]]# Route add-net 0.0.0.0 netmask 0.0.0.0 GW 10.1.0.1

[[email protected]]# route add default GW 10.1.0.1

Delete target: 10.1.249.112 Gateway: 10.1.0.1

[Email protected]]# Route del host 10.1.249.112

Delete target: 10.1.249.0 Gateway: 10.1.0.1

[Email protected]]# Route del-net 10.1.249.0 netmask 255.255.0.0

Netstat command:

Netstat-print network connections,routing tables,interface statistics,masquerade Connections,and Multicast Memberships

Show Network Connections:

netstat [--tcp|-t] [--udp|-u] [--raw|-w] [--listening|-l] [--all|-a] [--NUMERIC|-N][--EXTEND|-E] [--program|-p]

-T:TCP protocol Related

-U:UCP protocol Related

-w:raw Socket Related

-L: In listening state

-A: all States

-N: Digital display of IP and ports

-E: Extended format

-P: Show related processes and PID

Netstat common groups and:

-tan TCP protocol related, all States, with digital display IP and port

-uan UCP Protocol related, all States, to digitally display IP and ports

-TNL TCP protocol related to digital display IP and port, in listening state

-UNL UCP protocol related, digital display IP and port, in listening state

Display Interface Statistics:

Netstat-i displaying all interface data

Netstat-i=eth0 Display Eth0 Interface data

Ifconfig-s eth0 display Eth0 interface data

To set the IP command:

Ifup eth0 Open eth0 Port

Ifdown eth0 Close Eth0 Port

Set Temporary IP:

IP addr Add 10.1.249.111/16 dev eth0 label eth0:0

To delete a temporary IP:

IP addr del 10.1.249.111/16 dev eth0 label eth0:0

IP addr Flush Dev eth0 label eth0:0

SS Command:

Netstat to get socket information by traversing proc, SS uses NetLink to communicate with kernel Tcp_diag module to get socket information

Options:

-T TCP protocol related

-U UDP Protocol Related

-W Bare Socket related

-X UNIX Sock related

-L Listen Status link

-A All

-N Number format

-P related programs and PID

-E Extended Information

-M memory usage

-O Timer Information

Common combinations:

-tan TCP protocol related, all, number formats

-TANL TCP protocol related, all, number formats, listen status links

-TANLP TCP protocol related, all, number formats, listen status links related programs and PID

-uan UCP protocol related, all, numeric format

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 show all UCP sockets

SS-S List Current Socket details

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

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

TCP Common Status:

TCP Finite state machine:

LISTEN: Monitoring

Established: Established links

Fin_wait_1: Waiting for a remote TCP link interrupt request, or confirmation of a previous link interrupt request

Fin_wait_2: Waiting for link interrupt request from remote TCP

Close-wait: Waiting for a link to be sent from a local user to interrupt the request

CLOSING: Waiting for remote TCP to confirm the link interruption

Last-ack: Wait for the original send to remote TCP link Interrupt Request Confirmation

Time-wait: Wait enough time to ensure that the remote TCP receives a link interrupt request acknowledgement

Syn-sent: Client syn_sent status

SYN-RECV: After the server has been passively opened, the client's SYN is received and the ACK state is sent.

Syn-received: Server-side status SYN_RCVD if you find that there are many SYN_RCVD states, your machine may be attacked by a SYN flood DOS (Denial of service attack)

CLOSEDSS: No connection status

3. Network configuration file

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

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", does it allow

DHCP server-assigned DNS servers point to information that is directly overwritten in the/etc/resolv.conf file

Nic configuration file/etc/sysconfig/network-scripts

The parser performs forward and reverse queries:

/etc/hosts

Image of the local host name database and IP address

Useful for small standalone networks

Typically, before using DNS check, Getent hosts view/etc/hosts content

4. Network Card related commands:

Network interface identifies and names the associated udev configuration file

/etc/udev/rules.d/70-persistent-net.rules

To view the network card:

DMESG |grep–i ETH

Ethtool-i eth0

To uninstall the NIC driver:

Modprobe-r e1000

Rmmod e1000

Load NIC driver:

Modprobe e1000

5. Use traditional naming methods:

(1) Edit/etc/default/grub configuration file grub_cmdline_linux= "RHGB quiet net.ifnames=0" or: Modify/boot/grub2/grub.cfg

(2) generate its configuration file for Grub2 grub2-mkconfig-o/etc/grub2.cfg

(3) Rebooting the system

This article is from the "Linux Learning path" blog, so be sure to keep this source http://luyubo.blog.51cto.com/7634254/1847180

Linux Basic network Management

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.