使用 etcdctl 访问 Kubernetes 数据
By luckymrwang
By luckymrwang
By luckymrwang
我在PREROUTING上做了一个REDIRECT端口改写,相应的服务处理请求后会返回应答。
按照我以往的认识,认为回包的流量应该先后经过OUTPUT和POSTROUTING,所以我利用iptables -t nat -nvL去查看NAT表在OUTPUT链和POSTROUTING链上的packge计数器,结果发现没有上涨,这让我陷入了沉思。
经过谷歌后找到了完美的解释:linux-netfilter-how-does-connection-tracking-track-connections-changed-by-nat。
By luckymrwang
By luckymrwang
iptables已开启并激活1
2
3
4
5
6
7
PORT=53
which sudo || alias sudo='$@'
sudo iptables -t raw -A OUTPUT -p udp --dport $PORT -j TRACE
sudo iptables -t raw -A OUTPUT -p tcp --dport $PORT -j TRACE
sudo iptables -t raw -A PREROUTING -p udp --dport $PORT -j TRACE
sudo iptables -t raw -A PREROUTING -p tcp --dport $PORT -j TRACE
By luckymrwang
BPF 的全称是 Berkeley Packet Filter, 即伯克利报文过滤器,它的设计思想来源于 1992 年的一篇论文"The BSD packet filter: A New architecture for user-level packet capture" (《BSD数据包过滤器:一种用于用户级数据包捕获的新体系结构》)。最初,BPF是在 BSD 内核实现的, 后来,由于其出色的设计思想,其他操作系统也将其引入, 包括 Linux。tcpdump 使用的libpcap是基于BPF的,在使用tcpdump或者libpcap时传入的"host 192.168.1.1"、"tcp and port 80"等是过滤表达式。
By luckymrwang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# man iptables
...
-j, --jump target
This specifies the target of the rule; i.e., what to do if the packet matches it. The target can be a user-
defined chain (other than the one this rule is in), one of the special builtin targets which decide the fate of
the packet immediately, or an extension (see EXTENSIONS below). If this option is omitted in a rule (and -g is
not used), then matching the rule will have no effect on the packet's fate, but the counters on the rule will be
incremented.
-g, --goto chain
This specifies that the processing should continue in a user specified chain. Unlike the --jump option return will
not continue processing in this chain but instead in the chain that called us via --jump.
By luckymrwang
本文将基于cURL命令简单演示如何以REST的方式使用Kubernetes API,方便您使用开发语言原生的HTTPS方式操作Kubernetes集群。演示包括创建和删除Pod,创建和修改Deployment。
1
2
3
cat ./kubeconfig |grep client-certificate-data | awk -F ' ' '{print 2ドル}' |base64 -d > ./client-cert.pem
cat ./kubeconfig |grep client-key-data | awk -F ' ' '{print 2ドル}' |base64 -d > ./client-key.pem
APISERVER=`cat ./kubeconfig |grep server | awk -F ' ' '{print 2ドル}'`
By luckymrwang
显示所有活动的网络连接
1
netstat -na
查看同时连接到哪个服务器 IP 比较多,cc 攻击用。使用双网卡或多网卡可用
1
netstat -an|awk '{print 4ドル}'|sort|uniq -c|sort -nr|head
By luckymrwang
By luckymrwang
本次演講主要是探討封包基於 Docker Container 的預設環境下,不同走向實際上對應到 iptables/ebtables 的實際流向。
演講中主要針對三個方向進行探討,分別是
每個方向都包含了雙向來回,譬如Host to Container 其實也包含了 Container to HostContainer to WAN 也包含了 WAN to Containe
主要差別在於誰發起了連線,這中間差異不大 (WAN to Container 可能會有 DNAT)