【Liunx-脚本】通过接口updown控制conntrack重置会话

一、应用场景 vyos系统有俩个WAN接口,针对WAN1和WAN2的网关做了failover,并在WAN1和WAN2接口上配置NAT,默认路由默认走WAN1,当WAN1接口down走WAN2。 二、场景问题 vyos系统的NAT存在问题,当WAN1接口down后,默认路由走WAN2出去,此时NAT在WAN2口生效,但是当WAN1口up后,failover重新生效,默认路由切回WAN1口,此时NAT没有切回WAN1,而是走了WAN2,导致用户不能上网。 三、解决方案 通过底层配置本脚本,抓去WAN1口物理状态,刷新conntrack,当WAN1口up后,failover重新生效,脚本运行重置conntrack,当WAN1口down后,脚本运行conntrack。 四、 创建脚本 4.1、进入root模式 root -i 4.2、创建脚本文件路径 mkdir pathcd pathmkdir to cd to 4.3、创建脚本文件 touch monitor_interface.sh #创建chmod +x monitor_interface.sh #赋权nano monitor_interface.sh #编辑 #!/bin/bashinterface="eth1"state_file="/tmp/eth1_state"# 如果状态文件不存在,则创建一个空文件touch "$state_file"# 获取当前状态get_interface_state() { ip link show "$interface" | awk '/state/ {print $9}'}# 读取之前的状态last_state=$(cat "$state_file" 2>/dev/null)# 获取当前物理接口状态current_state=$(get_interface_state)# 如果当...

avatar 杨杨得亿 发表于 2023-11-24

【Liunx-脚本】通过接口updown控制conntrack重置会话

一、应用场景 vyos系统有俩个WAN接口,针对WAN1和WAN2的网关做了failover,并在WAN1和WAN2接口上配置NAT,默认路由默认走WAN1,当WAN1接口down走WAN2。 二、场景问题 vyos系统的NAT存在问题,当WAN1接口down后,默认路由走WAN2出去,此时NAT在WAN2口生效,但是当WAN1口up后,failover重新生效,默认路由切回WAN1口,此时NAT没有切回WAN1,而是走了WAN2,导致用户不能上网。 三、解决方案 通过底层配置本脚本,抓去WAN1口物理状态,刷新conntrack,当WAN1口up后,failover重新生效,脚本运行重置conntrack,当WAN1口down后,脚本运行conntrack。 四、 创建脚本 4.1、进入root模式 root -i 4.2、创建脚本文件路径 mkdir pathcd pathmkdir to cd to 4.3、创建脚本文件 touch monitor_interface.sh #创建chmod +x monitor_interface.sh #赋权nano monitor_interface.sh #编辑 #!/bin/bashinterface="eth1"state_file="/tmp/eth1_state"# 如果状态文件不存在,则创建一个空文件touch "$state_file"# 获取当前状态get_interface_state() { ip link show "$interface" | awk '/state/ {print $9}'}# 读取之前的状态last_state=$(cat "$state_file" 2>/dev/null)# 获取当前物理接口状态current_state=$(get_interface_state)# 如果当...

avatar 杨杨得亿 发表于 2023-11-24

Rollup

一个小巧强大的ESM打包器

avatar 轻笑Chuckle 发表于 2023-11-15

绿色魔法All in One,一键开启,稳定高速🚀

一、项目地址:点击直达 二、使用指导:右键图片在新标签页中打开 三、防失联下载:Chrome+Edge+Firofox:点击直达

avatar 杨杨得亿 发表于 2023-11-07

绿色魔法All in One,一键开启,稳定高速🚀

一、项目地址:点击直达 二、使用指导:右键图片在新标签页中打开 三、防失联下载:Chrome+Edge+Firofox:点击直达

avatar 杨杨得亿 发表于 2023-11-07

Webpack

从Webpack开始的前端工程化探索

avatar 轻笑Chuckle 发表于 2023-11-05

路由基础知识

Routing Fundamentals 路由基础知识 Fundamentals: 基础知识 Terminology 术语 First, you will see these terms being used throughout the documentation. Here’s a quick reference: 首先,你会在整个文档中看到这些术语。下面是一个快速参考: throughout: 从头到尾 Tree: A convention for visualizing a hierarchical structure. For example, a component tree with parent and children components, a folder structure, etc. 树:可视化分层结构的公约。例如包含父组件和子组件的组件树、文件夹结构等。 Subtree: Part of a tree, starting at a new root (first) and ending at the leaves (last). Root: The first node in a tree or subtree, such as a root layout. Leaf: Nodes in a subtree that have no children, such as the last segment in a URL path. convention: 公约 visualizing: 可视化的 hierarchical:分层的 URL Segment: Part of the URL path delimited by slashes. URL Path: Part of the URL that comes after the domain ...

avatar 阿紫的博客网站 发表于 2023-10-30

路由基础知识

Routing Fundamentals 路由基础知识 Fundamentals: 基础知识 Terminology 术语 First, you will see these terms being used throughout the documentation. Here’s a quick reference: 首先,你会在整个文档中看到这些术语。下面是一个快速参考: throughout...

avatar 阿紫的博客网站 发表于 2023-10-30

7 月 4 日在家躺尸的我叫上哥哥妹妹以及远在上海朋友打开了Minecraft一起做方块人。

avatar 宇生の后花园 发表于 2023-10-19

7 月 4 日在家躺尸的我叫上哥哥妹妹以及远在上海朋友打开了Minecraft一起做方块人。

avatar 宇生の后花园 发表于 2023-10-19