Is there a specific way to get the Ip of a computer in Pharo smalltalk? - smalltalk

I am trying to run an application Pharo that requires data from the Ip of the host computer in which it's running. In general I have to open the code to set it manually in my Pharo code then launch the application. Is there a better and programmatically way of getting the IP address and returning this address automatically regardless of the computer? Say I deploy it to different computer.

I think you are searching for NetResolverName.
To get name of your computer:
NetNameResolver localHostName
Then you can use it for the IP address. If you execute in Workspace:
NetNameResolver addressForName: NetNameResolver localHostName
You will get a local network address.
In my case: #[192 168 1 17]
Edit
You can also directly query it via:
NetNameResolver localAddressString
Where you will get just: '192 168 1 17'
Note: If you are getting 127.0.0.1
If you are getting localhost address => 127.0.0.1 you probably have issues with the host mapping.
You can test that with via ping "hostname" e.g. ping localhost.localdomain
which will get you replies from 127.0.0.1. If you have correct setup (hosts, DNS, etc.) you should get reply from your IP address.
When I have changed the hostname from localhost.localdomain to smalltalk then ping smalltalk correctly replies with 192.168.10.30. Then Pharo produces correct result.

Related

Configuring apache on ipv6 no connection

Solution: It turns out ipv6 has got it's own firewall which I didn't know and it filtered out 80 and 443! Thanks so much Nicholas Pipitone!
I'm having difficulties to get apache to accept ipv6 connections (everything perfect on ipv4). Results from ready.chair6.net:
What I tested/tried:
Disabling firewall doesn't change the result
Getting apache to listen on all interfaces or specifically the ipv6 interface doesnt change the result
Executing 'curl https://v6.ident.me/' correctly sends me back my ipv6 address
Netstat tells me that both the ipv4 AND ipv6 address are listening for connections on 80 and 443
I'm really stuck here, what else can I do?
The MX record error means it's having a problem getting the IP address from the DNS servers.
Solution: Try dig +short AAAA $hostname and dig +short MX $hostname, with $hostname being your URL. If you don't see an IPv6 IP in the terminal, then you don't have DNS fully setup. If you just recently setup your URL, then wait a day for caches to be updated. If it's been a while, talk to who you bought the domain name from / who's responsible for making your URL point to your IP.
Note: MX is only for mail. If you don't want incoming mail / that's not what the problem is, then that test is testing something it doesn't have to test, and you can ignore it.
More possibilities: Is the hostname on line 4 the same as the host name on the second to last line? Try pinging that IPv6 address from line 4 on a different computer (Not on the same private network); what do you get?
If you get a response, try nmaping the IPv6 on another computer to see if port 80 is open to the public.
-If the nmap fails then try checking your port forwarding settings if you're behind a NAT. If you're not behind the NAT then something might be blocking the request in-between their computer and your computer (Very unlikely); you can try telnet'ing to port 80 remotely and see if you're getting the requests - because then it's just an apache issue.
-If nmap succeeded, then what do you get? Send an HTTP request over command line from the another computer and see if you get a response.
If pinging doesn't work, then you're just not connected to the internet (o.O), idk how to help with that. If pinging the IPv6 works but pinging the URL doesn't, then dig must not be showing anything and it's the DNS as mentioned previously. If dig does show something in that case, then I'm lost.

TURN server broken - Coturn

Just a bit of background first.
I have installed coturn server in my local machine (Behind a firewall and with local IP).
I have created a port forwarding for cotrun server lets say my local ip is: 192.168.0.11:3478 is mapped with my public ip 10.1.10.212:3478.
When I use some online utility to check my public IP has this port open it? that utility shows that it is open.
I am trying to test this server using this fiddle: Code to test TURN server
I removed the stun configuration from it, and added my live ip and port. And when I try to test it, it says your TURN server is broken in console on web browser. And I see failed as output.
I have also used following commands to create a user from this link.
Wiki to Coturn Configuration
// created test user
sudo turnadmin -a -u test -r test -p test
// enabling admin support in web (not sure how to access it in browser)
sudo turnadmin -A -u test -p test
I start the turn server using following command:
turnserver -L 192.168.0.11 -a -f -v -X -r test
I have enabled the "TURNSERVER_ENABLED"
/etc/default/coturn
TURNSERVER_ENABLED=1
Screenshot of my about:webrtc:
Please find the below attached Screen shot for my about:webrtc. I am not sure what is missing.
EDIT-1
I can also see the incoming packet message processed, error 401: Unauthorized in the console of TURN server
EDIT-2
I resolved the TURN server related issue, added the turn server in client code as well, still facing issue, call is not going through,
Update
Here is what I found, the reason why it wasn't working earlier was due to a defective router in the network. This thing has harassed me for almost a month (however the internet used to work fine). But I found that there is a loss of packets and I switch to LAN cable I even avoided the firewall of the organization and there it was working just fine. Then I configured the rules in firewall and it started working as well.
A few issues that might be causing this:
The -X option requires an argument - the external IP if the TURN server is behind a NAT.
If you are setting all your parameters on the command line, you should include -n to ensure that it does not load an unrelated configuration file.
TURNSERVER_ENABLED=1 is to start turnserver with default configuration at system boot. You do not want this if you are starting turnserver manually from the command line.
https://github.com/coturn/coturn/blob/master/README.turnserver
" I have created a port forwarding for CoTurn server lets say my local ip is: 192.168.0.11:3478 is mapped with my public ip 10.1.10.212:3478."
Now surely you are aware that the private address-spaces in IPV4 are (private IP ranges):
10.0.0.0 – 10.255.255.255
172.16.0.0 – 172.31.255.255
192.168.0.0 – 192.168.255.255
So, your first IP is in the last private IP range, and your so-called "public IP" is in the first private IP-range. Now you need to find your TRUE REAL public-IP address to try to connect to it from outside. I would say that it looks like your ISP has you behind a NAT. So your TURN server might be behind two NATs. Which is kind of ironic situation for a server designed to help penetrate NATs of webRTC-clients. You might want to try to put CoTurn somewhere where it is possible for it to work like AWS (special case of CoTurn friendly NAT).
Just recently got (well with lots of help -- that even did the most of the work) CoTurn to work in cloud and on local Ubuntu ;-) (never stopped me from bragging though). Though there is troubling few srflx-call-successes yet (mostly local network or relay(TURN) calls). :-D

Access Apache server installed on a VM remotely from computer in local network

I would like to access Apache from a computer that is inside my network, the problem is Apache is running on a virtual machine:
DIAGRAM
( [A: VM Running Apache] -- [B: Actual machine] ) ------ [C: Actual machine]
IP's:
A: 192.168.55.55
B: 192.168.1.25
I can access A from B just fine, but not from C. (I get a message that reads 'the connection to the server timed out' after a while).
B: NETWORK INFO
PD: The reason Apache is inside a VM is because I'm using Vagrant, not sure that has something to do with anything but I thought I'd mention it anyways.
This is what I did to get this working on my home network.
On the machine actually running Vagrant, edit the Vagrantfile and port forward 8088 (or whatever port # you choose) from the Host ('Actual Machine' as you called it) to port 80 on the Guest ('VM Running Apache' as you called it).
Do a normal vagrant up and you should see the port forwarding happening on boot up. I personally have approximately 8 virtual hosts running inside my Vagrant box each with their own host name. I edited my hosts file on the Host (machine 'B' above) in order to point these hostnames to the ip of the Vagrant box. It works great and I can just put in something like mysite.dev in the address bar and that site pulls up on my local machine.
Now to get this to work on another machine, within the same subnet as the Host machine, you will need to edit the hosts file on that second machine. Point the hostnames, my example was mysite.dev, to the actual ip address of the Host machine. This will forward any instance of mysite.dev to the machine you have labeled as 'B' in your question. The only problem is that this is just pointing to the standard port 80 like any normal webpage. You want this traffic to actually get to machine 'A' in your question. So instead of just putting mysite.dev into the address bar of the browser, put mysite.dev:8088 (or whatever port number you chose to forward to machine 'A' earlier).
Now the traffic from 'C' will be sent to machine 'B' because the hosts file tells it to go there and the additional port you added to the address forces machine 'B' to forward that traffic to port 80 on machine 'A'. Machine 'A' receives the request and returns the data to machine 'B' which then forwards it back to machine 'C'.
The end result is machine 'C' seeing the page returned from machine 'A'.
Hope that about sums it all up.
Good luck!
c0p
If your Vagrant version is >= 1.5 and using a public url doesn't create concerns, the solution should be trivial:
vagrant share
More info here.

OpenSwan L2TP/IPSec sshd bind address

Okay so I have been on Google for about an hour or so trying to figure this one out.
I have a L2TP/IPSec vpn setup. When clients connect a new interface is created for that client the issue is durning boot and most of the time these interfaces do not exist. My vpn range starts at 10.24.1.1 I want sshd to listen on 10.24.1.1 but when there is no client connected it failes to bind address
/var/log/secure:
Apr 15 01:38:26 arija sshd[28068]: error: Bind to port 22 on 10.24.1.1 failed: Cannot assign requested address.
which makes sense. My Question is. Is there a way to create some sort of dummy interface or just assign 10.24.1.1 so sshd will listen on it? Thanks for the help!!
Also Server is CentOs 6 64bit
you can just add the ip address you need to the interface during startup
the configuration depends on which linux flavor you're using, as an example for ubuntu it's located in /etc/network/interfaces.d/eth0.cfg.
Make sure you're excluding this address from the address pool you are using to provision IP Addresses to the L2tP clients
First of all, you need to understand, that in common situation service can listen only on 'up-and-running' interface with assigned IP. The reason of this is Linux core limitations. You can change this behavior at runtime with:
sysctl net.ipv4.ip_nonlocal_bind=1
or at boot time by setting same parameter in /etc/sysctl.conf:
...
net.ipv4.ip_nonlocal_bind=1
...
But there is simpler way for you: you can bind sshd to 0.0.0.0 in their config /etc/ssh/sshd_config:
...
ListenAddress 0.0.0.0
...

name resolution ssh vs ping

I'm having a strange problem in which for many sites if I attempt to ssh into them I get "could not resolve " as a response, but if I try ping or nslookup it finds the same site just fine. Is there a difference in how name resolution works between these services?
The problem is definitely related to names, I can connect to the same sites fine using the ip address rather than the name, and I can connect using the name provided I enter it into /etc/hosts (using a name I found via ping or nslookup on the same machine)
I am experiencing this on a fedora 19 machine.