Skip to content

Instantly share code, notes, and snippets.

View chenchun's full-sized avatar
🦖
go for{vacation()}

Chun Chen chenchun

🦖
go for{vacation()}
View GitHub Profile
@chenchun
chenchun / debug_ipip.md
Last active August 5, 2019 05:24
flannel vxlan ipip

debug两台机器ipip是否通

#10.59.194.141上执行下面创建的ipip0网卡:
node=10.59.194.141
peer=10.59.194.154
ip tun add ipip0 mode ipip remote $peer local $node
ip link set ipip0 up
ip add add 192.168.200.1 brd 255.255.255.255 peer 192.168.200.2 dev ipip0
ip ro add 192.168.200.0/24 via 192.168.200.1
主机1--路由器1--网络--路由器2--主机2
这样的组网模型中,从主机1 ping 主机2,网络通信的基本原理是怎样的?
2、路由基本原理
将整个ping包过程进行分解,步骤如下:
1)主机1发送ping包前,需要先进行arp相关操作,具体包括:
(1)检查dst ip和local ip,如果不是在同一个网段(本例就不是一个网段),则查看本地arp缓存,确认是否有网关(路由器1)IP对应的mac地址,如果没有,则向网关发送arp请求包。
(2)本地网关收到其arp包后,回复相应的mac地址。
(3)主机1收到arp回复,得到网关mac,更新相应的arp缓存。
2)主机向路由器1发送ping数据包,数据包的dst IP仍为主机2的IP,但dst MAC为路由器1的MAC。
@chenchun
chenchun / ipint.go
Created September 16, 2016 08:03 — forked from ammario/ipint.go
Golang ip <-> int conversion
func ip2int(ip net.IP) uint32 {
if len(ip) == 16 {
return binary.BigEndian.Uint32(ip[12:16])
}
return binary.BigEndian.Uint32(ip)
}
func int2ip(nn uint32) net.IP {
ip := make(net.IP, 4)
binary.BigEndian.PutUint32(ip, nn)
@chenchun
chenchun / vxlan.sh
Last active August 21, 2019 07:29
setup unicast vxlan on two hosts
## 10.2.0.3
ip link add vxlan0 type vxlan id 2 dev eth1 dstport 8472
ip link set dev vxlan0 address 72:74:8b:9d:56:e4
ip link set dev vxlan0 up
ip ad add 192.168.50.1/24 dev vxlan0
vxlan_dev=vxlan0
peer_vxlan_mac=3e:33:f7:c5:a3:5b
peer_vxlan_ip=192.168.50.2
peer_host_ip=10.2.0.2
@chenchun
chenchun / connect-apiserver.md
Last active July 30, 2018 07:39
kubernetes apiserver #apiserver #k8s #kubernetes

In the diagram below you can see the full authentication flow with all options, starting with the browser on the lower left hand side.


Kubernetes                                                  Workstation
+---------------------------------------------------+     +------------------+
|                                                   |     |                  |
|  +-----------+   apiserver        +------------+  |     |  +------------+  |
|  |           |   proxy            |            |  |     |  |            |  |
|  | apiserver |                    |  ingress   |  |     |  |  ingress   |  |
@chenchun
chenchun / close_nf_conntrack.sh
Last active November 12, 2020 07:14
bash expect, close nf_conntrack
#!/usr/bin/expect -f
set node [lindex $argv 0]
set passwd [lindex $argv 1]
set timeout 30
spawn ssh root@$node
expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "$passwd\r" }
}
expect "*#"
@chenchun
chenchun / infinite_arp.sh
Last active July 30, 2018 08:17
#hairpin mode
ip link add br0 type bridge
ip link add br1 type bridge
ip link add dev v0 type veth peer name v1
ip link set v0 master br0
ip link set v1 master br1
ip link set br0 up
ip link set br1 up
ip link set v0 up
ip link set v1 up
ip ad add 192.168.0.1/24 dev br0
@chenchun
chenchun / gist:4a6fcce0eed1e6a842f722f1d69197d5
Created November 13, 2017 04:41 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: