I need to keep dns port 53 busy/binded to a interface over only TCP or only UDP. is there a way to accomplish this? using socket lib python or any other way would be appreciated.
Asked
Active
Viewed 736 times
-1
-
Does that mean 2 socket will be made, TCP and UDP, but only one can accept a connection at a time? you can implement it using `select.select`. – Hagai Wild Jul 20 '18 at 09:36
-
Hi Hagai, Actually only one socket at a time needed. it can be either TCP or UDP, but port 53 of interface should be binded over one transport protocol. – Sunil Kumar Jul 20 '18 at 09:43
-
Can you explain why? It is not a problem technically, but port 53 for DNS needs both TCP and UDP to work reliable in all cases (despite old documentation stating that TCP is only for zone transfers, which is completely wrong). – Patrick Mevzek Jul 20 '18 at 14:25
-
Hi Patrick, Yeah I agree(AXFR and other DNS stuffs uses TCP), But I need these for testing, where it should use/listen to whichever left interfaces:Proto(TCP or UDP):53. That's why i want to keep eitheir TCP or UDP busy(but not both) with another service or any other means at one time. – Sunil Kumar Jul 23 '18 at 07:16
1 Answers
-1
tcp only
from socket import *
tcp = socket(AF_INET, SOCK_STREAM)
tcp.bind(('', 53))
tcp.listen(5)
udp only
from socket import *
udp = socket(AF_INET, SOCK_DGRAM)
udp.bind(('', 53))

shaun shia
- 1,042
- 2
- 9
- 14
-
-
yeah exactly @EJP, I tried these, binding to eth0 interface IP. didn't get what i expected. – Sunil Kumar Jul 20 '18 at 11:53