DNS vs IP

Posted by Zeno on Mon 20 Jun 2005 02:15 AM — 38 posts, 114,892 views.

USA #0
Okay I have noresolve on (so DNS names are used instead of IPs) but what would cause the MUD to still show an IP over a DNS name? This player somehow had one character on with his IP and another with his DNS thus multiplaying without our multiplay alarm going off. (Since it was strcmp the IP and DNS and not matching) It seems like the player forced the MUD to resolve it to an IP.

Here's what happened: (IPs & names changed from original)
Quote:
Comm: Alt@pcp02934895pcs.planfd01.in.comcast.net has connected.
Comm: Main@203.240.225.27 has connected.


Both are the same IP. (Sock.sinaddr showed it)
Amended on Mon 20 Jun 2005 02:25 AM by Zeno
USA #1
203.240.225.27 is an IP in South Korea. pcp02934895pcs.planfd01.in.comcast.net does not resolve to anything. Repeated attempts show it as a host not found. So it's not possible, at least from where I sit, to tie the 2 together.
USA #2
Er, as I said the IPs and DNS names were changed. When "Comm: Sock.sinaddr: <IP>, port 1809." came up, both those characters logged on from as we compare the port to the users list when signed on.
USA #3
if Sock.sinaddr can read both the IP, couldn't there be a way to tie your alarm into it somehow?
On another note, maybe you could add in somewhere that someone logging via IP will get a refused connection, though I'm not sure what all kinda of problems that could cause besides maybe restricting new players.
USA #4
Wait a minute. Isn't the IP the default, and the resolve causes a DNS name to show?

When you receive a connection, the IP is what you know & have. The hostname is what you get from a DNS lookup.
USA #5
I think he changed the code to read DNS instead of IPs because of the apparently large number of IP proxies there are out to keep people from running one and logging all the people at once they want to
USA #6
Quote:
if Sock.sinaddr can read both the IP, couldn't there be a way to tie your alarm into it somehow?

That was my first version of my multiplay alarm, but it doesn't tell the characters since no character is on yet.

Quote:
Wait a minute. Isn't the IP the default, and the resolve causes a DNS name to show?

Correct. Did I say something wrong?
USA #7
Well, you seemed to imply that by turning on noresolve, you never see the IP address and only use the hostname. That doesn't make a lot of sense to me; I'd have figured that it'd give the opposite i.e. IP address but no hostname.

In any case, the reason some people's hostnames won't show up would be if the DNS lookup fails for some reason. There are plenty of reasons why that could be: it could be a timeout, maybe the person really has no hostname handed out by the IP, the IP is spoofed and the spoofed IP has no hostname associated with it, etc.
USA #8
Well then ignore my comment about noresolve since I probably had what I meant backwards.

Basically, Alt always had the DNS and Main always had the IP. It didn't seem like a simple lookup error because it happened everytime and yet the IP resolves to the DNS.
USA #9
Actually, I don't understand why you're even getting hostnames in the first place if you have DNS resolving turned off.

In any case, does the hostname you get resolve to the IP address?
USA #10
I didn't turn it off, I simply meant that I typed "noresolve" for the first time and DNS names were being shown.

Well Sock.sinaddr and the port matched the DNS, so yes.
USA #11
What exactly do you mean when you say that sock.sinaddr and port matched the hostname?
USA #12
Well when someone connects it displays this:
Comm: Sock.sinaddr: <IP>, port 1809.

So after the person connected with a DNS, I checked users, and their port was 1809, so their DNS was that IP right?
USA #13
First off an issue of vocabulary; they're hostnames, not DNSs; a DNS is a domain name server, it's the computer that holds the mappings of IPs to domain names (hostnames).

I'm a little surprised that two connections would have the same port. Normally, if two have the same port, it means that it's literally the same connection, not two connections from the same source.

When you say 'check users' you mean typing in the users command, right? And you saw two distinct lines with the same port, but one with an IP and the other with a hostname?
USA #14
Yeah, I know I have an issue with explaining in exact words or even the right words. Thanks.

I meant that as I saw Sock.sinaddr with the IP, I waited until the next player signed on and compared ports via the users command. That way I knew the IP.
USA #15
Quote:
I meant that as I saw Sock.sinaddr with the IP, I waited until the next player signed on and compared ports via the users command. That way I knew the IP.
I don't understand what you mean. Like I said, it doesn't make sense for two separate connections to come from the same place with the same port. The very meaning of a port is that it services one connection.
USA #16
Alright I'll provide an example.

Comm: Sock.sinaddr: 203.240.225.27, port 1809.
Alt@pcp02934895pcs.planfd01.in.comcast.net has connected.
<I type users>
Desc|Con|Idle| Port | Player      @HostIP  
  39|  0|  14|  1809| Alt     @pcp02934895pcs.planfd01.in.comcast.net 


Does that make sense? I watched the port that connected and looked at the character that just signed on. Therefor, 203.240.225.27 = pcp02934895pcs.planfd01.in.comcast.net
USA #17
Oh. So there's just one connection involved. In that case, yes, the IP maps to that hostname - you must have asynchronous lookups?

Where is the second connection that made you worried about multiplaying?
USA #18
Well it was an example. Here's what the users list would have looked like:
<I type users>
Desc|Con|Idle| Port | Player      @HostIP  
  39|  0|  14|  1809| Alt     @pcp02934895pcs.planfd01.in.comcast.net 
  34|  0|  51|  1486| Main     @203.240.225.27 


The one character's IP was never resolved to the hostname no matter when he signed on, thus allowing him to bypass our multiplay alarm.
Amended on Tue 21 Jun 2005 05:04 AM by Zeno
USA #19
So, the character you have labeled as 'main' there. You're saying that no matter when he logs on, he always has only the IP address? But when the character labeled 'alt' logs on, the resolve gives you a hostname? Even though both are (apparently) coming from the same IP?
USA #20
Right. To be more specific, it wasn't myself who caught him, it was a supervisor. What I'm really asking is that is it possible for a person/computer to "force" their IP to not be resolved to a hostname? I mean it wasn't a proxy because the person always used that comcast address. The two characters were signing on and off at long lengths between each of the time trading shards between each other. Which is highly illegal in our MUD.
Amended on Tue 21 Jun 2005 05:28 AM by Zeno
USA #21
It could be possible if there is some form of spoofing going on, or if there's a proxy, firewall, etc. somewhere, that might be refusing DNS lookups after the first one. Seems funny though that somebody would go to that much trouble to cheat. Is there any reason to believe this player is the kind of person who would do that?
USA #22
A firewall eh? Well I am not positive it was intentional, but I'm nearly sure it was.

Oh yes, he's caused so much trouble before. His first chat replying to a PK hate discussion was "I love PK, it gets me into the game" or something of the sort. A week later he gets his first shard, gets killed twice, complains that he was killed within 5 minutes twice (when it was really 30min) and then chats "F*** THIS MUD" and quits. A week later he is back and causing more trouble.
USA #23
I'm not entirely familiar with how one could block DNS lookups however if he's behind a firewall and his firewall acts as the DNS node for his connections, it might do the trick for him.

I'd suggest that you rewrite your mplay detection to go off of IP addresses and not hostmasks. You might have to store the IP address in addition to the resolved hostmask, so that you can always compare from straight hostmask.

An interesting thing to try, next time this happens, is to ping both the IP address and the hostname. The hostname should, in principle, resolve to the IP address you first pinged; the ping tool will tell you what IP address it resolves to. If they don't match, and if you have reason to believe it's the same connection, something is afoot.
USA #24
Of course, if this guy is that much trouble, and you know who it is, and you are absolutely sure he's cheating, just ban his IP and be done with it. Why worry about going through all this :)
USA #25
We've thought about that, but he hasn't really broken enough rules to ban him. Basically he just trolls a lot.

I thought about storing IPs to a pcdata field. But what would the IP lookup code be? I'm sure its in comm.c somewhere, just not exactly sure what.
USA #26
You don't need to look up the IP address on connection; you already have it. What you do need to do is write it in string form. Fortunately, that's fairly easy.
strcpy( buf, inet_ntoa( sock.sin_addr ) );
That's all you've got to do, assuming that 'buf' is an appropriate char[]. You probably shouldn't store it in pcdata, though; just leave it in the connection data structure with the rest of the connection information.
USA #27
Ah but I was planning to have the IP displayed in finger also, and if there is no connection, we can't show the IP. Also, I need to include...
act_info.c:5341: warning: implicit declaration of function 'inet_ntoa'


       #include <sys/socket.h>
       #include <netinet/in.h>
       #include <arpa/inet.h>


Right? I want the IP to be shown in whois. But I'm not sure I understand, how does it know to get the IP from the victim?
     strcpy( buf4, inet_ntoa( sock.sin_addr ) );
Amended on Tue 21 Jun 2005 06:31 PM by Zeno
USA #28
Eh.. umm.. if there is no connection, how will you have an IP to begin with? Are you saying that you need the IP to be persistent for e.g. a link-dead player? Then yes, you'll need to put it into the pcdata...

That piece of code I gave you is taken from the connection accepting. It only works when you just accepted the connection and still have the socket structure lying around. And yes, you do need to include whatever's necessary, although I forget which files exactly you need.
USA #29
Yeah that's what I meant, I'd like finger to show the IP of players even if they aren't on. Right now it shows the last hostname (something I added). Why shouldn't I store it in pcdata? Or did you say that just because it already existed?

I still don't understand how this line:
strcpy( buf4, inet_ntoa( sock.sin_addr ) );

Will store the IP of the victim (and not ch, or who for that matter) in buf4.
USA #30
I said to not store it in pcdata because conceptually that's not where it belongs, but if you have extra requirements (e.g. IP addresses persist after deconnection) then it makes sense to put it there.

The line I give you doesn't target anybody. As I said, it comes from the code that accepts connections. It takes the socket structure that was just obtained from accept() and grabs the socket address. It is not something you would use anywhere else in your code. In fact, if you grep for inet_ntoa you will probably end up in the socket accepting code.
USA #31
Well I don't understand since if it is only used in new_descriptor, how am I suppose to display it with a character? The character loading is dealt with in nanny.
USA #32
When you load the character in nanny, you have the descriptor, right? So if you store the IP address (in string form after inet_ntoa or in the sock_sinaddr form), you can then stick it into the pcdata structure or wherever it is you want to put it.
Canada #33
So STRALLOC the result of inet_ntoa into a string on the DESCRIPTOR_DATA structure to save it and have an in game one easily available? Make sense.

Does your finger code load the charactes to read in the data? Or does it write to a file, and the finger command checks that?

Either way, you could just copy the value from ch->desc->ipstring to ch->pcdata->ipstring, or you could write to the file(s) from ch->desc->ipstring directly, though with this the IP will not persist if the character is loaded by an imm and forced to save.
USA #34
The finger is the latest snippet, so it loads and reads the player file.

Storing it in a buf yes I know, but I need to write the buf someone in order to read it in another function. Are you saying to change the header of the functions to store this buf?
USA #35
What's the problem with just writing the buf into the descriptor, and then writing it into the pcdata in nanny? I'm not sure I understand the problem.
USA #36
Oh wait, storing the buf into the descriptor? Could you give me an example line so I understand completely?
Canada #37
You could probably do this:

Add a field to your DESCRIPTOR_DATA in mud.h by adding
char *ipstring;
Then, in new_descriptor in comm.c, add the following:
dnew->ipstring = STRALLOC(inet_ntoa( sock.sin_addr ));
This should create a a string based on the ip, allocate the memory for it, and change d->ipstring to point to that memory. You should, I beleive add it right above:
if (!sysdata.NO_NAME_RESOLVING)
No testing was done, but that should give you the ip adress as a string allocated into a field in their descriptor data, and this would allow you to copy it later into their pcdata.