Brook OpenWRT: Perfectly supports IPv4/IPv6/TCP/UDP

Updated at: 2024-02-07

img

中文

Write the system to the OpenWRT hard drive

  1. Download the 23.05.2 version of OpenWRT on your computer according to the specifics of your device, for instance, I am using macOS.

    Different versions of OpenWRT may vary greatly; it's recommended to use the version that I am using.

    curl -o openwrt.img.gz https://downloads.openwrt.org/releases/23.05.2/targets/x86/64/openwrt-23.05.2-x86-64-generic-ext4-combined-efi.img.gz
    
  2. First, create an Ubuntu bootable USB drive, insert the OpenWRT device and boot from the USB drive

  3. Connect the computer and the router with an Ethernet cable, and change their IPs to the same subnet. Then copy the openwrt.img.gz file from the computer to the router

    scp xxx@xxx:/path/to/openwrt.img.gz ./
    
  4. Check the router's hard drive

    lsblk
    
  5. Write to the hard drive with root user

    gunzip -c openwrt.img.gz | dd of=/dev/sda bs=4M
    
  6. Shutdown, disconnect the Ethernet cable, remove the USB drive, and boot.

Change the router's address

uci set network.lan.ipaddr=192.168.2.1
uci commit

Remove serial console

vim /boot/grub/grub.cfg

Remove this, otherwise, the startup will be slow

console=ttyS0,115200n8

Reboot or Power off then boot

Connect the computer with an Ethernet cable

Change the IP of the computer to the same subnet as the router, then visit http://192.168.2.1. If the router has multiple ports, try each one until you find the one that grants access.

Remove ULA

  1. Network - Interfaces - Global network options - IPv6 ULA-Prefix - Save & Apply

Configure WAN

  1. Connect the modem to another port on the router. If you're not sure which port it is, try them one by one and check the router's management page to see if there is data flow on the WAN.
  2. Network - Interfaces - wan - Edit - General Settings - Protocol: PPPoE - Switch protocol - username/password - Save - Save & Apply
  3. If a wan_6 has been automatically created at this point, delete the previous wan6. Save & Apply

If you haven't obtained IPv6 PD here, and if your modem also has routing capabilities, then it needs to support issuing PD. Otherwise, allow OpenWRT to dial in to obtain PD. If not, please contact your ISP and say no to all non-Native solutions like Relay, NAT6, etc.

Configure LAN

  1. Network - Interfaces - lan - Edit - Advanced Settings - IPv6 assignment length: 64
  2. Network - Interfaces - lan - Edit - Advanced Settings - DHCP Server - IPv6 RA Settings - RA Flags: None - Save - Save & Apply

Test on computer

Unplug and re-plug the computer's network cable at this time to automatically acquire an IP, which should be a GUA, and the DNS should also be a GUA. If a ULA is still obtained at this point, it should disappear after the next router reboot

brook dnsclient -d http3.ooo -t A -s 192.168.2.1:53
brook dnsclient -d http3.ooo -t AAAA -s 192.168.2.1:53
brook dnsclient -d http3.ooo -t A -s [xxx]:53
brook dnsclient -d http3.ooo -t AAAA -s [xxx]:53
brook echoclient -s 137.184.237.95:7777
brook echoclient -s [2604:a880:4:1d0::4cf:b000]:7777

Expand root

opkg update
opkg install parted losetup resize2fs
wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=0"
. ./expand-root.sh

Reboot

Test on OpenWrt

brook dnsclient -d http3.ooo -t A -s 127.0.0.1:53
brook dnsclient -d http3.ooo -t AAAA -s 127.0.0.1:53
brook dnsclient -d http3.ooo -t A -s [::1]:53
brook dnsclient -d http3.ooo -t AAAA -s [::1]:53
brook echoclient -s 137.184.237.95:7777
brook echoclient -s [2604:a880:4:1d0::4cf:b000]:7777

Test your Brook Server

brook testbrook --link 'brook://...'

Install Brook.ipk

Brook.ipk will use :9999, 127.0.0.1:8888, [::1]:8888, 127.0.0.1:5353

  1. System - Software - Update lists...
  2. System - Software - Upload Package... - Brook.ipk

Then open dashboard http://192.168.2.1:9999

Test on computer

Check the two DNS servers allocated on your computer; one should be IPv4 and the other IPv6

brook dnsclient -d http3.ooo -t A -s 192.168.2.1:53
brook dnsclient -d http3.ooo -t AAAA -s 192.168.2.1:53
brook dnsclient -d http3.ooo -t A -s [xxx]:53
brook dnsclient -d http3.ooo -t AAAA -s [xxx]:53

Test IPv4 and IPv6, as well as TCP and UDP, of course, your Brook Server should support dual-stack

brook echoclient -s 137.184.237.95:7777
brook echoclient -s [2604:a880:4:1d0::4cf:b000]:7777

Discuss