Linux学习总结 unit09 网络管理

来源:互联网 发布:联通wcdma 通话 数据 编辑:程序博客网 时间:2024/06/15 13:30

#1.Ipv4网络

                  IP地址

                  网关GATEWAY

                  DNS域名服务器

#2.IP地址

#3.网关

#4.DNS

        DNS(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联
网,而不用去记住能够被机器直接读取的IP。

#5.网络管理命令

             ifconfig

[root@foundation18 ~]# ifconfigenp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500        ether 00:21:cc:ba:0f:6a  txqueuelen 1000  (Ethernet)        RX packets 2394819  bytes 3010949842 (2.8 GiB)        RX errors 0  dropped 15  overruns 0  frame 0        TX packets 254354  bytes 18302447 (17.4 MiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0        device interrupt 20  memory 0xf2500000-f2520000  

             ip addr show eth0

[root@foundation18 ~]# ip addr show enp0s252: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000    link/ether 00:21:cc:ba:0f:6a brd ff:ff:ff:ff:ff:ff

             ping -c 1 -w 1

[root@foundation18 ~]# ping -c 1 -w 1Usage: ping [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface]            [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]            [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]            [-w deadline] [-W timeout] [hop1 ...] destinatio

                 ip route

[root@foundation18 ~]# ip routedefault via 192.168.43.1 dev wlp3s0  proto static  metric 600192.168.43.0/24 dev wlp3s0  proto kernel  scope link  src 192.168.43.143  metric 600 

             traceroute

Usage:  traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] [ -w waittime ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ]Options:  -4                          Use IPv4  -6                          Use IPv6  -d  --debug                 Enable socket level debugging  -F  --dont-fragment         Do not fragment packets  -f first_ttl  --first=first_ttl                              Start from the first_ttl hop (instead from 1)  -g gate,...  --gateway=gate,...                              Route packets through the specified gateway                              (maximum 8 for IPv4 and 127 for IPv6)  -I  --icmp                  Use ICMP ECHO for tracerouting  -T  --tcp                   Use TCP SYN for tracerouting (default port is 80)  -i device  --interface=device                              Specify a network interface to operate with  -m max_ttl  --max-hops=max_ttl                              Set the max number of hops (max TTL to be                              reached). Default is 30  -N squeries  --sim-queries=squeries                              Set the number of probes to be tried                              simultaneously (default is 16)  -n                          Do not resolve IP addresses to their domain names  -p port  --port=port        Set the destination port to use. It is either                              initial udp port value for "default" method                              (incremented by each probe, default is 33434), or                              initial seq for "icmp" (incremented as well,                              default from 1), or some constant destination                              port for other methods (with default of 80 for                              "tcp", 53 for "udp", etc.)  -t tos  --tos=tos           Set the TOS (IPv4 type of service) or TC (IPv6                              traffic class) value for outgoing packets  -l flow_label  --flowlabel=flow_label                              Use specified flow_label for IPv6 packets  -w waittime  --wait=waittime                              Set the number of seconds to wait for response to                              a probe (default is 5.0). Non-integer (float                              point) values allowed too  -q nqueries  --queries=nqueries                              Set the number of probes per each hop. Default is                              3  -r                          Bypass the normal routing and send directly to a                              host on an attached network  -s src_addr  --source=src_addr                              Use source src_addr for outgoing packets  -z sendwait  --sendwait=sendwait                              Minimal time interval between probes (default 0).                              If the value is more than 10, then it specifies a                              number in milliseconds, else it is a number of                              seconds (float point values allowed too)  -e  --extensions            Show ICMP extensions (if present), including MPLS  -A  --as-path-lookups       Perform AS path lookups in routing registries and                              print results directly after the corresponding                              addresses  -M name  --module=name      Use specified module (either builtin or external)                              for traceroute operations. Most methods have                              their shortcuts (`-I' means `-M icmp' etc.)  -O OPTS,...  --options=OPTS,...                              Use module-specific option OPTS for the                              traceroute module. Several OPTS allowed,                              separated by comma. If OPTS is "help", print info                              about available options  --sport=num                 Use source port num for outgoing packets. Implies                              `-N 1'  --fwmark=num                Set firewall mark for outgoing packets  -U  --udp                   Use UDP to particular port for tracerouting                              (instead of increasing the port per each probe),                              default port is 53  -UL                         Use UDPLITE for tracerouting (default dest port                              is 53)  -D  --dccp                  Use DCCP Request for tracerouting (default port                              is 33434)  -P prot  --protocol=prot    Use raw packet of protocol prot for tracerouting  --mtu                       Discover MTU along the path being traced. Implies                              `-F -N 1'  --back                      Guess the number of hops in the backward path and                              print if it differs  -V  --version               Print version info and exit  --help                      Read this help and exitArguments:+     host          The host to traceroute to      packetlen     The full packet length (default is the length of an IP                    header plus 40). Can be ignored or increased to a minimal                    allowed value

#6.网络管理命令nmcli

                   命令                                              使用
         nmcli dev status                             列出所有设备
         nmcli con show                              列出所有连接
         nmcli con up <name>                   激活某个连接
         nmcli con down <name>              关闭某个连接
         nmcli dev dis <dev>                      断开某个设备
         nmcli con add ..                             添加一个新连接
         nmcli con mod <ID>                      修改连接
         nmcli con del <ID>                         删除连接


         nmcli connection add type ethernet con-name westos ifname
         eth0 autoconnect yes
         nmcli connection add type ethernet con-name westos ifname
         eth0 ip4 172.25.254.10/24
         nmcli connection delete westos
         nmcli connection show
         nmcli connection down westos
         nmcli connection up westos

         nmcli connection modify "westos" ipv4.addresses newip/24
         nmcli connection modify "westos" ipv4.method
         <auto|manual>
         nmcli device connect eth0
         nmcli device disconnect eth0
         nmcli device show
         nmcli device status


#7.网络管理文件

##7.1.动态获取IP配置:

vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 //接口使用设备
BOOTPROTO=dhcp //网卡工作模式
ONBOOT=yes //网络服务开启时自动激活
NAME=eth0 //网络接口名称


##7.2.静态IP配置:

vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static|none
ONBOOT=yes
NAME=eth0
IPADDR=172.25.0.100
NETNASK=255.255.255.0    //子网掩码,通过也可PREFIX=24

#8.网关配置文件

• 配置文件:/etc/sysconfig/gateway
GATEWAY = IP
• 查看:route -n


#9.名称解析

两个文件:
/etc/hosts
/etc/resolv.conf
一个配置文件:

/etc/nsswitch.conf

原创粉丝点击