配置 DOCKER-USER链 以限制或允许Docker容器的访问

1.查看现有规则 DOCKER-USER 链的规则是否生效与 链的优先级 和 规则顺序相关 sudo iptables -L DOCKER-USER --line-numbers 2.添加规则 允许已建立的连接(必须放在最前面) sudo iptables -I DOCKER-USER -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT 允许 192.168.1.100 访问所有 Docker 容器: sudo iptables -I DOCKER-USER -s 192.168.1.100 -j ACCEPT 允许 192.168.1.100 访问 Docker 容器时,仅允许访问 TCP 80 端口 sudo iptables -I DOCKER-USER -p tcp --dport 80 -s 192.168.1.100 -j ACCEPT 添加规则到指定位置 sudo iptables -I DOCKER-USER 3 -p tcp --dport 80 -s 192.168.1.101 -j ACCEPT 参数说明: -I在最前面插入 3.禁止其他所有 IP 的访问 注意iptables规则是从上往下执行的所以这条命令要放在最下面 ...

February 19, 2025 · 1 min · ming

Docker安装Hugo

1.启动一个nginx容器把hugo打包好的文件映射到该容器 docker-compose.yml services: nginx: image: nginx:latest container_name: hugo restart: 'unless-stopped' ports: - "1317:80" volumes: - ./www:/www - ./nginx.conf:/etc/nginx/conf.d/default.conf nginx.conf server { listen 80; server_name localhost; location / { root /www/blog/public; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /www/blog/public; } } 启动: sudo docker compose up -d 2.进入www并创建站点 cd www hugo new site blog 3.安装主题我以PaperMod来演示 进入blog目录 ...

February 15, 2025 · 3 min · ming

PVE去除Web端弹窗和更换社区源

Web端去除弹窗 sed -i_orig "s/data.status === 'Active'/true/g" /usr/share/pve-manager/js/pvemanagerlib.js sed -i_orig "s/if (res === null || res === undefined || \!res || res/if(/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js sed -i_orig "s/.data.status.toLowerCase() !== 'active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js systemctl restart pveproxy 去除企业源使用社区源 1.把以下文件中的内容注释掉 /etc/apt/sources.list.d/ceph.list /etc/apt/sources.list.d/pve-enterprise.list 2.在/etc/apt/sources.list文件中添加社区源 deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription

August 13, 2024 · 1 min · ming

Git编译安装

1.安装依赖 sudo apt install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev make 2.下载git源码 wget https://www.kernel.org/pub/software/scm/git/git-2.46.0.tar.gz -O git.tar.gz 3.解压缩源码 tar -zxf git.tar.gz cd git-* 4.编译安装git make prefix=/usr/local all sudo make prefix=/usr/local install 5.验证安装 git --version

August 6, 2024 · 1 min · ming

Fish-Shell编译安装

1.安装依赖 sudo apt update sudo apt install build-essential cmake ncurses-dev 2.下载fish wget https://github.com/fish-shell/fish-shell/releases/download/3.7.1/fish-3.7.1.tar.xz tar -xf fish-3.7.1.tar.xz cd fish-3.7.1 3.编译安装 Fish make sudo make install 4.验证安装 fish --version 5.设置fish为默认 shell 确认 Fish 的路径 which fish 6.将Fish路径添加到 /etc/shells echo "/usr/bin/fish" | sudo tee -a /etc/shells 7.更改默认 shell chsh -s /usr/local/bin/fish 8.重新登录 退出当前会话并重新登录,或者重启终端,以使更改生效 9.验证更改 echo $SHELL

August 6, 2024 · 1 min · ming

Ubuntu安装NVIDIA驱动

1.更新系统 sudo apt update sudo apt upgrade 2.搜索并安装适用的驱动 sudo ubuntu-drivers devices 3.选择并安装推荐的驱动程序和设置DKMS密码 sudo apt install nvidia-driver-xxx 4.列出所有与NVIDIA相关的已安装包 dpkg -l | grep -i nvidia 5.重启系统 sudo reboot 6.DKMS密钥 选择 Enroll MOK 选择 Continue 选择 Yes 输入 密码 重启 7.验证驱动程序是否正确安装 nvidia-smi 每秒更新一次 GPU 状态 watch -n 1 nvidia-smi 8.禁用安全启动(可选) 装完驱动发现无法使用 nvidia-smi 命令,并提示以下内容 NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running. 这时候,可以试试关闭虚拟机的安全启动,原因是因为驱动签名验证无法通过 ...

August 5, 2024 · 1 min · ming

PVE独显直通

在 Proxmox VE 上进行独立显卡直通(GPU passthrough)操作,可以将物理显卡直接分配给虚拟机,从而提升虚拟机的图形性能。 前提条件 硬件支持:确保你的 CPU 和主板支持 IOMMU(Intel VT-d 或 AMD-Vi) BIOS 设置:在 BIOS 中启用 IOMMU 和相关设置(Intel VT-d 或 AMD-Vi) 硬件环境: CPU: AMD Ryzen 5 3600X Motherboard: MSI MAG B550M GPU: Nvidia 1650S 1.更改BIOS设置 重置BIOS为默认设置 Settings\Save & Exit\Restore Defaults 关闭S/3Modern Standby Support(可选) Settings\Advanced\ACPI Settings\S/3Modern Standby Support [Disabled] 设置Initiate Graphic Adaptor为外置显卡 Settings\Advanced\Initiate Graphic Configuration\Initiate Graphic Adaptor [PEG] 设置Integrated Graphics为Force Mode Settings\Advanced\Initiate Graphic Configuration\Integrated Graphics [Force] 打开主板IOMMU Overclocking\Advanced CPU Configuration\AMD CBS\IOMMU [Enabled] 打开CPU虚拟化 Overclocking\Advanced CPU Configuration\SVM Mode [Enabled] 2.启用 IOMMU 编辑 /etc/default/grub 文件,找到 GRUB_CMDLINE_LINUX_DEFAULT 行,并添加 ...

August 5, 2024 · 1 min · ming