Modify destination port in TCP/IP headers of all outgoing packets - windows

Used SSH Tunnel to route the traffic addressed to server1:port1 to server2:port2.
Now,the problem is that i want to redirect all TCP/IP packets from desktop addressed to server1:port1 to server2:port2.
using "hosts" file on windows, i mapped server1 ip as ipaddress of server2. [local DNS mapping]
http://server2:port2 //gives the desired page.
http://server1:port2 //gives the desired page as server1 ip is mapped as that of server2 ip.
Is it possible to rewrite the destination port of all TCP/IP packets addressed to some host?
[Transform destination port all TCP/IP packets with (destn ip as server1 and destn port as port1) to port2]
This is required as there is no direct access to server1 from the working desktop.
I can't use the same port number on server2 as that of server1 as that port is already taken on server2.
Please share your comments on this.

You can use iptables to rewrite the destination port either on the desktop machine or on an intermediate router.

Related

Why doesn't this telnet command connect to this socket "server IP and SMTP port" in command line

C:\Users\Kyle>telnet 10.0.0.1 25
The response that I get is:
Connecting To 10.0.0.1...Could not open connection to the host, on port 25: Connect failed
Some ISP will block port 25 due to spamming concern. Consider to try with port 587 instead.
10.0.0.1 is a private IP address. You can only connect directly to that IP address if there is a server at that address on your local network. You should verify that there is a server at that IP address, and that the server is running a program that is listening for connections on port 25.

I can't connect a webpage on my ec2

I am building simple webpage.
I could run on my local host.
I made ec2 instance, I opened ports 22, 8000.
I could connect with ssh and run server for webpage,
but I get this error
this is my github address that contain the code.
enter link description herehttps://github.com/MoreNiceJay/django2
In your security group rules, open port 80
This is the standard port for http traffic
Other things to check: login to the host with ssh and use netstat |grep LISTEN to see if there is a process listening on port 80

How to open incoming port 50070 in firewall (google compute engine)

I have my Single node Hadoop installed on Google Compute Engine instance and i want to open port 50070 on that machine to access the hadoop dashboard. i configured in the firewall rule as tcp:50070 in compute engine networks. but still i am unable to access my port outside the network (ie . via internet). I tried nmap for the public ip of my GCE instance and i got a result which has only ssh port got opened all other ports are filtered .
Note: i am using debian 7.5 image
Make sure your daemon is listening on port 50070. If you have more than one networks in you project make sure the port is opened on the right network. You can run the following commands to check the information about your instance and network.
lsof -i
gcutil --project= getinstance
gcutil --project= listnetworks
gcutil --project= listfirewalls
gcutil --project= getfirewall
Check if IP/Port is allowed in iptables or not.
iptables -L
would show you all the records.
To allow port in iptables you can do the following:
sudo iptables -A INPUT -p tcp -m tcp --dport 50070 -j ACCEPT
sudo iptables-save -c
Short answer
In addition to configure the firewall rule at GCE web console make sure that your server is listening at 0.0.0.0 instead of 127.0.0.1
Long answer
In the context of servers, 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs - Source
In contrast 127.0.0.1 is the IP address used to stablish a connection to the same machine used by the user this address is usually referred as the localhost.
It's often used when you want a network-capable application to only serve clients on the same host. A process that is listening on 127.0.0.1 for connections will only receive local connections on that socket. - Source
Hence, if you try to stablish a connection to your server from internet and your server is listening at 127.0.0.1 at your GCE machine, then, from the server point of view a request has never been received and as a consequence Goocle Cloud Firewall will refuse the connection because there is no server listening at the opened port (in your case 50070).
I hope this answer helps to solve your problem. Best regards.

Ruby - How to send a text string from a TCP Server to a client on a different computer with Ruby?

I've been trying to learn this for days and nothing is working. When I write code like this
for the client.
require 'socket'
tcp_client=TCPSocket.new('localhost',2000)
while grab_string=tcp_client.gets
puts(grab_string)
end
tcp_client.close
and code like this for the server.
# Set up a server program.
require 'socket'
tcp_server=TCPServer.new(2000)
loop{
waiting_client=tcp_server.accept
path='C:\Users\Nil_Face\Music\Bad Religion - Anxiety.mp3'
test=File.new(path,'rb')
waiting_client.puts(File.basename(path))
test.close
waiting_client.close
}
It works just fine but when I use that server on my desktop and try to get that text string to appear on the client located on a different computer. It doesn't work. Why won't the client connect to the server when their both on different computers? And how can I get them to?
Your client is connecting to 'localhost', which is the same computer where the client runs.
tcp_client=TCPSocket.new('localhost',2000)
The client should be connecting to the hostname/ip of the machine on which the server is running. Change 'localhost' with the IPv4 address / inet addr of the server machine, in this case '192.168.1.10'.
On windows:
ipconfig
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : local.domain
IPv4 Address. . . . . . . . . . . : 192.168.1.10
On Linux:
# /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr FF:FF:FF:FF:FF:FF
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
If you're getting connection timed out. You can try connecting with telnet from the command prompt:
telnet 192.168.1.10 2000
From the server computer, you can also verify that the server is running and is accepting connections with netstat:
netstat -an
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:2000 0.0.0.0:0 LISTENING
If those are all correct, you probably have a firewall that is blocking the connection.

How do I change the IP address in XAMPP for Windows?

I've been trying to figure out how I can change my server config for XAMPP so that it doesn't have a memory fault when both Windows and the server are trying to access localhost at the same time. Basically I want XAMPP to be IP of 127.0.1.1 or something similar so it doesn't interfere with the localhost used by the system so I can browse the web and my websites that I'm developing. What is happening is that if I have XAMPP and Eversoft's first page 2000 v2.0 running at the same time, I'll get a BSOD (blue screen of death) in the middle of editing my sites. This is an intermittent problem, but always happens with these two programs.
Just edit c:\xampp\apache\conf\httpd.conf and change the Listen 80 to Listen 127.0.0.2:80 or whatever ip address you want. Make sure you place : between the ip address and port number, in this case it was port 80.
These are the steps to follow when you want your PHP application to be installed on a LAN server (not on web)
Get the internal IP or Static IP of the server (Ex: 192.168.1.193)
Open XAMPP>apache>conf>httpd.conf file in notepad
Search for Listen 80
Above line would read like- #Listen 0.0.0.0:80 / 12.34.56.78:80
Change the IP address and replace it with the static IP
Save the httpd.conf file ensuring that the server is pointed to #Listen 192.168.1.193:80
In the application root config.php (db connection) replace localhost with IP address of the server
Note: If firewall is installed, ensure that you add the http port 80 and 8080 to exceptions and allow to listen. Go to Control Panel>Windows Firewall>Allow a program to communicate through windows firewall>Add another program Name: http Port: 80 Add one more as http - 8080
If IIS (Microsoft .Net Application Internet Information Server) is installed with any Microsoft .Net application already on server, then it would have already occupied 80 port. In that case change the #Listen 192.168.1.193:80 to #Listen 192.168.1.193:8080
Hint:
first part=file location --- second part=find in the file ---
third part=replace with finded text
How Change "127.0.0.1" in Xampp To "127.0.0.2" (or paste your favorite ip instead 127.0.0.2)
(C:\xampp\apache\conf\httpd.conf) --- Listen 80 --- Listen 127.0.0.2:80
(C:\xampp\apache\conf\extra\httpd-ssl.conf) --- Listen 443 --- Listen 127.0.0.2:443
(C:\xampp\php\php.ini) --- ;xdebug.remote_host = "127.0.0.1" --- ;xdebug.remote_host = "127.0.0.2"
(C:\xampp\phpMyAdmin\config.inc.php) --- $cfg['Servers'][$i]['host'] = '127.0.0.1'; --- $cfg['Servers'][$i]['host'] = '127.0.0.2';
How Change "Localhost" in Xampp To "myhost" (or paste your favorite name instead myhost)
xampp control panel admin butoons still open localhost
(C:\xampp\apache\conf\httpd.conf) --- ServerName localhost:80 --- ServerName myhost:80
(C:\xampp\php\php.ini) --- ; SMTP = localhost --- ; SMTP = myhost
(C:\Windows\System32\drivers\etc\HOSTS) --- 127.0.0.1 localhost --- 127.0.0.2 localhost
127.0.0.2 myhost >>> #(next line after 127.0.0.2 localhost)
You can point 127.0.1.1 to 127.0.0.1 in your windows hosts file (Windows/system32/driver/etc)

Resources