Skip to content

Commit

Permalink
merge code
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Jun 15, 2024
2 parents c5c69ec + ba2f33f commit a7d310c
Show file tree
Hide file tree
Showing 23 changed files with 1,502 additions and 5 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

```shell

git clone -b main https://github.com/jingjingxyk/build-static-nginx.git
git clone --recursive -b https://github.com/jingjingxyk/build-static-nginx.git

# or

git clone --recursive -b nginx https://github.com/jingjingxyk/swoole-cli.git

Expand Down Expand Up @@ -67,9 +69,8 @@ bash build-release.sh
* `build-static-nginx` 使用了多个其他开源项目,请认真阅读自动生成的 `bin/LICENSE`
文件中版权协议,遵守对应开源项目的 `LICENSE`
* `build-static-nginx`
本身的软件源代码、文档等内容以 `Apache 2.0 LICENSE`+`SWOOLE-CLI LICENSE`
作为双重授权协议,用户需要同时遵守 `Apache 2.0 LICENSE``SWOOLE-CLI LICENSE`
所规定的条款
* 本身的软件源代码、文档等内容以 `Apache 2.0 LICENSE`+`SWOOLE-CLI LICENSE`
* 作为双重授权协议,用户需要同时遵守 `Apache 2.0 LICENSE``SWOOLE-CLI LICENSE`所规定的条款

## SWOOLE-CLI LICENSE

Expand Down
103 changes: 103 additions & 0 deletions sapi/quickstart/linux/SDN/OVN/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

## 常用命令

```bash
ovn-nbctl show
ovn-sbctl show

ovn-sbctl lflow-list

ovn-sbctl list chassis


ovn-nbctl get-connection
ovn-sbctl get-connection

ss -tuxlpn | grep -e '^\s*tcp\s.*\b:664[0-5]\b' -e '^\s*udp\s.*\b:6081\b' -e '^\s*u_str\s.*\bovn\b' | sed -r -e 's/\s+$//'

```

```bash

ovn-nbctl lr-policy-list lr01
ovn-nbctl lr-route-list lr01
ovn-nbctl ls-lb-list ls10
ovn-nbctl list address_set
ovn-nbctl list acl
ovn-sbctl show
ovn-nbctl find logical_router_policy priority=100


ovn-nbctl list logical_router
ovn-nbctl list logical_router_port
ovn-nbctl list logical_switch
ovn-nbctl list logical_switch_port

```

```bash

ovn-nbctl show
ovn-nbctl lr-policy-list ovn-cluster
ovn-nbctl lr-route-list ovn-cluster
ovn-nbctl ls-lb-list ovn-default
ovn-nbctl list address_set
ovn-nbctl list acl

ovn-nbctl list dhcp_options

ovn-nbctl list gateway_chassis
ovn-nbctl find NAT type=snat

ovn-sbctl list chassis
ovn-sbctl list port_binding
ovn-sbctl show

ovn-sbctl --bare --columns name find Chassis hostname=ovn-gateway-test-01

ovs-appctl ovs/route/show

```

```bash

ovn-nbctl list Logical_Switch

ovn-nbctl list Logical_Switch_Port

ovn-nbctl list ACL

ovn-nbctl list Logical_Router

ovn-nbctl list Logical_Router_Port

ovn-nbctl list Logical_Router_Static_Route

ovn-nbctl list NAT

ovn-nbctl list DHCP_Options

ovn-nbctl list Gateway_Chassis



ovn-sbctl list Chassis

ovn-sbctl list Encap

ovn-sbctl lflow-list

ovn-sbctl --ovs lflow-list

ovn-sbctl list Multicast_Group

ovn-sbctl list Datapath_Binding

ovn-sbctl list Port_Binding

ovn-sbctl list MAC_Binding

ovn-sbctl list DHCP_Options

ovn-sbctl list Gateway_Chassis
```
124 changes: 124 additions & 0 deletions sapi/quickstart/linux/SDN/OVS/bind-nic-eth0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# 交换机连接外网



```bash
ss -tlnp

ip route show
ip route list

ifconfig

ip route show table main

ip address show

ip -f inet addr show

ip a show eth0

arp -a

ip -s link

lsmod | grep openvswitch


cat /etc/systemd/resolved.con

cat /etc/netplan/50-cloud-init.yaml


systemctl is-active systemd-resolved

systemctl status systemd-resolved
systemctl restart systemd-resolved


systemctl stop systemd-resolved



systemctl status systemd-networkd


```



## 查看网关配置

```bash

route -v
# or
netstat -rn

ip route show table local

```


```bash

lsmod | grep openvswitch

systemctl status networking #old
systemctl status NetworkManager #new


```


## 手动配置网络
```bash

vi /etc/network/interfaces

auto eth0
iface eth0 inet static
address 192.168.0.55 #ip地址
gateway 192.168.0.1 #网关
netmask 255.255.255.0 #子网掩码
broadcast # 广播地址


systemctl restart networking

or

/etc/init.d/networking restart


```


```bash

dhclient -r eth0

```


```bash

iptables -m conntrack --ctstate NEW

```

```bash

ifconfig <interface_name> alias <new_alias_name> up

ifconfig -a

```

```bash

ip route add <DESTINATION> via <GATEWAY>

ip route add <DESTINATION> via <GATEWAY> <dev> INTERFACE

```
105 changes: 105 additions & 0 deletions sapi/quickstart/linux/SDN/OVS/bind-nic-eth0/bind-br-eth0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/env bash

set -eux

__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}

ovs-vsctl --if-exists del-br br-eth0
ovs-vsctl add-br br-eth0 # 添加网桥
ip link set br-eth0 up # 激活网桥

{
# 本机IP地址: 172.16.124.59
# 本机网关: 172.16.127.253
# 本机掩码: 255.255.240.0
# 广播地址: 172.16.127.255

ip addr add 172.16.124.60/20 dev br-eth0
ip route replace default via 172.16.127.253 dev br-eth0

ip route add 100.100.2.136 via 172.16.127.253 dev br-eth0
ip route add 100.100.2.138 via 172.16.127.253 dev br-eth0
ip route add 0.0.0.0/0 via 172.16.127.253 dev br-eth0

# 测试例子
# ip route del 100.100.2.136
# ip route del 100.100.2.138
# ip route del 172.16.112.0/20

# ip route replace default via 192.168.0.1 dev br-eth0
# ip route change default via 192.168.0.1 dev br-eth0 src 192.168.0.27


# ip route del 192.168.0.27/24 via 0.0.0.0
# ip route add 192.168.0.27/24 via 0.0.0.0 dev br-eth0
# ip route change default via 192.168.0.1 dev br-eth0

# ip route add default via 192.168.10.1 dev eth0
# ip route add default via 192.168.0.1 dev br-eth0

# ip route add <DESTINATION> via <GATEWAY> <dev> INTERFACE
# ip route add 0.0.0.0 via 192.168.0.1 dev br-eth0
# ip route change default via 192.168.0.1 dev br-eth0

} ||
{
echo $?
}

ovs-vsctl add-port br-eth0 eth0
ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=external-network-provider:br-eth0

ip addr flush dev eth0

sysctl -w net.ipv4.ip_forward=1
# iptables -t nat -A POSTROUTING -s 10.1.20.0/24 -o br-eth0 -j MASQUERADE

ip a


systemctl stop systemd-resolved

exit 0

ovs-dpctl show
ovs-dpctl dump-flows
ovs-appctl ovs/route/show
ovs-ofctl show br-int

exit 0



iptables -t nat -L -n --line-number

#iptables -t nat -A POSTROUTING -s 10.10.92.1/24 ! -d 10.10.92.1/24 -j SNAT --to-source 172.17.14.125
#iptables -t nat -A POSTROUTING -s 10.10.92.0/24 -o br-eth0 -j MASQUERADE # eth0连接外网
#iptables -A FORWARD -i eth0 -o veth-a -j ACCEPT
#iptables -A FORWARD -i veth-a -o eth0 -j ACCEPT

iptables -t nat -L -n --line-number
# iptables -t nat -D POSTROUTING 21

#iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to 你的eth0地址
iptables -t nat -A POSTROUTING -s 10.10.92.0/24 -o br-eth0 -j SNAT --to-source 172.17.14.125
iptables -t nat -A POSTROUTING -s 10.10.92.1 -o br-eth0 -j SNAT --to-source 172.17.14.125
iptables -t nat -A POSTROUTING -s 10.10.92.1/24 -o br-eth0 -j MASQUERADE
iptables -A PREROUTING -t nat -j DNAT -p tcp --dport 8090 -i $if_oam --to 192.168.9.217:8090

ip route add 192.168.10.0/24 via 172.17.14.125 src 10.10.92.1

iptables -t nat -A PREROUTING -d 10.10.92.1 -j DNAT --to-destination 10.10.92.2

route del default gw 192.168.1.1
ip route add 10.10.92.1 via 172.17.14.125



ip route change default via 172.17.63.253 dev br-eth0

ip route show | column -t

35 changes: 35 additions & 0 deletions sapi/quickstart/linux/SDN/OVS/bind-nic-eth0/unbind-br-eth0.sh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/env bash

set -eux

__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}

ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=' '

{
ip addr add 172.16.124.60/20 dev eth0

ip route replace default via 172.16.127.253 dev eth0

ip route add 100.100.2.136 via 172.16.127.253 dev eth0
ip route add 100.100.2.138 via 172.16.127.253 dev eth0
ip route add 0.0.0.0 via 172.16.127.253 dev eth0

} || {
echo $?
}


ovs-vsctl --if-exists del-port eth0

ip addr flush dev br-eth0

ovs-vsctl --if-exists del-br br-eth0

ip a


Loading

0 comments on commit a7d310c

Please sign in to comment.