1IPVSADM(8)                Linux Administrator's Guide               IPVSADM(8)
2
3
4

NAME

6       ipvsadm - Linux Virtual Server administration
7

SYNOPSIS

9       ipvsadm -A|E -t|u|f service-address [-s scheduler]
10               [-p [timeout]] [-M netmask] [-b sched-flags]
11       ipvsadm -D -t|u|f service-address
12       ipvsadm -C
13       ipvsadm -R
14       ipvsadm -S [-n]
15       ipvsadm -a|e -t|u|f service-address -r server-address
16               [-g|i|m] [-w weight] [-x upper] [-y lower]
17       ipvsadm -d -t|u|f service-address -r server-address
18       ipvsadm -L|l [options]
19       ipvsadm -Z [-t|u|f service-address]
20       ipvsadm --set tcp tcpfin udp
21       ipvsadm --start-daemon state [--mcast-interface interface]
22               [--syncid syncid]
23       ipvsadm --stop-daemon state
24       ipvsadm -h
25

DESCRIPTION

27       Ipvsadm(8)  is  used  to set up, maintain or inspect the virtual server
28       table in the Linux kernel. The Linux Virtual  Server  can  be  used  to
29       build  scalable  network  services  based  on  a cluster of two or more
30       nodes. The active node of the cluster redirects service requests  to  a
31       collection  of  server  hosts  that will actually perform the services.
32       Supported features include two protocols (TCP and UDP),  three  packet-
33       forwarding methods (NAT, tunneling, and direct routing), and eight load
34       balancing algorithms (round robin, weighted round robin,  least-connec‐
35       tion,   weighted   least-connection,  locality-based  least-connection,
36       locality-based least-connection with replication,  destination-hashing,
37       and source-hashing).
38
39       The command has two basic formats for execution:
40
41       ipvsadm COMMAND [protocol] service-address
42               [scheduling-method] [persistence options]
43
44       ipvsadm command [protocol] service-address
45               server-address [packet-forwarding-method]
46               [weight options]
47
48       The  first  format  manipulates a virtual service and the algorithm for
49       assigning service requests to real servers.  Optionally,  a  persistent
50       timeout  and  network  mask for the granularity of a persistent service
51       may be specified. The second format manipulates a real server  that  is
52       associated  with  an  existing  virtual service. When specifying a real
53       server, the packet-forwarding method and the weight of the real server,
54       relative  to  other real servers for the virtual service, may be speci‐
55       fied, otherwise defaults will be used.
56
57   COMMANDS
58       ipvsadm(8) recognises the commands described below. Upper-case commands
59       maintain  virtual  services.  Lower-case commands maintain real servers
60       that are associated with a virtual service.
61
62       -A, --add-service
63              Add a virtual service. A service address is uniquely defined  by
64              a triplet: IP address, port number, and protocol. Alternatively,
65              a virtual service may be defined by a firewall-mark.
66
67       -E, --edit-service
68              Edit a virtual service.
69
70       -D, --delete-service
71              Delete  a  virtual  service,  along  with  any  associated  real
72              servers.
73
74       -C, --clear
75              Clear the virtual server table.
76
77       -R, --restore
78              Restore  Linux  Virtual  Server rules from stdin. Each line read
79              from stdin will be treated as the command line options to a sep‐
80              arate  invocation  of ipvsadm. Lines read from stdin can option‐
81              ally begin with "ipvsadm".  This option is useful to avoid  exe‐
82              cuting  a large number or ipvsadm  commands when constructing an
83              extensive routing table.
84
85       -S, --save
86              Dump the Linux Virtual Server rules to stdout in a  format  that
87              can be read by -R|--restore.
88
89       -a, --add-server
90              Add a real server to a virtual service.
91
92       -e, --edit-server
93              Edit a real server in a virtual service.
94
95       -d, --delete-server
96              Remove a real server from a virtual service.
97
98       -L, -l, --list
99              List  the virtual server table if no argument is specified. If a
100              service-address is selected, list this service only. If  the  -c
101              option is selected, then display the connection table. The exact
102              output is affected by the other arguments given.
103
104       -Z, --zero
105              Zero the packet, byte and rate counters in a service or all ser‐
106              vices.
107
108       --set tcp tcpfin udp
109              Change  the  timeout values used for IPVS connections. This com‐
110              mand always takes  3  parameters,   representing   the   timeout
111              values (in seconds) for TCP sessions, TCP sessions after receiv‐
112              ing a  FIN packet, and  UDP  packets, respectively.   A  timeout
113              value 0 means that the current timeout value of the  correspond‐
114              ing  entry  is preserved.
115
116       --start-daemon state
117              Start the connection synchronization daemon.  The  state  is  to
118              indicate  that  the  daemon  is started as master or backup. The
119              connection synchronization  daemon  is  implemented  inside  the
120              Linux kernel. The master daemon running at the primary load bal‐
121              ancer multicasts changes of connections  periodically,  and  the
122              backup daemon running at the backup load balancers receives mul‐
123              ticast message and creates corresponding connections.  Then,  in
124              case  the  primary  load  balancer fails, a backup load balancer
125              will takeover, and it has state of almost  all  connections,  so
126              that  almost  all established connections can continue to access
127              the service.
128
129       The sync daemon currently only supports IPv4 connections.
130
131       --stop-daemon
132              Stop the connection synchronization daemon.
133
134       -h, --help
135              Display a description of the command syntax.
136
137   PARAMETERS
138       The commands above accept or require zero  or  more  of  the  following
139       parameters.
140
141       -t, --tcp-service service-address
142              Use TCP service. The service-address is of the form host[:port].
143              Host may be one of a plain IP address or a hostname. Port may be
144              either a plain port number or the service name of port. The Port
145              may be omitted, in which case zero will be used. A Port  of zero
146              is  only  valid if the service is persistent as the -p|--persis‐
147              tent option, in which case it is a wild-card port, that is  con‐
148              nections will be accepted to any port.
149
150       -u, --udp-service service-address
151              Use UDP service. See the -t|--tcp-service for the description of
152              the service-address.
153
154       -f, --fwmark-service integer
155              Use a firewall-mark, an integer  value  greater  than  zero,  to
156              denote  a virtual service instead of an address, port and proto‐
157              col (UDP or TCP). The marking of packets with a firewall-mark is
158              configured  using the -m|--mark option to iptables(8). It can be
159              used to build a virtual service associated with  the  same  real
160              servers,   covering  multiple  IP  address,  port  and  protocol
161              triplets. If IPv6 addresses are used,  the  -6  option  must  be
162              used.
163
164              Using  firewall-mark  virtual  services  provides  a  convenient
165              method of grouping together different IP  addresses,  ports  and
166              protocols into a single virtual service. This is useful for both
167              simplifying configuration if a large number of virtual  services
168              are  required  and grouping persistence across what would other‐
169              wise be multiple virtual services.
170
171       -s, --scheduler scheduling-method
172              scheduling-method  Algorithm for allocating TCP connections  and
173              UDP datagrams to real servers.  Scheduling algorithms are imple‐
174              mented as kernel modules. Ten are shipped with the Linux Virtual
175              Server:
176
177              rr - Round Robin: distributes jobs equally amongst the available
178              real servers.
179
180              wrr - Weighted Round Robin: assigns jobs to real servers propor‐
181              tionally  to  there  real  servers'  weight. Servers with higher
182              weights receive new jobs first and get more  jobs  than  servers
183              with lower weights. Servers with equal weights get an equal dis‐
184              tribution of new jobs.
185
186              lc - Least-Connection: assigns more jobs to  real  servers  with
187              fewer active jobs.
188
189              wlc  -  Weighted  Least-Connection: assigns more jobs to servers
190              with fewer  jobs  and  relative  to  the  real  servers'  weight
191              (Ci/Wi). This is the default.
192
193              lblc  -  Locality-Based  Least-Connection: assigns jobs destined
194              for the same IP address to the same server if the server is  not
195              overloaded  and available; otherwise assign jobs to servers with
196              fewer jobs, and keep it for future assignment.
197
198              lblcr  -  Locality-Based  Least-Connection   with   Replication:
199              assigns  jobs destined for the same IP address to the least-con‐
200              nection node in the server set for the IP address.  If  all  the
201              node  in the server set are over loaded, it picks up a node with
202              fewer jobs in the cluster and adds it in the sever set  for  the
203              target.  If  the server set has not been modified for the speci‐
204              fied time, the most loaded node is removed from the server  set,
205              in order to avoid high degree of replication.
206
207              dh  - Destination Hashing: assigns jobs to servers through look‐
208              ing up a statically assigned hash table by their destination  IP
209              addresses.
210
211              sh  - Source Hashing: assigns jobs to servers through looking up
212              a statically assigned hash table by their source  IP  addresses.
213              This  scheduler  has two flags: sh-fallback, which enables fall‐
214              back to a different server if the selected server  was  unavail‐
215              able, and sh-port, which adds the source port number to the hash
216              computation.
217
218              sed - Shortest Expected Delay: assigns an incoming  job  to  the
219              server with the shortest expected delay. The expected delay that
220              the job will experience is (Ci + 1) / Ui if   sent  to  the  ith
221              server,  in which Ci is the number of jobs on the the ith server
222              and Ui is the fixed service rate (weight) of the ith server.
223
224              nq - Never Queue: assigns an incoming job to an idle  server  if
225              there  is, instead of waiting for a fast one; if all the servers
226              are busy, it adopts the Shortest Expected Delay policy to assign
227              the job.
228
229       -p, --persistent [timeout]
230              Specify  that a virtual service is persistent. If this option is
231              specified, multiple requests from a client are redirected to the
232              same  real  server  selected for the first request.  Optionally,
233              the timeout of persistent sessions may  be  specified  given  in
234              seconds, otherwise the default of 300 seconds will be used. This
235              option may be used in conjunction with protocols such as SSL  or
236              FTP where it is important that clients consistently connect with
237              the same real server.
238
239              Note: If a virtual service is to  handle  FTP  connections  then
240              persistence  must be set for the virtual service if Direct Rout‐
241              ing or Tunnelling is used as the forwarding mechanism.  If  Mas‐
242              querading  is  used in conjunction with an FTP service than per‐
243              sistence is not necessary, but the ip_vs_ftp kernel module  must
244              be  used.   This module may be manually inserted into the kernel
245              using insmod(8).
246
247       -M, --netmask netmask
248              Specify the granularity with which clients are grouped for  per‐
249              sistent  virtual services.  The source address of the request is
250              masked with this netmask to direct all clients from a network to
251              the  same  real server. The default is 255.255.255.255, that is,
252              the persistence granularity is per client  host.  Less  specific
253              netmasks  may  be  used  to resolve problems with non-persistent
254              cache clusters on the client  side.   IPv6  netmasks  should  be
255              specified  as  a  prefix  length between 1 and 128.  The default
256              prefix length is 128.
257
258       -b, --sched-flags sched-flags
259              Set scheduler flags for this virtual server.  sched-flags  is  a
260              comma-separated  list  of flags.  See the scheduler descriptions
261              for valid scheduler flags.
262
263       -r, --real-server server-address
264              Real server that  an  associated  request  for  service  may  be
265              assigned  to.   The server-address is the host address of a real
266              server, and may plus port. Host can be either a plain IP address
267              or  a  hostname.   Port can be either a plain port number or the
268              service name of port.  In the case of the  masquerading  method,
269              the  host address is usually an RFC 1918 private IP address, and
270              the port can be different from that of the  associated  service.
271              With  the  tunneling  and  direct  routing methods, port must be
272              equal to that of the service address. For normal  services,  the
273              port  specified   in the service address will be used if port is
274              not specified. For fwmark services,  port  may  be  omitted,  in
275              which  case  the destination port on the real server will be the
276              destination port of the request sent to the virtual service.
277
278       [packet-forwarding-method]
279
280              -g, --gatewaying  Use gatewaying (direct routing). This  is  the
281              default.
282
283              -i, --ipip  Use ipip encapsulation (tunneling).
284
285              -m,  --masquerading   Use  masquerading (network access transla‐
286              tion, or NAT).
287
288              Note:  Regardless of the packet-forwarding mechanism  specified,
289              real servers for addresses for which there are interfaces on the
290              local node will be use the local forwarding method, then packets
291              for the servers will be passed to upper layer on the local node.
292              This cannot be specified by ipvsadm, rather it set by the kernel
293              as real servers are added or modified.
294
295       -w, --weight weight
296              Weight  is an integer specifying the capacity  of a server rela‐
297              tive to the others in the pool. The valid values of weight are 0
298              through to 65535. The default is 1. Quiescent servers are speci‐
299              fied with a weight of zero. A quiescent server will  receive  no
300              new  jobs  but still serve the existing jobs, for all scheduling
301              algorithms distributed with the Linux Virtual Server. Setting  a
302              quiescent  server  may  be useful if the server is overloaded or
303              needs to be taken out of service for maintenance.
304
305       -x, --u-threshold uthreshold
306              uthreshold is an integer specifying the upper connection thresh‐
307              old of a server. The valid values of uthreshold are 0 through to
308              65535. The default  is  0,  which  means  the  upper  connection
309              threshold is not set. If uthreshold is set with other values, no
310              new connections will be sent to the server when  the  number  of
311              its connections exceeds its upper connection threshold.
312
313       -y, --l-threshold lthreshold
314              lthreshold is an integer specifying the lower connection thresh‐
315              old of a server. The valid values of lthreshold are 0 through to
316              65535.  The  default  is  0,  which  means  the lower connection
317              threshold is not set. If lthreshold is set  with  other  values,
318              the  server  will receive new connections when the number of its
319              connections drops  below  its  lower  connection  threshold.  If
320              lthreshold  is  not  set  but uthreshold is set, the server will
321              receive new connections when the number of its connections drops
322              below three forth of its upper connection threshold.
323
324       --mcast-interface interface
325              Specify  the  multicast  interface  that  the sync master daemon
326              sends outgoing multicasts through, or  the  sync  backup  daemon
327              listens to for multicasts.
328
329       --syncid syncid
330              Specify the syncid that the sync master daemon fills in the Syn‐
331              cID header while sending multicast messages, or the sync  backup
332              daemon  uses  to  filter out multicast messages not matched with
333              the SyncID value. The valid values of syncid are  0  through  to
334              255. The default is 0, which means no filtering at all.
335
336       -c, --connection
337              Connection  output.  The list command with this option will list
338              current IPVS connections.
339
340       --timeout
341              Timeout output. The list command with this option  will  display
342              the   timeout values (in seconds) for TCP sessions, TCP sessions
343              after receiving a FIN packet, and UDP packets.
344
345       --daemon
346              Daemon information output. The list  command  with  this  option
347              will display the daemon status and its multicast interface.
348
349       --stats
350              Output  of  statistics  information.  The list command with this
351              option will display the statistics information of  services  and
352              their servers.
353
354       --rate Output  of  rate  information. The list command with this option
355              will display the rate information (such  as  connections/second,
356              bytes/second and packets/second) of services and their servers.
357
358       --thresholds
359              Output  of  thresholds  information.  The list command with this
360              option will display the upper/lower connection threshold  infor‐
361              mation of each server in service listing.
362
363       --persistent-conn
364              Output  of  persistent  connection information. The list command
365              with this option will display the persistent connection  counter
366              information  of  each  server in service listing. The persistent
367              connection is used to forward the actual  connections  from  the
368              same client/network to the same server.
369
370              The  list  command  with  the  -c,  --connection option and this
371              option will include persistence engine data, if any is  present,
372              when listing connections.
373
374       --sort Sort  the list of virtual services and real servers. The virtual
375              service entries are sorted  in  ascending  order  by  <protocol,
376              address,  port>. The real server entries are sorted in ascending
377              order by <address, port>. (default)
378
379       --nosort
380              Do not sort the list of virtual services and real servers.
381
382       -n, --numeric
383              Numeric output.  IP addresses and port numbers will  be  printed
384              in  numeric  format  rather  than  as as host names and services
385              respectively, which is the  default.
386
387       --exact
388              Expand numbers.  Display the exact value of the packet and  byte
389              counters,  instead  of only the rounded number in K's (multiples
390              of 1000) M's (multiples of 1000K) or G's (multiples  of  1000M).
391              This option is only relevant for the -L command.
392
393       -6, --ipv6
394              Use with -f to signify fwmark rule uses IPv6 addresses.
395
396       -o, --ops
397              One-packet  scheduling.   Used in conjunction with a UDP virtual
398              service or a fwmark virtual service that handles only UDP  pack‐
399              ets.   All  connections are created such that they only schedule
400              one packet.
401

EXAMPLE 1 - Simple Virtual Service

403       The following commands configure a Linux Director to distribute  incom‐
404       ing  requests addressed to port 80 on 207.175.44.110 equally to port 80
405       on five real servers. The forwarding method used  in  this  example  is
406       NAT,  with  each  of  the  real  servers being masqueraded by the Linux
407       Director.
408
409       ipvsadm -A -t 207.175.44.110:80 -s rr
410       ipvsadm -a -t 207.175.44.110:80 -r 192.168.10.1:80 -m
411       ipvsadm -a -t 207.175.44.110:80 -r 192.168.10.2:80 -m
412       ipvsadm -a -t 207.175.44.110:80 -r 192.168.10.3:80 -m
413       ipvsadm -a -t 207.175.44.110:80 -r 192.168.10.4:80 -m
414       ipvsadm -a -t 207.175.44.110:80 -r 192.168.10.5:80 -m
415
416       Alternatively, this could be achieved in a single ipvsadm command.
417
418       echo "
419       -A -t 207.175.44.110:80 -s rr
420       -a -t 207.175.44.110:80 -r 192.168.10.1:80 -m
421       -a -t 207.175.44.110:80 -r 192.168.10.2:80 -m
422       -a -t 207.175.44.110:80 -r 192.168.10.3:80 -m
423       -a -t 207.175.44.110:80 -r 192.168.10.4:80 -m
424       -a -t 207.175.44.110:80 -r 192.168.10.5:80 -m
425       " | ipvsadm -R
426
427       As masquerading is used as the forwarding mechanism  in  this  example,
428       the  default  route of the real servers must be set to the linux direc‐
429       tor, which will need to be configured to forward and  masquerade  pack‐
430       ets. This can be achieved using the following commands:
431
432       echo "1" > /proc/sys/net/ipv4/ip_forward
433

EXAMPLE 2 - Firewall-Mark Virtual Service

435       The  following commands configure a Linux Director to distribute incom‐
436       ing requests addressed to any port on 207.175.44.110 or  207.175.44.111
437       equally to the corresponding port on five real servers. As per the pre‐
438       vious example, the forwarding method used in this example is NAT,  with
439       each of the real servers being masqueraded by the Linux Director.
440
441       ipvsadm -A -f 1  -s rr
442       ipvsadm -a -f 1 -r 192.168.10.1:0 -m
443       ipvsadm -a -f 1 -r 192.168.10.2:0 -m
444       ipvsadm -a -f 1 -r 192.168.10.3:0 -m
445       ipvsadm -a -f 1 -r 192.168.10.4:0 -m
446       ipvsadm -a -f 1 -r 192.168.10.5:0 -m
447
448       As  masquerading  is  used as the forwarding mechanism in this example,
449       the default route of the real servers must be set to the  linux  direc‐
450       tor,  which  will need to be configured to forward and masquerade pack‐
451       ets. The real server should also be configured to mark incoming packets
452       addressed  to any port on 207.175.44.110 and  207.175.44.111 with fire‐
453       wall-mark 1. If FTP traffic is to be handled by this  virtual  service,
454       then  the ip_vs_ftp kernel module needs to be inserted into the kernel.
455       These operations can be achieved using the following commands:
456
457       echo "1" > /proc/sys/net/ipv4/ip_forward
458       modprobe ip_tables
459       iptables  -A PREROUTING -t mangle -d 207.175.44.110/31 -j MARK --set-mark 1
460       modprobe ip_vs_ftp
461

IPv6

463       IPv6 addresses should be surrounded by square brackets ([ and ]).
464
465       ipvsadm -A -t [2001:db8::80]:80 -s rr
466       ipvsadm -a -t [2001:db8::80]:80 -r [2001:db8::a0a0]:80 -m
467
468       fwmark IPv6 services require the -6 option.
469

NOTES

471       The Linux Virtual Server implements three  defense  strategies  against
472       some  types of denial of service (DoS) attacks. The Linux Director cre‐
473       ates an entry for each connection in order to keep its state, and  each
474       entry occupies 128 bytes effective memory. LVS's vulnerability to a DoS
475       attack lies in the potential to increase the number entries as much  as
476       possible until the linux director runs out of memory. The three defense
477       strategies against the attack are: Randomly drop some  entries  in  the
478       table.  Drop  1/rate packets before forwarding them. And use secure tcp
479       state transition table and short  timeouts.  The  strategies  are  con‐
480       trolled  by  sysctl  variables  and  corresponding entries in the /proc
481       filesystem:
482
483       /proc/sys/net/ipv4/vs/drop_entry      /proc/sys/net/ipv4/vs/drop_packet
484       /proc/sys/net/ipv4/vs/secure_tcp
485
486       Valid values for each variable are 0 through to 3. The default value is
487       0, which disables the respective defense strategy. 1 and  2  are  auto‐
488       matic  modes - when there is no enough available memory, the respective
489       strategy will be enabled and the variable is automatically  set  to  2,
490       otherwise  the  strategy  is  disabled  and the variable is set to 1. A
491       value of 3 denotes that the respective strategy is always enabled.  The
492       available  memory  threshold and secure TCP timeouts can be tuned using
493       the sysctl variables and corresponding entries in the /proc filesystem:
494
495       /proc/sys/net/ipv4/vs/amemthresh /proc/sys/net/ipv4/vs/timeout_*
496

FILES

498       /proc/net/ip_vs
499       /proc/net/ip_vs_app
500       /proc/net/ip_vs_conn
501       /proc/net/ip_vs_stats
502       /proc/sys/net/ipv4/vs/am_droprate
503       /proc/sys/net/ipv4/vs/amemthresh
504       /proc/sys/net/ipv4/vs/drop_entry
505       /proc/sys/net/ipv4/vs/drop_packet
506       /proc/sys/net/ipv4/vs/secure_tcp
507       /proc/sys/net/ipv4/vs/timeout_close
508       /proc/sys/net/ipv4/vs/timeout_closewait
509       /proc/sys/net/ipv4/vs/timeout_established
510       /proc/sys/net/ipv4/vs/timeout_finwait
511       /proc/sys/net/ipv4/vs/timeout_icmp
512       /proc/sys/net/ipv4/vs/timeout_lastack
513       /proc/sys/net/ipv4/vs/timeout_listen
514       /proc/sys/net/ipv4/vs/timeout_synack
515       /proc/sys/net/ipv4/vs/timeout_synrecv
516       /proc/sys/net/ipv4/vs/timeout_synsent
517       /proc/sys/net/ipv4/vs/timeout_timewait
518       /proc/sys/net/ipv4/vs/timeout_udp
519

SEE ALSO

521       The LVS web site (http://www.linuxvirtualserver.org/) for more documen‐
522       tation about LVS.
523
524       ipvsadm-save(8), ipvsadm-restore(8), iptables(8),
525       insmod(8), modprobe(8)
526

AUTHORS

528       ipvsadm - Wensong Zhang <wensong@linuxvirtualserver.org>
529              Peter Kese <peter.kese@ijs.si>
530       man page - Mike Wangsmo <wanger@redhat.com>
531               Wensong Zhang <wensong@linuxvirtualserver.org>
532               Horms <horms@verge.net.au>
533
534
535
5364th Berkeley Distribution        5th July 2003                      IPVSADM(8)
Impressum