用于在Ubuntu中进行负载平衡的IPIP隧道


1

我在gentoo负载平衡器和gentoo真实服务器之间设置了ldirectord / heartbeat HA。由于主机的限制,我可以通过ipip隧道进行负载平衡。

我在gentoo真实服务器上具有以下设置:

(附加到...的末尾)/etc/conf.d/net

iptunnel_tunl0="mode ipip"

config_tunl0=( 
        "xxx.xxx.xxx.xxx netmask 255.255.255.255"
        "yyy.yyy.yyy.yyy netmask 255.255.255.255"
        "zzz.zzz.zzz.zzz netmask 255.255.255.255"
)

那些xxx / yyy / zzz IP是我共享的IP地址。

“ ip address show”显示如下:

4: tunl0: <NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN 
    link/ipip 0.0.0.0 brd 0.0.0.0
    inet xxx.xxx.xxx.xxx/32 scope global tunl0
    inet yyy.yyy.yyy.yyy/32 scope global tunl0:1
    inet zzz.zzz.zzz.zzz/32 scope global tunl0:2

这一切都很好。

我现在正在尝试设置ipip隧道到Ubuntu真实服务器。

我可以使用以下方法显示界面:

ip tunnel add tunl0 mode ipip

然后通过将其附加到/ etc / network / interfaces来添加IP地址

auto tunl0
  iface tunl0 inet static
  address xxx.xxx.xxx.xxx
  netmask 255.255.255.255

然后我的“ ip addr show”命令显示与gentoo机器上的命令相同

问题是IP隧道添加..不会在重新启动后持续存在,因此下次网络尝试加载时,我们会得到

# /etc/init.d/networking restart
* Reconfiguring network interfaces...
ssh stop/waiting
ssh start/running, process 2442
ssh stop/waiting
ssh start/running, process 2482
SIOCSIFADDR: No such device
tunl0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
tunl0: ERROR while getting interface flags: No such device
Failed to bring up tunl0.
   ...done.

如何像在Gentoo中一样使隧道接口持久化?

Answers:


2

有两种处理方法。如果您只需要一个简单的命令,那么最简单的方法是在/ etc / network / interfaces中为您的条目添加pre-up和添加行pre-down

auto tunl0

iface tunl0 inet static
  pre-up ip tunnel add tunl0 mode ipip
  post-down ip tunnel del tunl0 mode ipip
  address xxx.xxx.xxx.xxx
  netmask 255.255.255.255

或者,如果您想做更复杂的事情,则可以分别在启动和关闭网络之前分别向/etc/network/if-pre-up.d/和添加/etc/network/if-post-down.d/运行脚本。


2

五年来,事情发展了很长的路要走。行属于(/ etc / network / interfaces)

请参阅man 5 intefaces以获取更多详细信息。

# Choose your own name for your tunnel interface (example uses 'mytun')
auto mytun
iface mytun inet tunnel
  mode ipip

  # Best I can tell, value of 'netmask' does nothing but is required:
  netmask 255.255.255.255

  # Local address (inside tunnel) (required)
  address 192.168.1.1 

  # dstaddr = remote address (inside tunnel)
  dstaddr 192.168.2.2

  # local = address of tunnel interface
  local x.x.x.x

  # endpoint = destination ip applied to ipip encapsulated packets (required)
  endpoint y.y.y.y

  # You may want to also consider using these two options
  # mtu 1480
  # ttl 63
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.