#!/bin/bash

##检查当前是否禁用ip转发

if sysctl -n net.ipv4.ip_forward | grep -q "^0$"; then
	echo "IP转发已禁用!"
else
	#临时禁用IP转发
	sysctl -w net.ipv4.ip_forward=0
	#确保系统重启后也禁用IP转发
	echo "net.ipv4.ip_forward = 0" >> /etc/sysctl.conf
	echo "IP转发已禁用。"
fi

## 检查设置是否生效
echo "当前IP转发状态："
sysctl -n net.ipv4.ip_forward
