LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2016, 02:43 PM   #1
thaylin
LQ Newbie
 
Registered: Oct 2015
Posts: 22

Rep: Reputation: Disabled
keepalived 2 ips on same subnet routing question.


I have a mariadb cluster that I am trying to use haproxy/keepalived. They are all on an internal network, but the problem i am having is the reverse looking for mariadb always looks at the primary IP, not the virtual floating IP. I have tried everything I can think of but route are not being added to send the packets out as from the secondary IP
Code:
Any help would be apprechiated:

# Managed by Puppet
vrrp_script chk_haproxy {
  script    "killall -0 haproxy"
  interval  2
  weight
}

global_defs {
  notification_email {
    thaylin@somedomain.org
  }
  notification_email_from keepalive@10.76.10.98
  smtp_server localhost
  smtp_connect_timeout 60
  router_id LVS_DEVEL
}

vrrp_instance VI_2 {
  interface                 eno16780032
  state                     BACKUP
  virtual_router_id         1
  priority                  140
  advert_int                1
  garp_master_delay         5



  # notify scripts and alerts are optional
  #
  # filenames of scripts to run on transitions
  # can be unquoted (if just filename)
  # or quoted (if has parameters)




  authentication {
    auth_type PASS
    auth_pass 1111
  }

  track_script {
    chk_haproxy
  }

  track_interface {
    eno16780032
  }

  virtual_ipaddress {
    10.76.10.105 dev eno16780032 brd 10.76.10.255
  }


  virtual_routes {
default src 10.76.10.105 via 10.76.10.1 dev eno16780032 
#      dev eno16780032 src 10.76.10.105 to 10.76.10.101/24 via 10.76.10.1
#      dev eno16780032 src 10.76.10.105 to 10.76.10.102/24 via 10.76.10.1
#      dev eno16780032 src 10.76.10.105 to 10.76.10.103/24 via 10.76.10.1

  }
[root@lvs2 ~]$ ip route show
default via 10.76.10.1 dev eno16780032 proto static metric 100
10.76.10.0/24 dev eno16780032 proto kernel scope link src 10.76.10.98 metric 100
152.1.14.37 via 10.76.10.1 dev eno16780032 proto dhcp metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

Last edited by thaylin; 03-11-2016 at 02:45 PM.
 
Old 03-12-2016, 07:42 AM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by thaylin View Post
the problem i am having is the reverse looking for mariadb always looks at the primary IP
Can you explain this more, not sure I understand what you are meaning.
Show an example.
 
Old 03-12-2016, 10:03 AM   #3
thaylin
LQ Newbie
 
Registered: Oct 2015
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lazydog View Post
Can you explain this more, not sure I understand what you are meaning.
Show an example.
Sure thing.

First I am running Rhel 7.2, haproxy 1.5.14 and keepalived 1.2.13
[root@lvs2 ~]$ haproxy -v
HA-Proxy version 1.5.14 2015/07/02
Copyright 2000-2015 Willy Tarreau <willy@haproxy.org>

[root@lvs2 ~]$ keepalived -v
Keepalived v1.2.13 (06/25,2015)
[root@lvs2 ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)


In this test setup I have 2 IPs 10.76.10.98(lvs2), which is the hostname for the server itself, and 10.76.10.105(mysqlmnmt) the virtual IP that keepalived handles
2: eno16780032: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:50:56:a8:17:c2 brd ff:ff:ff:ff:ff:ff
inet 10.76.10.98/24 brd 10.76.10.255 scope global dynamic eno16780032
valid_lft 448057sec preferred_lft 448057sec
inet 10.76.10.105/32 brd 10.76.10.255 scope global eno16780032
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fea8:17c2/64 scope link
valid_lft forever preferred_lft forever

The problem that I have is that when I do an mysql -u thaylin -p -h 10.76.10.105 from another machine I get the error

ERROR 1045 (28000): Access denied for user 'thaylin'@'lvs2' (using password: YES)

It should be looking for the hostname associated with

This is not a password error, the password is correct..

I know with mysql you would normally use hostname security of the webserver making the call, but that does not work when you are using haproxy to pass through, and therefore it homes in on the virtual ip keepalived manages.

I have also attempted 2 interfaces. It is easier to route properly, but keepalived tries to add the routes before their is an IP assigned to it, and therefore the network is unreachable, in addition even if you set track_interface to the always live server interface the VRRP requests are not checked on it, but on the managed interface.
 
Old 03-12-2016, 11:57 PM   #4
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
What does the following give you;

Code:
dig lvs2
 
Old 03-13-2016, 06:45 AM   #5
thaylin
LQ Newbie
 
Registered: Oct 2015
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lazydog View Post
What does the following give you;

Code:
dig lvs2
It gives me the proper 10.76.10.98 IP address for the machine. I should so add that the cluster is on different machines than the load balancers, I need them to see the IP as the 105 IP, not the 98.

Last edited by thaylin; 03-13-2016 at 09:24 AM.
 
Old 03-14-2016, 11:15 AM   #6
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
And there in lies the problem. If you want to use host names then those host names have to resolve to the ip addresses you want.
 
Old 03-14-2016, 11:29 AM   #7
thaylin
LQ Newbie
 
Registered: Oct 2015
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lazydog View Post
And there in lies the problem. If you want to use host names then those host names have to resolve to the ip addresses you want.
Thank you, but no, that is not actually the problem. The production has separate hostnames, btw.


Here is a basic diagram of the issue..

------------------- 10.76.10.98 -> Mysql/Mariadb cluster lookup 10.76.10.98

external traffic -> 10.76.10.105

I need this to change to

--------------------10.76.10.98

external traffic -> 10.76.10.105 -> Mysql/Mariadb cluster lookup 10.76.10.105

The .98 address is jsut there for system accessibility for when the .105 address is on lvs1, 10.76.10.97, and to do the VRRP checks. I am currently looking into maybe iptables SNAT?
 
Old 03-14-2016, 01:55 PM   #8
thaylin
LQ Newbie
 
Registered: Oct 2015
Posts: 22

Original Poster
Rep: Reputation: Disabled
thanks for your help, I fixed it using SNAT:

-A POSTROUTING -s 10.76.10.99/32 -p tcp -m multiport --dports 3306 -m comment --comment "100 snat for mysqlcl" -j SNAT --to-source 10.76.10.100
-A POSTROUTING -s 10.76.10.98/32 -p tcp -m multiport --dports 3306 -m comment --comment "100 snat for mysqlcl" -j SNAT --to-source 10.76.10.100
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Keepalived + LVS + Direct Routing. maas187 Linux - Networking 2 03-01-2015 02:05 AM
Mutiple IPs and network cards routing (source policy routing?) shogun1234 Linux - Networking 1 01-17-2013 12:09 AM
how to add subnet ips to 2 server ? a_1 Linux - Server 2 11-09-2011 01:01 PM
Forwarding connection using the same subnet IPs superandrzej Linux - Networking 12 04-27-2004 02:05 AM
NAT'd subnet routing question ealpert1 Linux - Networking 10 05-19-2003 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration