how to change ipv6 to ipv4? - sockets

i've problem with change ipv6 to ipv4 when i used this command
lsof -i :6702
got this
java 3143 st 71u IPv6 12097 0t0 TCP *:6702 (LISTEN)
as you can see it using ipv6 and i want to change it to ipv4
i used the
supervisor.childopts: "-Djava.net.preferIPv4Stack=true"
in storm.yaml
summary in storm ui read the change but when i used
lsof -i :6702 didn't read it ! still using ipv6 !

If 6702 is a worker, perhaps try to add -Djava.net.preferIPv4Stack=true to worker.childopts as well?
It looks like you are on a dual stack node. The v6 socket should accept incoming v4 connections transparently. What problem are you trying to solve?

Error disappered by adding this property
-Djava.net.preferIPv4Stack=true
to nimbus and supervisor and worker in storm.yaml

Related

Postgres database port 5432. Is it connecting to the internet?

I am a newbie to connections. I ran the following command on my ubuntu server:
lsof -nP -iTCP -sTCP:LISTEN
and this came up, among other connections:
postgres 29826 postgres 7u IPv6 192275 0t0 TCP [::1]:5432 (LISTEN)
postgres 29826 postgres 8u IPv4 192276 0t0 TCP 127.0.0.1:5432 (LISTEN)
I am configuring my "ufw" firewall and trying to understand what is connecting to my server. Question is the following:
Is this connecting in some way to the internet? I am assuming it is not, since the IP address is local. Another question, is there a command to check only incoming and outcoming connections to the internet? Somewhat simplified so I can understand it better?
Thank you very much
You are right, that server is only listening on the loopback interface.
You'll have to change the listen_addresses parameter and restart PostgreSQL.

Libvirt dnsmasq is running on all interfaces, this is undesired

So currently I'm running libvirt on my debian box, and it's DHCP server is listening on all interfaces, I would like to restrict that down to the bridge interface where the VMs would live. I can kill off the dhcp server temporarily to accomplish what I need but would like something more permanent.
I'm sure there is some option I can put in the dhcp server portion of the network config to make this happen.
<network>
<name>default</name>
<uuid>2fb34907-96bc-4af1-89a2-4f1f872a2600</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:c3:d2:ea'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
<host mac='52:54:00:21:df:dc' ip='192.168.122.2'/>
</dhcp>
</ip>
<route address='192.168.122.2' prefix='32' gateway='192.168.122.110'/>
</network>
root#calypso-deb:~# lsof -i -n | grep dnsmasq
dnsmasq 1656 nobody 3u IPv4 29150 0t0 UDP *:bootps
dnsmasq 1656 nobody 5u IPv4 29153 0t0 UDP 192.168.122.1:domain
dnsmasq 1656 nobody 6u IPv4 29154 0t0 TCP 192.168.122.1:domain (LISTEN)
root#calypso-deb:~#
Here’s a suggestion (which is meant to be a comment rather than an answer, but I cannot comment).
User Jonathon Reinhart posted an answer that describes how to pass options to dnsmasq (since libvirt v.5.6.0). See also “Network XML format” in the libvirt documentation. This got me wondering whether passing something like --interface=virbr0 --bind-interfaces would do what you need in this case.
It should already be listening on virbr0 interface only, as the config shows that too.
You can check that with lsof -i -n | grep dnsmasq or similar tools.

Redirect port on Windows from loopback to outside

I have a socket that listen on port 6100 on my development machine, whose lan address is 192.168.1.2
I can access the socket and use it with the address 127.0.0.1:6100, but I can't access it from 192.168.1.2:6100 (I need to access the socket from another client on the Lan)
If I type netstat -an | find "6100" on the command prompt I get:
TCP 127.0.0.1:6100 0.0.0.0:0 LISTENING
So I need to redirect all calls to 192.168.1.2:A_RANDOM_PORT to 127.0.0.1:6100
How can i do that?
I tried with:
netsh interface portproxy add v4tov4 listenport=6200 listenaddress=192.168.1.2 connectport=6100 connectaddress=127.0.0.1
But without luck
I've finally been able to accomplish this task, but only using an external tool.
I downloaded "PassPort port forwarding utility" and set up a redirection from 192.168.1.2 to 127.0.0.1
Unfortunately I haven't been able to do that without an external tool.
You failed to post the code concerned, but you bound your listening socket to 127.0.0.1 instead of 0.0.0.0. Just fix that. No oort forwarding required.

Opening port so that pgAdmin on Windows 7 can connect to PostgreSQL on Debian on VirtualBox

Hello all :) I'm a having a little trouble connecting this.
On Windows 7 about my Debian 6 on VitualBox configured with Host-only Adapter:
>nmap -T4 -A -v 192.168.56.1
[...]
5432/tcp unknown postgresql
On the Debian, PostgreSQl is listening:
>netstat -tulpn
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 2432/postgres
tcp6 0 0 :::5432 :::* LISTEN 2432/postgres
.. and the port is opened
>iptables -nL
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0./0 tcp dpt:5432
.. and Postgres is accepting all the connections in postgresql.conf
listen-addresses = '*'
port = 5432
In Windows I have this error message from pdAdmin:
Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "192.168.56.1" and accepting TCP/IP
connections on port 5432?
If you encounter this message, please check if the server you're trying
to contact is actually running PostgreSQL on the given port.
Test if you have network connectivity from your client to the server
host using ping or equivalent tools. Is your network / VPN / SSH tunnel /
firewall configured correctly?
For security reasons, PostgreSQL does not listen on all available
IP addresses on the server machine initially. In order to access
the server over the network, you need to enable listening on the
address first.
For PostgreSQL servers starting with version 8.0, this is controlled
using the "listen_addresses" parameter in the postgresql.conf file.
Here, you can enter a list of IP addresses the server should listen
on, or simply use '*' to listen on all available IP addresses. For
earlier servers (Version 7.3 or 7.4), you'll need to set the
"tcpip_socket" parameter to 'true'.
You can use the postgresql.conf editor that is built into pgAdmin III
to edit the postgresql.conf configuration file. After changing this
file, you need to restart the server process to make the setting effective.
If you double-checked your configuration but still get this error
message, it's still unlikely that you encounter a fatal PostgreSQL
misbehaviour. You probably have some low level network connectivity
problems (e.g. firewall configuration). Please check this thoroughly
before reporting a bug to the PostgreSQL community.
Best regards
What about your pg_hba.conf file?
Have you configured it to accept connections from hosts in the 192.168.56.0 network?
Try to add this line and restart Postgres:
# VitualBox Host-Only Adapter
host all all 192.168.56.0/24 md5
If it's a testing environment you could even replace 192.168.56.0/24 with 0.0.0.0/0 and forget about it.

clojure swank server opens public port?

(This question has been downvoted, which I find strange. How have I offended?)
Am I right to think that running a swank server usually opens port 4005 to the world, not bound to localhost-only connections?
So anyone hacking in a café is not only allowing passers-by to execute arbitrary code on their computer, but is giving them a nice interface to do it with.
It appears that when I run a swank server with either 'mvn clojure:swank', or 'lein swank', or (swank.swank/start-server "/tmp/yo")
then I get something like (thanks Mike!):
$lsof -i -P
java 11693 john 13r IPv6 6701891 0t0 TCP *:34983 (LISTEN)
and indeed I can connect from an emacs running on another machine on the same network.
(swank.swank/start-server "/tmp/yo")
If I start the server by hand, it produces the following output
Connection opened on local port 34983
#<ServerSocket ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=34983]>
Whereas:
(swank.swank/start-server "/tmp/yo" :host "localhost")
produces:
Connection opened on local port 40368
#<ServerSocket ServerSocket[addr=localhost/127.0.0.1,port=0,localport=40368]>
Which seems more like I was expecting.
Is there any good reason for doing this?
Any ideas on how it the more conventional ways of starting it could be persuaded to only accept connections from local processes?
Totally valid question.
After opening a slime server, you'll notice:
eames:~:% lsof -i -P | grep 4005
java 41477 mjd 33u IPv6 0x0b8956d0 0t0 TCP [::127.0.0.1]:4005 (LISTEN)
The connection is listening on the local address at port 4005. This interface isn't exposed to the network, so other devices on the network can't connect to your slime server.
edit:
This was my result of starting swank using leiningen, which provides "localhost" as an argument to swank.swank/start-server. You may want to double check that the leiningen plugin is opening non-local ports.
You're right that swank opens the connection on every address if a host isn't explicitly provided. The relevant code is swank.util.net.sockets/make-server-socket, and this behavior is documented. I agree, it seems like the wrong default.
it only accepts one connection so even if it is exposed to the world it stops listening once you connect.
If you're using the clojure-maven-plugin, version 1.3.4 was recently released which now start the swank server against localhost to prevent this problem.
This behaviour can be configured in your pom.xml file with:
<configuration>
<swankHost>someotherhostname</swankHost>
</configuration>
or from the command line with:
mvn clojure:swank -Dclojure.swank.host=someotherhostname