2025年2月

openwrt 23.x开始,dnsmasq-full不在支持ipset合集了。改为支持nftset了。原来还有为nftables安装iptables才能够对IP地址进行转发。改为nftset后可以直接和nftables配合使用。

1.创建nftset。在创建nftset合集是可以使用inet、ip、ip6等对IP地址合集进行定义,我这里使用inet。

nft add table inet iplistall
nft add set inet iplistall ip4list { type ipv4_addr ;}
nft add set inet iplistall ip6list { type ipv6_addr ;}

2.创建nftables规则,根据规则将nftset合集中的IP地址按照规则进行转发。

nft add chain inet iplistall output { type filter hook output priority 0 ; policy accept ; }
nft add chain inet iplistall prerouting { type nat hook prerouting priority dstnat ; policy accept ; }
nft add rule inet iplistall prerouting ip daddr @ip4list udp dport 0-65535 counter redirect to :1080
nft add rule inet iplistall prerouting ip daddr @ip4list tcp dport 0-65535 counter redirect to :1080



3.在dnsmasq中对相应的域名配置使用nftset。

nftset=/docker.com/4#inet#iplistall#ip4list
nftset=/docker.com/6#inet#iplistall#ip6list

4.相关命令
a.查看所有tables。nft list tables
b.查看nftset 地址合集 。 nft list set inet iplistall ip4list
c.查看nft规则列表。 nft list ruleset

5.参考资源
a.https://nie11kun.github.io/archives/dnsmasq-nftset-nftables-1.html https://github.com/v2fly/domain-list-community/blob/master/data/netflix
b.chatgpt
c.doubao

参考页面信息:https://openwrt.org/docs/guide-user/virtualization/vmware?s%5B%5D=esxi

在Linux下调整img文件的分区大小

1.准备工作

本操作需要用到qemu-img fdisk e2fsck resize2fs等工具,在ubuntu系统中,可以用下列命令安装

sudo apt-get install -y qemu-utils parted e2fsprogs

2.获取img文件

http://www.openwrt.org

3.扩展img文件大小

使用qemu-img工具扩展openwrt的img文件大小。本次扩展到1GB。

qemu-img resize -f raw 2openwrt.img 1G

4.调整img文件分区大小

  • 使用losetup将img文件挂载为环回设备:

    sudo losetup -fP ./2openwrt.img
    sudo losetup -a
    /dev/loop9: [64768]:6561801 (/home/user/openwrt-24.10/2openwrt.img)
  • 查看当前img文件的分区信息

    sudo parted /dev/loop9 unit s print
    Model: Loopback device (loopback)
    Disk /dev/loop9: 2097152s
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags: 
    
    Number  Start   End      Size     Type     File system  Flags
     1      512s    33279s   32768s   primary  ext2         boot
     2      33792s  246783s  212992s  primary  ext4
    
  • 用parted调整分区大小,不要删除分区,直接resizepart分区大小,不然如果你用的是EFI安装包的话,删除了分区后分区的uuid会发生变化。

    parted /dev/loop9
    print free
    resizepart 1GB
  • 同步分区信息

    sudo partx -u /dev/loop9

5.扩展新的root分区大小

  • 使用e2fsck 和 resize2fs 扩展新的root分区。

    sudo e2fsck -f /dev/loop9p2
    sudo resize2fs  /dev/loop9p2
    
    yangbo@homeserver2:~/openwrt-24.10$ sudo e2fsck -f /dev/loop9p2
    e2fsck 1.45.5 (07-Jan-2020)
    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    Pass 3: Checking directory connectivity
    Pass 4: Checking reference counts
    Pass 5: Checking group summary information
    Padding at end of inode bitmap is not set. Fix<y>? yes
    
    rootfs: ***** FILE SYSTEM WAS MODIFIED *****
    rootfs: 1573/6656 files (0.0% non-contiguous), 7887/32768 blocks
    yangbo@homeserver2:~/openwrt-24.10$ 
    yangbo@homeserver2:~/openwrt-24.10$ sudo resize2fs  /dev/loop9p2
    resize2fs 1.45.5 (07-Jan-2020)
    Resizing the filesystem on /dev/loop9p2 to 257920 (4k) blocks.
    The filesystem on /dev/loop9p2 is now 257920 (4k) blocks long.
    
    yangbo@homeserver2:~/openwrt-24.10$ 

将img文件转换为VMDK文件

openwrt的img文件不论是直接下载的还是扩容后的,都不能直接用于VMware ESXi。需要将其转换为vmware 的vmdk文件。使用qemu-img文件,命令如下

qemu-img convert -f raw -O vmdk 2openwrt.img 2openwrt.vmdk

在ESXi中创建虚拟机并使用扩容后的VMDK文件

这个就不写了,无非不过上传VMDK文件,创建虚拟机,使用已存在的虚拟硬盘即可。

问题

如果partuudi发生了变化,1.可以查看新的partuuid,然后修改boot分区grub.cfg文件的内容。2.重新操作,注意不要让partuuid发生变化。