本帖最後由 tomleehk 於 2023-11-18 01:09 編輯
Xray-core installation and configuration
Run SSH client, e.g. ssh root@192.168.1.1 to access openwrt command shell.
opkg update <<ENTER>>
opkg install xray-core <<ENTER>>
After installation of packages is complete, type
opkg list-installed <<ENTER>>
to verify xray-core version must be of v1.8 above.
In order to run xray server with reality,
1) a set of public key/private key created with x25519 algorithm is needed.
Run SSH client, e.g. ssh root@192.168.1.1 to access openwrt command shell, then
type
xray x25519 <<ENTER>>
A pair of keys will be generated
e.g.
Private key: YIHyZpW1NJLck_XTCG8IYMMqq1JG7w2Vm95HMAbB51g
Public key: Xh_hBw4E5SBFjreeAQQjnUMlvLvFPeELy2Xdvur6XwU
2) a string of ShortID which comprises letters 0 to f only, the string length must be a multiple of 2 and maximum string length is 16.
e.g. 6ba85179e30d4fc2
Assume xray server uses the following parameters
1) port = 8447
2) protocol = vless
3) uuid = c50bf28e-98cd-a351-b8d5-d60d56c376c7
4) network = gRPC
5) gRPC serviceName = whitelist
and
1) port 8446
2) protocol = vless
3) uuid = c50bf28e-98cd-a351-b8d5-d60d56c376c7
4) flow = xtls-rprx-vision
5) network = tcp
6) security = reality
7) realitySettings
dest : www.amazon.com:443
serverNames : www.amazon.com
privateKey : YIHyZpW1NJLck_XTCG8IYMMqq1JG7w2Vm95HMAbB51g
shortIds : 6ba85179e30d4fc2
Prepare a text file config.json with content- {
- "inbounds": [
- {
- "port": 8447,
- "protocol": "vless",
- "allocate": {
- "strategy": "always"
- },
- "settings": {
- "clients": [
- {
- "id": "c50bf28e-98cd-a351-b8d5-d60d56c376c7",
- "level": 0
- }
- ],
- "decryption": "none"
- },
- "streamSettings": {
- "network":"gRPC",
- "gRPCSettings": {"serviceName": "whitelist"}
- }
- },
- {
- "port": 8446,
- "protocol": "vless",
- "settings": {
- "clients": [
- {
- "id": "c50bf28e-98cd-a351-b8d5-d60d56c376c7",
- "flow": "xtls-rprx-vision",
- "level": 0
- }
- ],
- "decryption": "none"
- },
- "streamSettings": {
- "network": "tcp",
- "security": "reality",
- "realitySettings": {
- "dest": "www.amazon.com:443",
- "serverNames": [
- "www.amazon.com"
- ],
- "privateKey": "YIHyZpW1NJLck_XTCG8IYMMqq1JG7w2Vm95HMAbB51g",
- "shortIds": [
- "6ba85179e30d4fc2"
- ]
- }
- }
- }
- ],
- "outbounds": [
- {
- "protocol": "freedom",
- "settings": {}
- }
- ]
- }
複製代碼 Run WINSCP to login router with
New Site
1) File protocol - SCP
2) Host Name - 192.168.1.1
3) Port Number - 22
4) User Name/Password - root / <root password>
You can use Save button to create a site profile for future re-use
Copy the above config.json to the folder /etc/xray/
Use WINSCP to edit the file /etc/config/xray
Change the content from- config xray 'enabled'
- option enabled '0'
複製代碼 To- config xray 'enabled'
- option enabled '1'
複製代碼 IMPORTANT:
1. Create a firewall rule to open port 8446 at openwrt luci, Network >> Firewall >> Traffic Rules
Name : Open8446
Protocol : TCP and UDP
Source zone : wan and wan6
Destination zone : This Device
Destination port : 8446
2. Destination site must fulfil the following requirements :
Overseas websites supporting TLSv1.3, H2
Reference :
https://www.duangvps.com/archives/1976
3. Technically the destination site can point to local webserver instead of external webserver- "realitySettings": {
- "dest": "127.0.0.1:443",
- "serverNames": [
- " testhost.ddnsfree.com"
- ],
複製代碼 Pros and Cons need further investigation.
Reboot router and access openwrt luci page
Status >> Processes
and search for xray to verify xray can be launched automatically. |