Once you have a grasp of the fundamental principles for constructing a JSON file and are familiar with the structure of singbox config.json, you can create your own.
Sing-Box can have multiple inbound/outbound connections configured simultaneously, each with its own set of parameters and settings.
{
"log": {},
"dns": {},
"inbounds": [{
"tag": "inbound1"
}, {
"tag": "inbound2"
}, {
"tag": "inbound3"
}, {
"tag": "inbound4"
}],
"outbounds": [{
"tag": "outbound1"
}, {
"tag": "outbound2"
}, {
"tag": "outbound3"
}, {
"tag": "outbound4"
}, {
"tag": "outbound5"
}],
"route": {
"final": "outbound3"
},
"experimental": {}
}
Code language: JSON / JSON with Comments (json)
The above JSON configuration file can be used as a starting point for your own configuration. The “log“, “dns” and “experimental” sections are optional and can be left empty. The “route” section has an object that contains one key-value pair of “final” and “outbound3” which indicates that the default outbound for traffic forwarding is “outbound3”. The “inbounds” and “outbounds” sections are arrays of objects. You can replace these objects with your desired from our list of inbounds and outbounds json blocks.
For example, let’s say you have selected “mixed-in” and “tun-in” as your inbound connections, and you want to connect to an outbound using the “shadowsocks” protocol and another using the “vmess over websocket” protocol. Your config.json file would then look something like this:
{
"inbounds": [{
"tag": "mixed-in"
}, {
"tag": "tun-in"
}],
"outbounds": [{
"tag": "shadowsocks-out"
}, {
"tag": "vmess-ws-out"
}],
"route": {
"final": "shadowsocks-out"
}
}
Code language: JSON / JSON with Comments (json)
Replacing tags with actual json blocks:
{
"inbounds": [{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 1080,
"tcp_fast_open": true,
"sniff": true,
"sniff_override_destination": true,
"set_system_proxy": false
}, {
"type": "tun",
"tag": "tun-in",
"interface_name": "tun0",
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/128",
"stack": "gvisor",
"mtu": 9000,
"auto_route": true,
"strict_route": true,
"endpoint_independent_nat": false,
"sniff": true,
"sniff_override_destination": true
}],
"outbounds": [{
"type": "shadowsocks",
"tag": "shadowsocks-out",
"server": "SERVER-IP-ADDRESS",
"server_port": 5353,
"method": "2022-blake3-aes-128-gcm",
"password": "8JCsPssfgS8tiRwiMlhARg=="
}, {
"type": "vmess",
"tag": "vmess-ws-out",
"server": "SERVER-IP-ADDRESS",
"server_port": 80,
"uuid": "3c1890e2-c768-4247-8a3b-032f6ed13a64",
"security": "auto",
"alter_id": 0,
"global_padding": false,
"authenticated_length": true,
"multiplex": {
"enabled": true,
"protocol": "smux",
"max_connections": 5,
"min_streams": 4,
"max_streams": 0
},
"transport": {
"type": "ws",
"path": "/stream",
"max_early_data": 0,
"early_data_header_name": "Sec-WebSocket-Protocol"
},
"connect_timeout": "5s"
}],
"route": {
"final": "shadowsocks-out"
}
}
Code language: JSON / JSON with Comments (json)
Now that you understand how to have multiple inbounds and outbounds, here’s an additional example for you to use as a starting point when building your config.json:
{
"log": {
"disabled": false,
"level": "error",
"output": "box.log",
"timestamp": true
},
"dns": {
"servers": [{
"tag": "local",
"address": "217.218.127.127",
"detour": "direct"
},
{
"tag": "google",
"address": "tls://8.8.8.8"
}, {
"tag": "block",
"address": "rcode://success"
}
],
"rules": [{
"geosite": "category-ads-all",
"server": "block"
}, {
"domain_suffix": ".ir",
"server": "local"
}],
"final": "google",
"strategy": "prefer_ipv4",
"disable_cache": false,
"disable_expire": false
},
"inbounds": [{
"tag": "inbound1"
}, {
"tag": "inbound2"
}, {
"tag": "inbound3"
}, {
"tag": "inbound4"
}],
"outbounds": [{
"tag": "outbound1"
}, {
"tag": "outbound2"
}, {
"tag": "outbound3"
}, {
"tag": "outbound4"
}, {
"tag": "outbound5"
}],
"route": {
"geoip": {
"download_url": "https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db",
"download_detour": "direct"
},
"geosite": {
"download_url": "https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db",
"download_detour": "direct"
},
"rules": [{
"protocol": "dns",
"outbound": "dns-out"
}, {
"geosite": [
"category-ads-all"
],
"domain_keyword": [
"yektanet",
"adengine.telewebion.com"
],
"outbound": "block"
},
{
"geoip": "private",
"domain_suffix": [
".ir",
"aparat.com",
"digikala.com",
"telewebion.com",
"varzesh3.com"
],
"port": [
22,
3389
],
"outbound": "direct"
}
],
"final": "outbound2",
"auto_detect_interface": true
},
"experimental": {}
}
Code language: JSON / JSON with Comments (json)
Examine my pre-made config.json files to gain a better understanding of how to construct yours.