How to capture only incoming TCP streams in WireShark? - filter

How to capture only incoming TCP streams in WireShark?
(I would like to capture only HTTP connections to my web server, not any outgoing HTTP connections from applications.)

Based on my test,
1. You can use this capture filter for the WireShark that running on the server which you want monitor incoming packets:
dst host 10.58.123.456 and dst port 8080
And you can use following result filter to view traffic comes from certain client:
ip.src_host == 10.78.123.456

Use a filter like (ip dst host 192.168.0.1 and tcp dst port 80) or (ip src host 192.168.0.1 and tcp src port 80).

Related

Same host UDP packet correlation in Go

In Go one can send UDP packets using net.Addr interface to specify the target endpoint. Some special addresses, e.g. :8080 and 0.0.0.0, sends packets using local loopback interface. When received, still on the same host, the message's net.Addr shows [::1]:8080 as source. What is the the easiest way to determine that the packet was sent and received by the same host?
Here's an example in the Go Playground. It shows 0.0.0.0:8080 (ipv4) instead of [::1]:8080.
I ended up using net.Dial("udp", addr) and eminently closing the connection. Dial also resolves hostnames, which I also needed.
Would be nice to avoid creating a socket, but Dial works for now.
:8080 is not an address, it is a port number, typically used when testing your own http websites on Windows because on Windows you cannot easily use port 80, the actual http port.
This will only use the loopback interface if you use localhost as the IP address.
The localhost address for IPv4 is 127.0.0.1 and for IPv6 it is ::1. The address 0.0.0.0 is usually used as a placeholder address to indicate, for example, listening on all IP addresses, see this question.
As mentioned in the comment, you can use net.IP.Equal to check if your peer is localhost. Just compare your address in question to 127.0.0.1 or to ::1, the net.IP.Equal function considers them equal.

How do I check whether an open port is TCP or HTTP?

Specifically, I have a Windows server (Windows 7), but the netstat -an command only shows whether ports are TCP or UDP. I thought these were the only kinds of ports, but node.js seems to distinguish between HTTP ports and TCP ports (example at bottom of linked page). I'm currently using node.js in a program that will run on my server, and it opens HTTP ports by default. These appear as TCP ports under netstat -an.
Is there a command line trick for distinguishing whether an open port on this server is HTTP or TCP? I make requests to my Information Technology office about ports that I need on this server, and they need to know whether these ports will be TCP, UDP, etc.
If necessary to use a remote client, I have a Mac that can do the job.
HTTP is an application protocol. Its definition presumes an underlying and reliable transport layer protocol. The transmission Control Protocol is commonly used. However HTTP can use unreliable protocols too (example SSDP).
Now to answer to your question:
netstat -lt : List TCP Listening Ports
netstat -lu : List UDP Listening Ports
If you want to know wether a TCP Port is running HTTP or not, you can check the standard port on HTTP (grep :80). The standard HTTP port is 80. The standard HTTPS port is 443.
All HTTP traffic is transmitted over TCP Ports. I think what may be causing some confusion is that the first node.js example uses the http module and the second example uses the net module.
The http module is built on top of the net module (which handles the TCP layer underlying HTTP).
Refer to: nodejs - net or http module
EDIT:
Only one process can bind to a port. If you're having difficulties connecting, shut down any other applications that may be using the same port, such as your Java Hello World server. Run netstat -an to make sure you don't see the port listed that you're trying to listen on in you node.js TCP server (port 1337) in the example. If nothing is listening on the port, fire up your node.js TCP server and run netstat -an again to make sure it's actually listening on the intended port.
Another suggestion - temporarily turn off the software firewall then use the telnet client on the local server to attempt to connect to the port using the command telnet 127.0.0.1 1337 (replace 1337 with your port) from the command prompt. This will eliminate any network devices such as firewalls between the client (telnet in this case) and the server. If the screen goes blank, you've connected. If you get the message Could not open connection to the host, on port then it's still not listening on the TCP Port. If you can connect locally from Telnet but you cannot connect remotely then there is something blocking your connection.

ElasticSearch - specifying an exact port (no port range)

I want to specify an exact port for ElasticSearch to use for HTTP traffic. How can I do so? In the config file, it says it listens to a port range by default. How can I restrict this port range to just 1 port?
Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens
on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node
communication. (the range means that if the port is busy, it will automatically
try the next port).
In config folder.. There is an file called "elasticsearch.Yml". In that
Parameters for port are commented.. Just remove hash before http.port and add port value to it..
http.port : 5000
You can do this for both tcp and http

Wireshark not capturing HTTPS packets?

Wireshark is not capturing https packets. I've tried filtering them by portmap.port == 443 but no https packet is shown, however, http packets are captured fine.
Any suggestions?
portmap refers to the ONC RPC portmapper protocol. That's only used for ONC RPC protocols such as NFS, YP, and the portmapper/rpcbind protocol itself.
HTTP, and HTTP-over-SSL/TLS, i.e. "https", do not use ONC RPC and, in particular, don't use the portmapper. They run atop TCP, so you'd want a display filter such as tcp.port == 443. (If you want a capture filter, so the only traffic you capture is traffic to or from port 443, port 443 would be the equivalent capture filter.)

Unable to receive response from the SNMP port

I am using SNMP to access the remote system data. According to the requirement I am encoding the SNMP request data to OAMPDU packet format and sending to remote system. The remote system receives the OAMPDU packet, decodes it and sends the snmp request to snmp agent through UDP socket which is bound to port 161. But I am unable to receive the response from snmp agent. I have created a UDP socket which is bound to 161 port to receive the response.
If I use any other free port number other than 161 for receiving SNMP agent does not send responses to that port.
Can anyone please suggest me how to overcome this problem?
Can we configure the different ports for tx,rx ???
How do we know on which port does snmp sends the response ???
Each UDP packet has a source port and a destination port. An SNMP manager sends out an SNMP request using any source port, and destination port 161. The agent will reply to the source port on the manager. For example:
Manager Agent
source port: <random number>
dest port: 161
content: what is your sysUpTime
source port: 161
destination port: <same random number>
content: sysUpTime is 42 seconds
Replies arrive on random number port, not port 161. So a manager listening on port 161 is unlikely to receive many replies. Instead of listening on port 161, listen on the same socket you used to send out the request. That socket will remember the source port it chose for sending.
P.S. When you use SNMP to query, SNMP's manager is UDP's client, and SNMP's agent is UDP's server.

Resources