Linux Network Services

Check ifconfig network interface address

Use ifconfig can see the network interface address configuration information

NIC Name: ens33
ip address: 192.168.71.151
Subnet Mask: 255.255.255.0
the MAC Address: 00: 0c: 29: 70: Fe: fc
IPV6 address: fe80 :: 58b9: 7c59: 8d8c : 23d

Linux Network Services

View Host Name hostname

View or set the current host name: hostname
Linux Network Services
modify the host name
hostname + hostname (temporarily modify the host name)
Linux Network Services
hostnamectl STE-hostname + hostname
Linux Network Services

route command to view the routing table entries

route command
to view information or set the host table: route [-n]
Linux Network Services

View network connections

netstat
Display system network connection status, routing tables, interface information netstat [Option]
Common options

a: displays all
n: denotes a display in a digital form
T: the TCP
U: the UDP
P: Protocol
r: represents a router

Example:
input netstat-ntap (see TCP protocol)
Linux Network Services
the netstat nuap-input (see UDP protocol)
Linux Network Services
input routing table netstat-r
Linux Network Services

DNS

nslookup command
to test DNS name resolution: nslookup target host address [DNS Server Address]
53 ports using the UDP protocol and TCP protocol
example
in the case of a networked host computer
input

nklookup www.baidu.com

Linux Network Services
解析到的地址是180.101.49.11用这个地址也可以访问百度网站

测试网络连接

测试网络互通性:ping+主机ip地址
示例
在Linux系统中测试网络连接为长ping状态需使用Ctrl+Z停止
Linux Network Services
在Window系统中只发送4个ping包,而且会自动停止
Linux Network Services

设置网络地址参数

临时配置:

通过命令行直接修改当前正在使用的网络地址,修改后立即可以生效。简单快速、执行效率高,一般在调试网络的过程中使用。但由于所做的修改并没有固定地存放在静态的文件中,因此重启ntewor服务或重启主机后将会失效。

固定配置:

通过配置文件来存放固定的各种网络地址,需要重启network服务或重启主机后才会生效。这中方法相对于要复杂一些,但是相当于“永久配置”,一般在需要为服务器设置固定的网络地址时使用。

临时修改命令
Linux Network Services
固定设置
输入

vim /etc/sysconfig/network-scripts/ifcfg-ens33

进入配置文件中将dhcp修改为static(静态)
按“G”到末行,按"O"在下一行插入:IPADD、NETMASK(子网掩码)、GETWAY
Linux Network Services

设置网口接口参数

ifconfig命令
ifconfig命令不仅可以用于查看网卡配置,还可以修改网卡的IP地址、子网掩码,也可以绑定虚拟网络接口、激活或者停用网络接口。

(1)、修改网卡的IP地址、子网掩码

ifconfig 网阔接口名称 IP地址 [netmask 子网掩码]
ifconfig 网络接口名称 IP地址 [netmask 子网掩码]

(2)、禁用、激活网卡接口
ipconfig 网络接口 up
ipconfig 网络接口 down

Linux Network Services
Linux Network Services
设置虚拟网卡
ifconfig+接口序列号+ip地址
Linux Network Services

设置路由记录

route命令

route命令不仅可以使用于查看路由表信息,还可以来添加、删除静态的路由表条目,其中也包括设置默认网关地址。

(1)、添加到指定网段的路由记录

route add -net 网段地址 gw ip地址

(2), to delete the route record the specified network '
route del -net ge ip address network address
Linux Network Services
(3), remove the default gateway records

route del default gw 网关地址

(4), add a gateway record

route add deafult gw 网关地址

Linux Network Services

Guess you like

Origin blog.51cto.com/14307755/2434608