Worried I have compromised my router

ams1234

Junior Member
Jul 5, 2015
8
0
0
My router has two interfaces - a private LAN gateway address as well as a public WAN address.

I recently used telnet to connect to the private LAN address. IMO this is not a problem as only devices on the same private subnet would be able to sniff traffic.

I then used telnet to connect to the public WAN interface.. am I still essentially connecting to the same interface on my home router? I am just worried that in order to reach the public IP the packets may have gone out of my network (even though the router is NAT'd) and so other people may have been able to sniff my telnet session.

Also if I was to telnet to the public IP from somewhere other than home that would definitely be insecure right?

Thanks a lot.
 

Elixer

Lifer
May 7, 2002
10,371
762
126
What router?
Use VPN for a secure connection to your network from WAN.
Why do you think packets go outside your subnet? They would be routed internally, and not hit your public IP at all.
 

JackMDS

Elite Member
Super Moderator
Oct 25, 1999
29,552
429
126
Electronics is Not like Bottle of water that without a cork can ooze out.

If no one specifically connected to your system and has the needed credentials nothing "pours" out. :eek:



:cool:
 

ams1234

Junior Member
Jul 5, 2015
8
0
0
It's a Thomson router, nothing special.

Elixer - but what if I telnet'd from a host on my LAN to the public address of my router? I'm not quite sure how NAT works.. but I'm guessing both private and public IP are stored on different interfaces of my router.
So doing the above would be secure as I am not going beyond my LAN right? (I don't care about hosts on the LAN being able to see traffic)
 

Gryz

Golden Member
Aug 28, 2010
1,551
204
106
It's a Thomson router, nothing special.

Elixer - but what if I telnet'd from a host on my LAN to the public address of my router? I'm not quite sure how NAT works.. but I'm guessing both private and public IP are stored on different interfaces of my router.
So doing the above would be secure as I am not going beyond my LAN right? (I don't care about hosts on the LAN being able to see traffic)

Yes.
Remember, it's all software in the end. How this works is, packets arrive on an interface. The chip on that interface (ethernet chip, the DSL chip, cable, whatever) just receives bits from the wire. It copies those bits into memory. And then it signals the CPU that a new packet has arrived. The CPU's interrupt handler puts that packet into a queue. And sets a flag that a new packet has arrived.

On the CPU a bunch of processes will be running. One of them takes packets out of the queue and examines them. There are 2 things it can do: 1) forward the packet to another router, or 2) accept the packet for yourself. First thing it does is: look at the destination address, and look it up in the routing table. In the routing table, it sees that the destination is actually directly connected. And even more special: it's destined for the router itself. The process will queue the packet in yet another queue, where another process will take care of it. E.g. it will put your telnet packet in the queue for TCP processes.

If the packet was not destined for the router itself, it will actually have found, in the routing table, the next hop and outgoing interface. It will encapsulate the ip-packet with a new layer-2 header, stick it in the output queue for the outgoing interface, and signal the outgoing interface that it has yet another packet to send out.

I hope this wasn't too complicated. It's pretty straight-forward. The point I was trying to make is: if a packet is destined to a particular device, once it reaches that device, it will not leave again.

There are exceptions, of course. High-end routers have chips (per interface or per linecard) that do all the forwarding. The CPU will never see the packet, unless the packet is destined for the router itself. Some routers will process packets destined for itself in process in user-space. Some will do it in the kernel. All depends on internal implementation. But once thing is true: those packets will not leave the router again.

I know that in some implementation, if you ping your own ip-address on a serial (point-to-point) interface, the router will send a packet out that interface, hoping it receives it back. This is done so that pinging your own interface allows you to check it the point-to-point link is up. However, this only works for ping. And not other protocols (like TCP, which is used by telnet).

BTW, if you are worried about security, it might be better to switch telnet off. And only use ssh. Ssh uses encryption. Not only during authentication, so you don't see clear-text passwords on the wire. But also to encrypt the content. I use Putty to do ssh from a windows-box.
 
Last edited:

ams1234

Junior Member
Jul 5, 2015
8
0
0
I wonder how the "internal routing" on the router works though.. let's say we had a private network of 192.168.1.0/24. If I telnet'd to 209.165.200.34 initially:
1. PC would send ARP request to router, both devices would have ARP entries in their cache.
2. My request would have a src IP of 192.168.1.10 let's say. Even though 209.165.200.34 is an interface on the router, normally if after binary addition is done between the dest. IP and mask (and the dst. network is found to be outside of the LAN) the router will do a routing lookup in its routing table.
3. So are you saying the packet arrives at the router, the router does a lookup in its routing table and then just keeps the TCP packet there?
4. Does the src address (from a different subnet) impact our example in anyway?

Thanks a lot.
 

Gryz

Golden Member
Aug 28, 2010
1,551
204
106
I wonder how the "internal routing" on the router works though.. let's say we had a private network of 192.168.1.0/24. If I telnet'd to 209.165.200.34 initially:
1. PC would send ARP request to router, both devices would have ARP entries in their cache.
Yes. Remember, your PC (say 192.168.1.10) has an arp-entry for the default-gateway (say 192.168.1.1). Not for 209.165.200.34. In fact, your PC doesn't even know that 209.165.200.34 is actually the router.

2. My request would have a src IP of 192.168.1.10 let's say. Even though 209.165.200.34 is an interface on the router, normally if after binary addition is done between the dest. IP and mask (and the dst. network is found to be outside of the LAN) the router will do a routing lookup in its routing table.
I think you got things mixed up. Why would the router do a routing lookup for the request ? It only needs to do one when it send a reply back. And what does that lookup have to do with 209.165.200.34 ?

3. So are you saying the packet arrives at the router, the router does a lookup in its routing table and then just keeps the TCP packet there?
Yes. It does a lookup for the destination address (209.165.200.34) and realize that the packet is destined for itself.

4. Does the src address (from a different subnet) impact our example in anyway?
Probably not. It depends on the implementation. What I think is most likely is that when any packet arrives at the router, the router immediately tags it with the name of the incoming interface. Once it realizes that the packet is destined for itself, and determines it needs to be handled by httpd or sshd, it will check to make sure the packet arrived on the internal interface, and not the external (Internet-facing) interface. You don't want http-requests coming from the big bad Internet.
An implementation could not check the incoming interface, but the source address. That would require another look in the routing table. That could be more costly (though on a home-router it would hardly matter). But more importantly, it could be more easily confused/spoofed, and would be a potential way to break in. I would do the interface-check.
 
Last edited:

ams1234

Junior Member
Jul 5, 2015
8
0
0
I think you got things mixed up. Why would the router do a routing lookup for the request ? It only needs to do one when it send a reply back. And what does that lookup have to do with 209.165.200.34 ?

Very clear replies so far, thanks for that.
I assume the router does send a reply back to the host? Telnet runs over TCP - so doesn't the 3-WAY handshake occur?
 

Gryz

Golden Member
Aug 28, 2010
1,551
204
106
I assume the router does send a reply back to the host? Telnet runs over TCP - so doesn't the 3-WAY handshake occur?
Sure, telnet runs over TCP. And TCP will send packets back and forth. So yes, the router will do lookups both on incoming packets and outgoing packets. It's obvious why it does it on outgoing packets. It does it on incoming packets to determine whether the packet needs to be forwarded further, or is destined for itself.