请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

关于lbvipfip的脚本

老师您好,请问lbvipfip这个绑定公网ip的脚本可以分享吗?

期待您的回复,感谢!

正在回答

插入代码

2回答

你好,感谢提问。

我找一下这个脚本,会上传到课程的代码仓库中。

0 回复 有任何疑惑可以回复我~
  • 提问者 白聪聪 #1
    谢谢老师,麻烦了!
    回复 有任何疑惑可以回复我~ 2024-09-26 13:10:26
孔令贤 2024-09-26 17:02:58

同学你好,原来的脚本已经找不到了,但大概的流程如下,请参考:

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
#!/bin/bash
 
# Load balancer ID passed as the first argument
LOAD_BALANCER_ID=$1
 
if [ -z "$LOAD_BALANCER_ID" ]; then
  echo "Usage: $0 <load_balancer_id>"
  exit 1
fi
 
# Get the port ID and private IP of the load balancer
PORT_ID=$(openstack loadbalancer show $LOAD_BALANCER_ID -c vip_port_id -f value)
PRIVATE_IP=$(openstack loadbalancer show $LOAD_BALANCER_ID -c vip_address -f value)
 
if [ -z "$PORT_ID" ] || [ -z "$PRIVATE_IP" ]; then
  echo "Failed to get port ID or private IP for load balancer $LOAD_BALANCER_ID"
  exit 1
fi
 
# Allocate a floating IP from the default public network
FLOATING_IP=$(openstack floating ip create public -c floating_ip_address -f value)
 
if [ -z "$FLOATING_IP" ]; then
  echo "Failed to allocate floating IP"
  exit 1
fi
 
# Associate the floating IP with the port
openstack floating ip set --port $PORT_ID $FLOATING_IP
 
if [ $? -eq 0 ]; then
  echo "Floating IP $FLOATING_IP successfully associated with load balancer $LOAD_BALANCER_ID (private IP: $PRIVATE_IP)"
else
  echo "Failed to associate floating IP with the port"
fi


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号