You are not logged in.

#1 2017-08-20 21:25:53

r0b0t
Member
From: /tmp
Registered: 2009-05-24
Posts: 505

dnscrypt making init/1 - systemd listen on port 53 tcp/udp

Hi guys,
I'm not sure if this is normal or not but it's worth for a discussion.
After I set up dnscrypt-proxy , I noticed that whenever the service was started init/1 was listening on port 53 tcp/udp

udp        0      0 127.0.0.1:53            0.0.0.0:*                           1/init 
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1/init

By checking with strace I see when it creates the socket.

23:13:52.539024 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 102 <0.000015>
23:13:52.539064 setsockopt(102, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 <0.000010>
23:13:52.539098 bind(102, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0 <0.000015>
23:13:52.539146 listen(102, 128)        = 0 <0.000010>
23:13:52.539179 socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 103 <0.000011>
23:13:52.539212 setsockopt(103, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 <0.000009>
23:13:52.539245 bind(103, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0 <0.000012>

Is this normal at all??
I don't feel comfortable at all having the main system process in listening, what are your thoughts?
thanks.

Last edited by r0b0t (2017-08-20 21:27:27)

Offline

#2 2017-08-20 22:59:29

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: dnscrypt making init/1 - systemd listen on port 53 tcp/udp

Show the command you used, to get "1/init".

Offline

#3 2017-08-20 23:31:27

r0b0t
Member
From: /tmp
Registered: 2009-05-24
Posts: 505

Re: dnscrypt making init/1 - systemd listen on port 53 tcp/udp

I think what strace shows is enough to get the point as if you run systemctl start dnscrypt-proxy you will see that the socket will be created.
In any case the command would be something like

# netstat -patuln | grep init
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1/init              
udp        0      0 127.0.0.1:53            0.0.0.0:*                           1/init      

# systemctl stop dnscrypt-proxy
Warning: Stopping dnscrypt-proxy.service, but it can still be activated by:
  dnscrypt-proxy.socket
[root@i]# netstat -patuln | grep init
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1/init              
udp        0      0 127.0.0.1:53            0.0.0.0:*                           1/init              
[root@i]# systemctl stop dnscrypt-proxy.socket
[root@i]# netstat -patuln | grep init
[root@i]# 

Last edited by r0b0t (2017-08-20 23:31:42)

Offline

#4 2017-08-20 23:52:22

r0b0t
Member
From: /tmp
Registered: 2009-05-24
Posts: 505

Re: dnscrypt making init/1 - systemd listen on port 53 tcp/udp

I understand what you mean by your question, here some more info:

lsof -i -a -p 1
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd   1 root  103u  IPv4 112878      0t0  TCP localhost.localdomain:domain (LISTEN)
systemd   1 root  104u  IPv4 112879      0t0  UDP localhost.localdomain:domain 
ls -aclh /proc/1/fd/103 
lrwx------ 1 root root 64 Aug 20 23:15 /proc/1/fd/103 -> socket:[112878]
ls -aclh /proc/1/fd/104
lrwx------ 1 root root 64 Aug 21 01:37 /proc/1/fd/104 -> socket:[112879]

cat /proc/1/net/tcp | grep 112878
   1: 0100007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 112878 1 ffff9418529a4d80 99 0 0 10 5           
 cat /proc/1/net/udp | grep 112879
 5035: 0100007F:0035 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 112879 2 ffff9417d00192c0 0 

Last edited by r0b0t (2017-08-21 00:01:56)

Offline

#5 2017-08-21 08:27:29

seiichiro0185
Member
From: Leipzig/Germany
Registered: 2009-04-09
Posts: 226
Website

Re: dnscrypt making init/1 - systemd listen on port 53 tcp/udp

Could it be that some kind of Systemd Socket Activation is used here? in that case Systemd would open the Port and launch the actual daemon on incoming requests (This is just a shot in the dark, I didn't take a look at dnscrypt yet). If this is the case there should be a dnscrypt-proxy.socket file somewhere (most likely /usr/lib/systemd/system/) that defines it.

Last edited by seiichiro0185 (2017-08-21 08:29:41)


My System: Dell XPS 13 | i7-7560U | 16GB RAM | 512GB SSD | FHD Screen | Arch Linux
My Workstation/Server: Supermicro X11SSZ-F | Xeon E3-1245 v6 | 64GB RAM | 1TB SSD Raid 1 + 6TB HDD ZFS Raid Z1 | Proxmox VE
My Stuff at Github: github
My Homepage: Seiichiros HP

Offline

#6 2017-08-23 08:49:08

r0b0t
Member
From: /tmp
Registered: 2009-05-24
Posts: 505

Re: dnscrypt making init/1 - systemd listen on port 53 tcp/udp

cat /usr/lib/systemd/system/dnscrypt-proxy.socket
[Unit]
Description=dnscrypt-proxy listening socket

[Socket]
ListenStream=127.0.0.1:53
ListenDatagram=127.0.0.1:53

[Install]
WantedBy=sockets.target

So I guess this is "normal"...

Offline

Board footer

Powered by FluxBB