$ sudo sing-box run -c ./sing-box/config.json
+0800 2024-02-17 18:43:05 INFO router: updated default interface eth0, index 2
+0800 2024-02-17 18:43:05 INFO inbound/tun[tun-in]: started at tun0
+0800 2024-02-17 18:43:05 INFO inbound/mixed[1]: tcp server started at 0.0.0.0:7890
+0800 2024-02-17 18:43:05 INFO inbound/direct[2]: udp server started at 0.0.0.0:53
+0800 2024-02-17 18:43:05 INFO sing-box started (0.44s)
The sing-box's output while running curl https://x.com at the same host which running sing-box, everything looks well:
+0800 2024-02-17 18:44:41 INFO [1815147228 0ms] inbound/tun[tun-in]: inbound packet connection from 172.16.0.1:54302
+0800 2024-02-17 18:44:41 INFO [1815147228 0ms] inbound/tun[tun-in]: inbound packet connection to 192.168.1.1:53
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com A x.com. 885 IN A 104.244.42.65
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com A x.com. 885 IN A 104.244.42.193
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com A x.com. 885 IN A 104.244.42.1
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com A x.com. 885 IN A 104.244.42.129
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com OPT OPT PSEUDOSECTION: EDNS: version 0 flags: MBZ: 0x0375, udp: 1232
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com. A x.com. 885 IN A 104.244.42.65
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com. A x.com. 885 IN A 104.244.42.193
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com. A x.com. 885 IN A 104.244.42.1
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com. A x.com. 885 IN A 104.244.42.129
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com SOA x.com. 55 IN SOA a.u10.twtrdns.net. noc.twitter.com. 2023121201 3600 600 604800 300
+0800 2024-02-17 18:44:41 INFO dns: exchanged x.com OPT OPT PSEUDOSECTION: EDNS: version 0 flags: MBZ: 0x0037, udp: 1232
+0800 2024-02-17 18:44:41 INFO [426345967 0ms] inbound/tun[tun-in]: inbound connection from 172.16.0.1:36448
+0800 2024-02-17 18:44:41 INFO [426345967 0ms] inbound/tun[tun-in]: inbound connection to 104.244.42.65:443
+0800 2024-02-17 18:44:41 INFO [426345967 4ms] outbound/hysteria2[proxy]: outbound connection to x.com:443
The sing-box's output while running curl https://twitter.com at another windows machine which set sing-box as the gateway/dns server, there is only DNS queries related output:
+0800 2024-02-17 18:48:02 INFO [190343424 0ms] inbound/direct[2]: inbound packet connection from 192.168.1.23:55109
+0800 2024-02-17 18:48:02 INFO dns: exchanged twitter.com A twitter.com. 1188 IN A 104.244.42.193
+0800 2024-02-17 18:48:02 INFO dns: exchanged twitter.com A twitter.com. 1188 IN A 104.244.42.1
+0800 2024-02-17 18:48:02 INFO dns: exchanged twitter.com A twitter.com. 1188 IN A 104.244.42.65
+0800 2024-02-17 18:48:02 INFO dns: exchanged twitter.com A twitter.com. 1188 IN A 104.244.42.129
+0800 2024-02-17 18:48:02 INFO dns: exchanged twitter.com. A twitter.com. 1188 IN A 104.244.42.193
+0800 2024-02-17 18:48:02 INFO dns: exchanged twitter.com. A twitter.com. 1188 IN A 104.244.42.1
+0800 2024-02-17 18:48:02 INFO dns: exchanged twitter.com. A twitter.com. 1188 IN A 104.244.42.65
+0800 2024-02-17 18:48:02 INFO dns: exchanged twitter.com. A twitter.com. 1188 IN A 104.244.42.129
$ uname -a
Linux alpine 6.6.16-0-virt #1-Alpine SMP PREEMPT_DYNAMIC Wed, 07 Feb 2024 18:00:38 +0000 x86_64 Linux
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host proto kernel_lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.1.3/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::54ab:93ff:fed5:58f4/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:c7:0f:4a:09 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
63: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UNKNOWN group default qlen 500
link/none
inet 172.16.0.1/30 brd 172.16.0.3 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::57a1:8e39:6cfe:427b/64 scope link stable-privacy proto kernel_ll
valid_lft forever preferred_lft forever
$ ip rule
0: from all lookup local
8997: from all to 192.168.1.3 lookup 2022
8998: from all iif tun0 lookup main
8999: from all iif tun0 lookup main
9000: from all to 172.16.0.0/30 lookup 2022
9001: from all ipproto icmp goto 9010
9002: not from all dport 53 lookup main suppress_prefixlength 0
9002: not from all iif lo lookup 2022
9002: from 0.0.0.0 iif lo lookup 2022
9002: from 172.16.0.0/30 iif lo lookup 2022
9010: from all nop
32766: from all lookup main
32767: from all lookup default
$ ip route show table 2022
default dev tun0
$ ip route
default via 192.168.1.1 dev eth0 metric 202
172.16.0.0/30 dev tun0 proto kernel scope link src 172.16.0.1
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.3
$ sysctl -a|grep ip_forward
net.ipv4.ip_forward = 1
net.ipv4.ip_forward_update_priority = 1
net.ipv4.ip_forward_use_pmtu = 0
$ ip link show eth0
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
$ sudo iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DOCKER all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
DOCKER all -- anywhere !127.0.0.0/8 ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 192.168.0.0/24 anywhere
MASQUERADE all -- 172.17.0.0/16 anywhere
MASQUERADE all -- anywhere anywhere
Chain DOCKER (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere
# sudo dmesg
...[[REMOVED MANULLY]]
[23533.310703] netlink: 'sing-box': attribute type 22 has an invalid length.
NOTE: MASQUERADE all -- anywhere anywhere and MASQUERADE all -- 192.168.0.0/24 anywhere is added manually by myself.
Is there anything more I should do for it to let the sing-box acts as a gateway?
Anything i should do for the dmesg log below:
[23533.310703] netlink: 'sing-box': attribute type 22 has an invalid length.
Reproduction
Restart the sing-box, the same host is still okay and the client OS is still failed to connect to internet via curl.
Logs
No response
Integrity requirements
[X] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
[X] I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
[X] I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
[X] I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.
Operating system
Linux
System version
Alpine Linux v3.19 6.6.16-0-virt x86_64
Installation type
Original sing-box Command Line
If you are using a graphical client, please provide the version of the client.
No response
Version
Description
The config.json i'm using is:
CLI to start the sing-box:
The sing-box's output while running
curl https://x.com
at the same host which running sing-box, everything looks well:The sing-box's output while running
curl https://twitter.com
at another windows machine which set sing-box as the gateway/dns server, there is only DNS queries related output:The output of
ipconfig /all
in client OS:So I back to check the sing-box host's config:
Is there anything more I should do for it to let the sing-box acts as a gateway?
Anything i should do for the dmesg log below:
Reproduction
Restart the sing-box, the same host is still okay and the client OS is still failed to connect to internet via
curl
.Logs
No response
Integrity requirements