NICS=$(ip link show | awk -F': ' '/^[0-9]+:/{print $2}' | grep -vE '^(lo|vmbr|tap|veth|bond|dummy|fwbr|fwln|fwpr|docker|br-)')

cat > /etc/systemd/system/off_tso.service << EOF
[Unit]
Description=Turn off TSO/GSO/GRO and EEE for all NICs
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
$(for nic in $NICS; do
echo "ExecStart=/usr/sbin/ethtool -K $nic tso off"
echo "ExecStart=/usr/sbin/ethtool -K $nic gso off"
echo "ExecStart=/usr/sbin/ethtool -K $nic gro off"
done)
ExecStart=/bin/bash -c 'for nic in $NICS; do ethtool --set-eee \$nic eee off 2>/dev/null || true; done'

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now off_tso.service
systemctl status off_tso.service

标签: none

添加新评论