Linux Learning note--ip, gateway, DNS awareness and settings, network port monitoring

Source: Internet
Author: User
Tags ftp protocol

############# #网络知识 #############
If a host can connect to the public network, such as access to www.baidu.com then this host will inevitably have
Ipaddress:ip Address
Gateway: Gateways
DNS: Domain Name System

########### #ipaddress ##############
1.TCP/IP: This is a protocol family, including TCP protocol, IP Protocol, IMCP protocol, HTTP protocol, FTP protocol, etc.

2.
The IP address is usually a 32bit number, which is the common IPv4 standard, the IP address is the network address + host address
The 4 version of the IPV4:IP protocol, referred to as IPv4, is the next version of IPv6
There are four types of IP addresses: Class A, Class B, Class C, Class D (1 bytes = 8 bits)
1)
Class A address: The first byte is the network address, the other three bytes is the host address, the first byte highest bit fixed to 0
Class A address range: 1.0.0.0~126.255.255.255
Reserved address in Class A address: 127.0.0.0~127.255.255.255, used as a cyclic test.
Class A private address: 10.0.0.0~10.255.255.255
(Private address: The address used in a local area network; public Address: The address used in the Internet)
2)
Class B Address: The first byte and the second self is the network address, the other two is the host address, the first byte highest bit fixed to 10
Class B address range: 128.0.0.0~191.255.255.255
Reserved address in class B: 169.254.0.0~169.254.255.255
Class B Private Address: 172.16.0.0~172.31.255.255
3)
Class C Address: The first, second, third byte is the network address, the fourth byte-bit host address, the first byte the highest bit fixed to 100
Class C address range: 192.0.0.0~223.255.255.255
Class C Private Address: 192.168.0.0~192.168.255.255

3.
Subnet mask: is a 32bit binary sequence of numbers. Non-0-bit corresponding network address of subnet mask, 0 corresponding host address
The Eg:c class address corresponds to the binary form of the subnet mask 255.255.255.0:
11111111.11111111.11111111.00000000

############# #ip设定 ###############
1. How to configure the command
Ifconfig # # #查看或者临时设定主机ip的工具
Ifconfig Network Interface # # #查看这个接口上的 IP
Ifconfig network interface IP netmask Subnet Mask # # #临时设定ip
Ifconfig eth0 172.25.254.100 netmask 255.255.255.0 # # #添加一个ip地址
Ifconfig eth0 down # # #禁用网卡
Ifconfig eth0 Up # # #启用网卡

IP # #网络配置工具, can replace the traditional network management configuration tools, such as ifconfig, route, etc.
IP Addr Show # #查看主机ip信息
IP addr Add 172.25.8.10/24 dev eth0 # # #添加一个ip地址
IP addr del 172.25.8.10/24 dev eth0 # # #删除一个ip地址

Systemctl Restart Network # # #重新启动网络服务
Systemctl Restart NetworkManager # # #管理和监控网络设置的守护进程 (Record network card work, such as: WiFi next time no longer login with a password)

Nmtui # #命令打开文本中的网络设定工具

NMCLI # #命令设定ip的方式
NMCLI connection Add con-name WESTOS ifname eth0 type Ethernet AutoConnect Yes # # #添加动态网络
NMCLI connection Add con-name WESTOS ifname eth0 type Ethernet IP4 ip/24 gw4 IP # # #添加静态网络
(add is added, Con-name is the connection name, ifname is the interface name, type is the device types, IP4 and gw4 are IPv4 addresses and gateways, changes are still in after the refresh)
NMCLI Connection Delete connection name # #删除此连接
NMCLI Connection Show # #显示所有连接
NMCLI Connection Show "System eth0" # #显示网络连接详细配置
NMCLI connection Modify "System westos1" ipv4.addresses 172.25.8.9/24 # #修改设备名为westos1的ip地址为172.25.8.9/24
NMCLI connection Modify "System westos1" Ipv4.dns 172.25.254.1 # #修改设备名为westos1的dns为172.25.254.1
NMCLI connection Modify "System westos1" Ipv4.method Auto # #修该配置方式为自动
NMCLI connection Modify "System westos1" Ipv4.method Manual # #修该配置方式为手动
NMCLI connection up "System westos1" # #激活
NMCLI connection Down "System westos1" # #关闭
NMCLI Device Status # #显示设备状态
NMCLI Device Show # #显示设备详细内容

2. How to configure the graphics network
Nm-connection-editor # #图形中的网络设定工具 (window appears)

3. Network configuration file
/etc/sysconfig/network-scripts/# # #网络配置目录
(Direct access to edit vim/etc/sysconfig/network-scripts/ifcfg-eth0)

# # #动态网络配置 # #
Vim ifcfg-xxx (device) # # #网络配置文件格式
Device=eth0 # #指定文件管理的设备名称
BOOTPROTO=DHCP # #dhcp动态获取
Onboot=yes # #开机时自动激活设备
Name=westos # #指定网络链接的名字为westos

# # #静态网络配置 # #
Vim ifcfg-xxx (device) # # #网络配置文件格式
Device=eth0 # #指定文件管理的设备名称
Bootproto=none or Static # #none和static都表示静态网络
Onboot=yes # #开机时自动激活设备
Name=westos # #指定网络链接的名字为westos
ipaddr=172.25.8.10
netmask=255.255.255.0 or Prefix=24 # #子网掩码是255.255.255.0

Summary: Command configuration information, restart will be cleared, want to take effect permanently, in the network configuration file modification.


################### #网关gateway ##################
Gateways: Gateway, also known as Inter-Network connector, protocol converter.
Gateways are facilities used to provide network-compatible functions such as protocol conversion, routing, and data exchange when communicating between networks with different architectures or protocols.
"The gateway can also be understood as the IP address of the LAN interface of the IP or router on the router and our host on the same network segment"

Vim/etc/sysconfig/network-scripts/ifcfg-xxx
gateway= Gateway Address

Eg:vim/etc/sysconfig/network-scripts/ifcfg-eth0
gateway=172.25.254.254

Route # #该命令可查看和操作ip路由表
-C # #显示更多信息
-N # #不解析名字
-V # #显示详细的处理信息
-F # #显示发送信息
-C # #显示路由缓存
-F # #清楚所有网关入口的路由表
-P # #与add一起用时路由具有永久性
Add # #添加一条新路由
Del # #删除一条路由
-net # #目标地址时网络
-host # #目标地址时主机
Netmask # #担负添加一个网络路由时, need to use netmask
GW # #路由数据包通过网关
eg
Route-n # #显示当前路由
Route add-net 192.168.62.0 netmask 255.255.255.0 Dev eth0 # #添加一条到192.168.62.0 Gateway
Route add-net 192.168.62.0 netmask 255.255.255.0 reject # #增加一条屏蔽路由
Route del-net 224.0.0.0 netmask 240.0.0.0 # #删除路由记录
Route add default GW 192.168.120.240 # #添加默认网关
Route del default GW 192.168.120.240 # #删除默认网关

The route command output explains:
Destination: Target network segment or host
Gateway Address, * Indicates the destination is the network to which this host belongs
Gatemask: Network Mask
Flags: tags, as follows:

        u indicates routing activity
        h indicates that the target is a host
        g indicates that the route is pointing to the gateway
         R indicates that the table entry generated by the recovery of dynamic routes
        d represents dynamic installation by a routed daemon
         m represents modifications to the
        ! by a routed daemon Represents the Deny Route
Metric: Route distance, number of connections to the specified network
REF: Number of route entry references
use: number of times the route item was routed software query
Iface: Output interface for route table entry


########### ######## #DNS ####################
1.DNS domain Name System: A distributed database for domain name resolution that provides services to convert domain names to IP addresses

2.ip mapping files     &NBSP
/etc/hosts
ip     host name

3.DNS Server point to File
vim/etc/resolv.conf     #DNS的配置文件 to get the address of the DNS server

NameServer 172.25.254.254 # #指定DNS服务器的ip地址
Vim/etc/sysconfig/network-scripts/ifcfg-xxx
dns=172.25.254.254
Systemctl Stop Networkmanager.service

Peerdns=yes|no # # #在ifcfg-eth0 Modified, whether the configuration file will be modified/etc/resolv.conf,no means not modified
Ifcfg-eth0 is configured in DHCP mode and the system defaults to Peerdns=yes, the system modifies the resolv.conf


############### #网络端口的检测 #######################
Netstat # #网络端口监测命令
-A # #所有
-N # #不做解析
-T # #tcp协议
-U # #udp协议
-L # #listen, current active port
-E # #显示端口的详细信息

/etc/service # #系统服务默认使用端口信息文件

This article is from the "12148275" blog, please be sure to keep this source http://12158275.blog.51cto.com/12148275/1898151

Linux Learning note--ip, gateway, DNS awareness and settings, network port monitoring

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.