how to create ip alias in nodejs - node.js

I am writing test in nodejs.
Calling my api using requestjs.
Now I have to make one call using an ip address to the api (/resources/media)
Then I have to make another call to the same api (/resources/media) using different ip from the same computer.
OS: ubuntu
any idea how to do that
help is very much appreciated.
Thanks

Your only choice is to set up a proxy (like squid), bind it to another (virtual) networking interface card and make the second request through it.

add another ip and make sure it was not existed before
sudo ip addr add 192.168.50.5 dev eth1
Then user localAddress option in requestjs

Related

How can i use a reverse shell over global Internet?

I'm very new to computers and hacking.
The questions I have:
How does one use a reverse shell over a global IP?
Do I need a server or will my pc/Raspberry Pi running on my router work?
Our Router has a dynamic IP, but it doesn't change often. Might this cause trouble?
Thanks!
1. How does one use a reverse shell over a global IP?
You need to host a listener on your device, then your need to port forward your router to allow the listener to be publicly accessible.
2. Do I need a server or will my pc/Raspberry Pi running on my router work?
Any pc/raspberry pi is fine. Only thing to note is that the reverse shell will only accept connections if the device is turned on.
3. Our Router has a dynamic IP, but it doesn't change often. Might this cause trouble?
If your router's public IP address changes, then all your currently deployed clients will stop working. Either be prepared to remake them each time it changes, or setup dynamic DNS for your router and use that to create your binaries.

How to assign an external ip to linux server at gcloud?

Last several days I'm struggling with a problem.
I have two instances(ubuntu server) on gcloud and I want to assign them their external IP.
And I can ping and ssh to my instances but when I try to do telnet it is not performed.
On gcloud all instances have one internal ip and one external IP.
And they does not know their ip. I get it from gcloud console.
How could I assign it to them?
Also I've tried sudo ifconfig eth0:0 130.211.95.1 up
You can do something like this to add the external IP to a local interface:
ip addr add 130.211.95.1/32 dev eth0 label eth0:shortlabel
Replace 'add' with 'del' to remove it once you are done with it.
shortlabel can be any string up to a certain (short) length.
Update: also see this GCE support issue for related information.
A feature request for this is already filed on GCE public issue tracker, however it is not yet implemented. You can star it to get notification if any update posted on the thread.
May you also mention what's your use case? so I can probably provide you with a workaround.

How to run multiple node.js scripts from different IP?

I have one Debian server that has 2 different IP address.
How to run two copies of my NodeJS script from different IP address?
I found a solution:
http.request() and request() has localAddress option. Set it to IP what you need and use.

DNS resolve without depending on router for asterisk system

Basically I have a Debian box running asterisk assigned an IP via DHCP with host-name XXX. My windows browser can resolve the host-name but if I use host-name in X-Lite or my SPA922 phone it fails to resolve. Is there any way of getting this to work without depending on the router or assigning a static IP (request is to make it portable). I was thinking zero-conf but am unsure (box has limited HDD too). Any help is most appreciated.
There are a couple of ways you could do this.
Personally I replaced my stock router firmware with DD-WRT and it then serves as both the DHCP server and supports a local name server (so all machines on the local LAN can access each other by name).
Not quite "not depending on the router" but pretty low configuration, and nothing to configure at all on the client devices really.

Same server, same program but started once using one network card and after with another

I have a Linux server with multiple ips (so, multiple eth0, eth0:0, eth0:1 etc).
The script I'm trying to start is a php CLI script which is downloading stuff from an another server API, and I would like to change the IP based on different parameters. Once the script is started, I don't need anymore to change the ip OF THAT SPECIFIC script until his end.
Do you have any clue if it is possible to achieve it?
My other solution was to install Xen or OpenVZ and create N different VPS per each IP, but as you can see is definitely a PITA :-)
You don't specify how you connect to the other server, but with sockets you can try socket_bind.
EDIT:
With curl you can try curl_setopt.
CURLOPT_INTERFACE The name of the outgoing network interface to use. This can be an interface name, an IP address or a host name.
I know how to do it in C - you use bind() on your socket before you call connect(), and you bind to the IP address assigned to the desired interface, passing 0 for port. I don't know how to do it in PHP.

Resources