包含标签 Linux articles

Internet和internet

internet意思是用一个共同的协议族把多个网络连接在一起. 而Internet指的是世界范围内通过TCP/IP互相通信的所有主机集合

Internet是一个internet,但internet不等于Internet

……

Continue reading

ip link

ip link命令格式

命令实例 ip link add link eth0 name eth0.10 type vlan id 10

命令实例 解释
ip link add link eth0 name eth0.10 type vlan id 10 在设备eth0上创建新的vlan设备eth0.10
ip link set eth0 up 或:ifconfig eth0 up 开启eth0网卡
ip link set eth0 down或:ifconfig eth0 down 关闭eth0网卡
ip link set eth0 promisc on 开启网卡的混合模式
ip link set eth0 promisc off 关闭网卡的混合模式
ip link set eth0 txqueuelen 1200 设置网卡队列长度
ip link set eth0 mtu 1400 设置网卡最大传输单元
ip link show 显示网络接口信息
ip link show eht0 显示eth0网卡的网络接口信息
ip link show type vlan 显示vlan类型设备
ip link delete dev eth0.10 删除设备
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
[root@k8s-master ~]# ip link help link
Usage: ip link add [link DEV] [ name ] NAME
                   [ txqueuelen PACKETS ]
                   [ address LLADDR ]
                   [ broadcast LLADDR ]
                   [ mtu MTU ] [index IDX ]
                   [ numtxqueues QUEUE_COUNT ]
                   [ numrxqueues QUEUE_COUNT ]
                   type TYPE [ ARGS ]

       ip link delete { DEVICE | dev DEVICE | group DEVGROUP } type TYPE [ ARGS ]

       ip link set { DEVICE | dev DEVICE | group DEVGROUP }
                          [ { up | down } ]
                          [ type TYPE ARGS ]
                          [ arp { on | off } ]
                          [ dynamic { on | off } ]
                          [ multicast { on | off } ]
                          [ allmulticast { on | off } ]
                          [ promisc { on | off } ]
                          [ trailers { on | off } ]
                          [ carrier { on | off } ]
                          [ txqueuelen PACKETS ]
                          [ name NEWNAME ]
                          [ address LLADDR ]
                          [ broadcast LLADDR ]
                          [ mtu MTU ]
                          [ netns { PID | NAME } ]
                          [ link-netnsid ID ]
                          [ alias NAME ]
                          [ vf NUM [ mac LLADDR ]
                                   [ vlan VLANID [ qos VLAN-QOS ] [ proto VLAN-PROTO ] ]
                                   [ rate TXRATE ]
                                   [ max_tx_rate TXRATE ]
                                   [ min_tx_rate TXRATE ]
                                   [ spoofchk { on | off} ]
                                   [ query_rss { on | off} ]
                                   [ state { auto | enable | disable} ] ]
                                   [ trust { on | off} ] ]
                                   [ node_guid { eui64 } ]
                                   [ port_guid { eui64 } ]
                          [ xdp { off |
                                  object FILE [ section NAME ] [ verbose ] |
                                  pinned FILE } ]
                          [ master DEVICE ][ vrf NAME ]
                          [ nomaster ]
                          [ addrgenmode { eui64 | none | stable_secret | random } ]
                          [ protodown { on | off } ]

       ip link show [ DEVICE | group GROUP ] [up] [master DEV] [vrf NAME] [type TYPE]

       ip link xstats type TYPE [ ARGS ]

       ip link afstats [ dev DEVICE ]

       ip link help [ TYPE ]

TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |
          bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan |
          gre | gretap | ip6gre | ip6gretap | vti | nlmon | team_slave |
          bond_slave | ipvlan | geneve | bridge_slave | vrf | macsec }
……

Continue reading

iptables详解

k8siptable 了解

https://blog.csdn.net/qq_36183935/article/details/90734847

iptables工作流程

iptables是采用数据包过滤机制工作的,所以它会对请求的数据包的包头进行分析,并根据我们预先设定的规则进行匹配来决定是否可以进入主机。

① 防火墙是一层一层过滤的。实际是按照配置规则的顺序从上到下,从前到后进行过滤的; ② 如果匹配上规则,即明确表明阻止还是通过,此时数据包就不再向下匹配新规则了; ③ 如果所有规则中没有明确表明是阻止还是通过这个数据包,也就是没有匹配上规则,则按照默认策略进行处理; ④ 防火墙的默认规则是对应的链的所有的规则执行完成后才会执行的;

……

Continue reading

k8s downward API

前面我们从pod的原理到生命周期介绍了pod的一些使用,作为kubernetes中最核心的对象,最基本的调度单元,我们可以发现pod中的属性还是非常繁多的,前面我们使用过一个volumes的属性,表示声明一个数据卷,我们可以通过命令kubectl explain pod.spec.volumes去查看该对象下面的属性非常多,前面我们只是简单的使用了hostpath和empryDir{}这两种模式,其中还有一种叫做downwardAPI这个模式和其他模式不一样的地方在于它不是为了存放容器的数据也不是用来进行容器和宿主机的数据交换的,而是让pod里的容器能够直接获取到这个pod对象本身的一些信息。

……

Continue reading

linux tmp文件

tmp是temporary的缩写,这个目录是用来存放一些临时文件。/tmp是Linux下的临时文件夹。

该文件夹中的内容一般不会删除,以redhat为例,系统自动清理/tmp文件夹的默认时限是30天。30天不访问的/tmp下的文件会被系统自动删除。

/tmp-临时文件目录,能够被任何用户,任何程序访问,一般用来存放程序的临时文件,所以应该定期清理一下。FHS甚至建议在开机时,应该要将/tmp下的数据都删除,临时目录还有/var/tmp

……

Continue reading

linux_lldptool

1
2
3
4
5
[root@localhost ~]# lldptool set-lldp -i eno2 adminStatus=rxtx;
[root@localhost ~]# lldptool -T -i eno2 -V sysName enableTx=yes;
[root@localhost ~]# lldptool -T -i eno2 -V portDesc enableTx=yes;
[root@localhost ~]# lldptool -T -i eno2 -V sysDesc enableTx=yes;
[root@localhost ~]# lldptool -T -i eno2 -V sysCap enableTx=yes;
……

Continue reading

linux用户态与内核态

一. 概念

  • 操作系统 - 管理计算机硬件与软件资源的软件.是用户与系统交互的操作接口.为它上面运行的程序提供服务.
  • 操作系统内核 - 操作系统的核心.负责管理系统的进程.内存.设备驱动程序.文件和网络系统.一个内核不是一套完整的操作系统.如Linux.
  • Linux操作系统 - 基于Linux 内核的操作系统.通常由Linux内核.shell(特殊的应用程序.提供运行其他程序的接口).文件系统和应用程序.

linux体系结构

参考图:

……

Continue reading

shell中=和~的用法

shell 中 =~ 的用法

我们先看一个脚本,该脚本的功能是搜索当前目录下文件中的指定字符串

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#!/bin/bash
apath=$1;acontent=$2;aexp=$3;

if [[ $aexp =~ all ]] ;then                                                                                                                                                        
    atype=''
else
    atype=".$aexp"
fi

find $apath  -name  "*"$atype -type f -print0 | xargs -0 grep --color -rn "$acontent"

if [[ $aexp =~ all ]] 其中 ~是对后面的正则表达式匹配的意思,如果匹配就输出1,不匹配就输出0

……

Continue reading

SNAT和DNAT

参考

SNAT

In Source Network Address Translation (SNAT), the NAT router modifies the IP address of the sender in IP packets. SNAT is commonly used to enable hosts with private addresses to communicate with servers on the public Internet.

RFC 1918 reserves the following three subnets as private addresses:

10.0.0.0/8

172.16.0.0/12

192.168.0.0/16

DNAT

In Destination Network Address Translation (DNAT), the NAT router modifies the IP address of the destination in IP packet headers.

OpenStack uses DNAT to route packets from instances to the OpenStack metadata service. Applications running inside of instances access the OpenStack metadata service by making HTTP GET requests to a web server with IP address 169.254.169.254. In an OpenStack deployment, there is no host with this IP address. Instead, OpenStack uses DNAT to change the destination IP of these packets so they reach the network interface that a metadata service is listening on.

……

Continue reading