# How to bind to port 53



## Anonymous (Feb 20, 2010)

I'm trying to write a script in python that creates a socket and binds to port 53. The problem I'm having though is that when I try to connect to the server at that port I receive an ICMP port unreachable response. I know the problem is in the operating system because port 8080 works fine. Does anyone know how I can bind to port 53. By the way I'm running the script as root and that doesn't seem to be a difference.


----------



## DutchDaemon (Feb 20, 2010)

Have you tried nc(1) to check whether the basic mechanism of creating a listener on port 53 actually works?


----------



## Anonymous (Feb 20, 2010)

Just tried it, here's the result:
I have 2 systems set up 10.0.0.2 is acting as the server and 10.0.0.1 the client.

Using

```
nc -l 10.0.0.2 53
```
and

```
nc 10.0.0.2 53 (from 10.0.0.1)
```

works and allows me to echo text between to consoles. But when I let nc listen on 10.0.0.2 53 and set /etc/resolv.conf on the client to:


```
nameserver 10.0.0.2
```

and do a:


```
nslookup example.com
```

and look in wireshark, I see the DNS request to sent to 10.0.0.2:53 with only a IMCP (port unreachable) response.


----------



## DutchDaemon (Feb 20, 2010)

You have set nc to listen op udp/53, right?


----------



## Anonymous (Feb 20, 2010)

Oh yeah, oops I forgot dns uses udp. So i guess my next question is how can I go about recieving the request in its orginal format? The output in nc for the dns request of google.com shows up as "xgooglecom"


----------



## DutchDaemon (Feb 20, 2010)

A tcpdump with some additional -XXX flags should show its original raw format. I'm not sure how nc handles, parses or manipulates input from DNS resolvers. It probably strips out anything non-ASCII.


----------

