How does the VIP loopback aliase work? - webserver

I want to know how does the loopback alias work,lets say i have the following nodes:
n[1-10] on a load balancer,
all under the following VIPs :
xx.xx.xx.xx
yy.yy.yy.yy
on the nodes we have the following:
lo:0 Link encap:Local Loopback
inet addr:xx.xx.xx.xx Mask:255.255.255.255
UP LOOPBACK RUNNING MTU:16436 Metric:1
lo:1 Link encap:Local Loopback
inet addr:yy.yy.yy.yy Mask:255.255.255.255
UP LOOPBACK RUNNING MTU:16436 Metric:1
Can some one explain me what is the concept of the loopback,or giving me a link to read about this concept
sorry , i don't have a deep background about, this ,and i don't want just to know HOW to do it (and this is the most thing i found while i'am searching for),but i want to know why i'am doing this loopback alias
Can some one explain to me what is the life cycle of a client request ,including the load balancer rule,and how the loopback server in this game :) ?
Thanks all

In order for services on the nodes to be able to listen for incoming connections for the VIPS, you need to configure the VIPs on an interface, physical or loopback.
The thing is, you don't want the nodes to answer to ARP requests regarding VIPs, because you only want the load balancer to do that, in order for all connections to go to the load balancer.
In order to do that, you need to do ARP filtering on the nodes one way or another, allowing them to respond to ARP requests for their real IPs, but not for VIPs. On Linux, one really simple way to do that is to configure the system to respond only to ARP requests coming into the interface owning the IP address, using arp_ignore and arp_announce sysctls. Loopback interfaces being local by design, there will be no ARP requests coming into the loopback.
If you want to learn more about that, you can read the "ARP Problem" part of the LVS Howto :
http://www.austintek.com/LVS/LVS-HOWTO/HOWTO/LVS-HOWTO.arp_problem.html

Related

Test UDP Broadcast locally

This is for a school project so I need to use UDP Broadcast.
I am building a P2P app that uses only port 5000 over UDP. I need to send a discovery broadcast packet to all clients in my network.
Normally the app will be used over Hamachi but for the purpose of developing I would like to use the simplest fastest network environment so I would like to test multiple instances locally.
I discovered that it is possible to use 127.0.0.1 127.0.0.2 etc as IPs for my local instance. (Actually tested with ips from 1 to 6 and sending messages at random to each other)
I now need to use the SAME port 5000 but do a broadcast UDP
When I invoke ifconfig on the loopback interface I do not see the BROADCAST option.
Since apparently it is impossible to add the BROADCAST option to the loopback interface, what is the easiest way to have:
1 ip address per instance
same port
running locally
Should I consider using Docker or VM or some network simulator for this purpose?
If you only want to broadcast to all clients, maybe multicast is enough for you. And this can fullfill all the three need you mention. Here is the definition, and here is a little example may help you.

wpa_supplicant connects with static IP but not dhcp

Currently working on an OpenEmbedded/Yocto board, and I'm running into an issue with Wifi.
Inside of interfaces, if I set a static IP, and assign it my network, gateway, netmask, and dns, it works when connecting to a specific wireless access point with wlan0.
However, if I set wlan0 to inet dhcp, instead of inet static, then it can connect to the access point, ping other things on the network, but it cannot get out to the internet. I have tried many things to get it to work, but to no avail.
I have played with wpa_supplicant, and interfaces, as well as udhcpc in order to try and get this to work, but nothing is working.
Does anyone have any ideas?
Edit 1: Took a look at route -n with both dhcp and static. The only difference is that with dhcp, Metric is set to 10 on the dhcp attempt, and 0 on the static.

TCP client using a specific interface while connecting to a webserver

I am trying to connect over Linux. My device is connected to two LANs (say eth0 and eth1) with different networks.
Both networks are connected to internet. I want my client program to be able to use eth1 even though my eth0 is the default interface.
There is an option setsockopt (SO_BINDTODEVICE) to bind to a specific interface but requires root priviledges which is not possible.
Binding to IP address of eth1 is not helping either. Please suggest is there any other way through socket APIs to link the connection with the interface. i.e. my client program will always usse eth1 source IP and interface to connect to the internet whereas all other programs will continue to use eth0 as ususal.
I investigated and appears changes in routing table can help in this but trying to avoid being risky to make system unstable as that is applied to every other programs too.
Thanks in advance.
Kris

How are sockets used for connections/streaming between application NOT over a network?

I have heard that sockets are used for all sorts of streaming between applications to send and receive data.
I have always thought and even read from articles that aim to give a "general sense" that sockets are used to create connections over networks.
However recently I saw that sockets are also used for local streaming/connections between apps which are not over a network.
My question;
How are sockets used for connections/streaming NOT over a network between apps?
If the applications are on the same machine then you can use the localhost or loopback address 127.0.0.1 as the IP address of the socket and any port number > 1024 in both applications and then they can communicate over this connection .
Also, if you want to use the socket approach and on linux, AF_UNIX is better than inet socket as they avoid some level of inet specific tasks like routing/adding-removing ip and transport headers, etc

Sniffing data on uClinux local loopback

I am looking for a way to monitor/sniff local loopback traffic inside a uClinux embedded device. I have several processes that communicate via the local loopback and want to capture this traffic on an outside machine. So I want to direct a copy of all local loopback traffic out the "real" Ethernet to a specific IP address, namely that of my Windows PC running a sniffer.
Is this possible, maybe with iptables or something? The traffic is all UDP, between a few dozen ports. If not, I was thinking about writing some code to open a raw socket, read in the packets in question and forward them to my fixed IP address. Would it work to capture local loopback traffic with a raw socket?