Skip to content

Blog

Install Qt From Source

Install Qt from opensouce, via local compile.

Take Qt-5.15.2 as an example.

Download Qt-5.15.2 from official site, or from mirror, like UTSC.

wget http://mirrors.ustc.edu.cn/qtproject/official_releases/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz
sudo apt install libX11-dev libXext-dev libXtst-dev -y
tar -xvf qt-everywhere-src-5.15.2.tar.xz
cd qt-everywhere-src-5.15.2
./configure -prefix /usr/local/qt-5.15.2 -opensource -developer-build \
-confirm-license -nomake tests -nomake examples
make -j8
sudo make install

Qt will be installed to /usr/local/qt-5.15.2, due to configure above.

[1]. https://qt.io

[2]. http://mirrors.ustc.edu.cn/help/qtproject.html

Container on Mikrotik

From Mikrotik ROS 7.4 Beta 4, Mikrotik add new feature of Container.

Configurations are based on Mikrotik RouterOS 7.13.1 .

Login Terminal in RouterOS, with following commands:

/system/device-mode/update container=yes

You will need to confirm the device-mode with a press of the reset button, or a cold reboot, if using container on X86.

(1). Add bridge veth interface for the container:

Section titled “(1). Add bridge veth interface for the container:”
/interface/veth/add name=veth1 address=172.17.0.2/24 gateway=172.17.0.1

(2). Create a bridge for containers and add veth to it:

Section titled “(2). Create a bridge for containers and add veth to it:”
/interface/bridge/add name=containers
/ip/address/add address=172.17.0.1/24 interface=containers
/interface/bridge/port add bridge=containers interface=veth1
/ip/firewall/nat/add chain=srcnat action=masquerade src-address=172.17.0.0/24

(1). Add host veth interface for the container:

Section titled “(1). Add host veth interface for the container:”
/interface/veth/add name=veth1 address=LAN_ADDRESS gateway=GATE_WAY_OF_LAN
/interface/bridge/port add bridge=LAN_BRIDGE interface=veth1
/container/mounts/add name=smartdns src=/smartdns.conf dst=/etc/smartdns/smartdns.conf
/container/config/set registry-url=https://registry-1.docker.io
/container/add remote-image=dashdreams/smartdns:latest interface=veth1 \
root-dir=/smartdns hostname=smartdns mounts=smartdns workdir=/root
/container/add file=smartdns.tar interface=veth1 root-dir=/smartdns \
hostname=smartdns mounts=smartdns workdir=/root
/container/start 0

6. Forward ports to internal container (optional)

Section titled “6. Forward ports to internal container (optional)”

Ports can be forwarded using dst-nat (where 192.168.88.1 routers IP address):

/ip firewall nat
add action=dst-nat chain=dstnat dst-address=192.168.88.1 dst-port=5353 protocol=tcp to-addresses=172.17.0.2 to-ports=53

How to get a local container image:

docker pull dashdreams/smartdns:latest@sha256:XXXXXXXXXXXXXXXXXXXXXXX
docker save dashdreams/smartdns > smartdns.tar

[1]. https://help.mikrotik.com/docs/display/ROS/Container

[2]. http://www.irouteros.com/?p=2712

[3]. Build-Container-Image-with-Podman

IP Address List Distribution Based on RouterOS and Openwrt

IP address list distribution with CNIP.

Configurations are based on Mikrotik RouterOS 7.6 .

A bypass routre with Openwrt required.

CN IP address list can be found from

Clang.CN

IPIP

RealIPDatabase

It’s possible to get CN IP list by running scripts below on linux:

curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest'|\
grep ipv6 | grep CN | awk -F\| \
'{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' | \
sed -e 's/^/add address=/g' -e 's/$/ list=CNIP/g'|\
sed -e $'1i\\\n/ipv6 firewall address-list' \
-e $'1i\\\nremove [/ipv6 firewall address-list find list=CNIP]'|\
sed '$a /file remove CNIPv6.rsc'>CNIPv6.rsc
curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest'|\
grep ipv4 | grep CN | awk -F\| \
'{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' |\
sed -e 's/^/add address=/g' -e 's/$/ list=CNIP/g' \
-e 's/$/ comment="CNIP"/g' |\
sed -e $'1i\\\n/ip firewall address-list' \
-e $'1i\\\nremove [/ip firewall address-list find list=CNIP]' |\
sed '$a \/' |sed '$a /file remove CNIPv4.rsc'>CNIPv4.rsc

Contains both IPv6 and IPv4 addresses.

The address list may look like this:

/ip firewall address-list
add list=CNIP address=x.x.x.x/xx
add list=CNIP address=x.x.x.x/xx
...
...
...
add list=CNIP address=x.x.x.x/xx

Open WinBox, and upload CNIPv4.rsc to RouterOS, than open Terminal, and run import CNIPv4.rsc.

In Terminal run command: /routing/tables/add name=OP fib

Add Proxy List in Firewall:

/ip/firewall/address-list/add name=proxy address=192.168.1.1-192.168.1.200

We take IP address range 192.168.1.1–192.168.1.200 to proxy list.

Mark Non-CN IP destnation address

add action=mark-routing chain=prerouting comment="ProxyRoute" \
src-address=proxy dst-address=!CNIP dst-address-type=!local \
new-routing-mark=OP passthrough=yes

Add another rule to accept openwrt’s flow

add action=accept chain=prerouting comment="BypassOP" \
src-address=192.168.1.254

Assume openwrt’s local ip is 192.168.1.254

Config route table to openwrt:

/ip/route/add dst-address=0.0.0.0 gateway=192.168.1.254 \
check-getway=ping routing-table=OP distance=1 \
scope=30 target-scope=10

Change PPPOE’s distance to 2:

/interface/pppoe-client/set pppoe-CMCC default-route-distance=2

4. Change Distribution if Bypass Router Down

Section titled “4. Change Distribution if Bypass Router Down”
  • Shutdown distribution when openwrt down
  • Turn distribution when openwrt up
/tool/netwatch/add host=192.168.1.254 type=simple interval=60 \
up-script=OPUP.rsc down-script=OPDOWN.rsc

Up Script:

add dont-require-permissions=yes name=OPUP.rsc owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/\
ip firewall mangle enable number=???\r\
\n/ip firewall mangle enable number=???\r\
\n/ip route enable number=0\r\
\n/ip/dns/cache/flush"

Down Script:

add dont-require-permissions=yes name=OPDOWN.rsc owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/\
ip firewall mangle disable number=???\r\
\n/ip firewall mangle disable number=???\r\
\n/ip route disable number=0\r\
\n/ip/dns/cache/flush"

??? is index number of mangle rules set in MangleRules

[1]. https://www.shawnleetttt.cyou/posts/71e7c44b/

[2]. https://idndx.com/high-availability-when-split-routing-using-routeros-and-raspberrypi/

[3]. DNS-Distribution-with-SmartDNS

[4]. IPv6-Configure-on-Mikrotik-RouterOS-v7.x

IPv6 Configure on Mikrotik RouterOS v7.x

IPv6 configuration on Mikrotik RouterOS is much more complicated than Merlin on ASUS. We are going to config IPv6 in this aritical.

Configurations are based on Mikrotik RouterOS 7.6 .

Login Terminal in RouterOS, with following commands:

# Accept ISP RA, Get IPv6 Address with SLAAC
/ipv6 settings set accept-router-advertisements=yes
# Configure DHCPv6 client:
# - Add default route: yes
# - WAN interface: pppoe-ether1
# - IPv6 address pool: IPv6 (You can change to whatever you want)
# - Prefix length for DHCPv6 server's offering cascading routers: 60
# - Request LAN prefix from ISP
/ipv6 dhcp-client add add-default-route=no interface=pppoe-ether1 \
pool-name=IPv6 pool-prefix-length=60 \
request=prefix

CMCC in Nanjing, Jiangsu provide /60 prefix, if prefix length less than /63, it’s impossible to use DHCPv6.

# Accept DHCPv6 client prefix delegation
/ipv6 firewall filter add action=accept chain=input \
comment="Accept DHCPv6 client prefix delegation" \
dst-port=546 protocol=udp src-address=fe80::/10

This rule is default, if you configured your router with default script.

/ipv6 address add address=::1 from-pool=IPv6 interface=bridge
# Delegate IPv6 addresses from pool `delegation`
# Lease is valid for 1 day
/ipv6 dhcp-server add address-pool=IPv6 \
interface=bridge lease-time=7d name=Home-IPv6

[1]. https://wu.renjie.im/blog/network/ros-dhcpv6/zh-cn/

Commit code from one git repository to anotherIn actual development, branch_a in the repro_a warehouse is independently transformed into a new warehouse repro_b. Mainly relies on`git remote`for implementation.

1. Submit the current code to another remote git repositoryIf warehouse repo_a is currently located in branch_a, it is required to extract all the data of branch_a (including submission history) and create a new warehouse repo_b. It is assumed here that the warehouse repo_b has been created.The basic syntax ofgit remote addis as follows. name and url are required.

Section titled “1. Submit the current code to another remote git repositoryIf warehouse repo_a is currently located in branch_a, it is required to extract all the data of branch_a (including submission history) and create a new warehouse repo_b. It is assumed here that the warehouse repo_b has been created.The basic syntax ofgit remote addis as follows. name and url are required.”
git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>

(1). Add the URL of the warehouse repo_b to the remote of the working warehouse.

Section titled “(1). Add the URL of the warehouse repo_b to the remote of the working warehouse.”
git remote add origin_repo_b git@server_ip:/path/repo_b.git

(origin_repo_b: the name you choose, as long as it does not duplicate the existing remote name) (git@server_ip:/path/repo_b.git:repo_b’s remote path)

git push origin_repo_b branch_a

(origin_repo_b: the name of the remote warehouse repo_b) (branch_a: branch_a branch of warehouse repo_a)

(3). Clone the warehouse repo_b and check whether the push is successful.

Section titled “(3). Clone the warehouse repo_b and check whether the push is successful.”

2. Submit the same code to multiple different git hosting servers (multiple git repositories)The method is very similar, mostly using the commandgit remote set-url --add [--push] <name> <newurl>Assume that a new warehouse repo_c is added to the remote git server, and the codes submitted by repo_b and repo_c must be consistent.

Section titled “2. Submit the same code to multiple different git hosting servers (multiple git repositories)The method is very similar, mostly using the commandgit remote set-url --add [--push] <name> <newurl>Assume that a new warehouse repo_c is added to the remote git server, and the codes submitted by repo_b and repo_c must be consistent.”

(1). Configure remote repo_c into the current working local git repository

Section titled “(1). Configure remote repo_c into the current working local git repository”
git remote set-url --add origin_repo_b git@192.168.1.101:~/project/repo_c.git

What this sentence means is that the remote warehouse git@192.168.1.101:~/project/repo_c.git is also added to the name origin_repo_b for management.

(2). Submit the code to remote warehouse repo_b and remote warehouse repo_c at the same time

Section titled “(2). Submit the code to remote warehouse repo_b and remote warehouse repo_c at the same time”
git push origin_repo_b branch_a

(3). fatal: refusing to merge unrelated histories

Section titled “(3). fatal: refusing to merge unrelated histories”
git pull origin master --allow-unrelated-histories