AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-308060

Radu Radu's questions

Martin Hope
Radu Radu
Asked: 2024-03-25 19:05:57 +0800 CST

没有分配 IP 的 dnsmasq 池

  • 5

我在嵌入式设备中有一个简单的 dnsmasq v2.80,我想将其用作 DHCP 服务器以实现自动配置目的。

我想要两个池(一个静态,一个动态)

我所拥有的是这个:

#
# main dnsmasq config file
#

user=nobody
group=nogroup

log-dhcp
dhcp-authoritative
dhcp-rapid-commit
no-dhcp-interface=lo
dhcp-name-match=set:wpad-ignore,wpad
dhcp-ignore-names=tag:wpad-ignore
dhcp-leasefile=/var/lib/misc/dnsmasq.leases

dhcp-option=tag:v69_static_pool_1,option:dns-server,1.2.3.254
dhcp-option=tag:v69_static_pool_1,option:router,1.2.3.253
dhcp-option=tag:v69_static_pool_1,option:ntp-server,1.2.3.252

dhcp-range=set:v69_dynamic_pool_1,10.250.0.2,10.250.0.254,255.255.255.0,12h
dhcp-option=tag:v69_dynamic_pool_1,option:dns-server,10.250.0.1
dhcp-option=tag:v69_dynamic_pool_1,option:router,10.250.0.1
dhcp-option=tag:v69_dynamic_pool_1,option:ntp-server,10.250.0.1

dhcp-range=1.2.3.1,1.2.3.254,255.255.255.0,infinite
dhcp-host=dc:2c:6e:ef:09:33,1.2.3.2,set:v69_static_pool_1

和网络接口

   link/ether ba:86:04:04:64:44 brd ff:ff:ff:ff:ff:ff
   inet 10.250.0.1/24 scope global v69
      valid_lft forever preferred_lft forever
   inet 1.2.3.1/24 scope global v69
      valid_lft forever preferred_lft forever
   inet6 fe80::b886:4ff:fe04:6444/64 scope link 
      valid_lft forever preferred_lft forever

但我想要的是不要浪费 IP 地址,因为我将使用公共 IP 地址分配给网络中的 cpes。我习惯于使用 mikrotik 路由器,虽然接口有一个静态 IP 地址,但足以让我分配接口范围之外的 IP。

而且我想确保静态池不用于分配给动态主机。

dnsmasq 可以吗?

dnsmasq
  • 1 个回答
  • 11 Views
Martin Hope
Radu Radu
Asked: 2018-08-31 06:33:19 +0800 CST

Source-MAC 过滤器 iptables

  • 2

我有一个带有 centos7 的 HAProxy 盒子,并为 smtp 集群做负载平衡代理,为我们的客户提供邮件中继。

default gateway => 10.0.0.1
master-relay.example.net => 10.0.0.254
relay1.example.net => 10.0.0.10 | gateway 10.0.0.1
relay2.example.net => 10.0.0.11 | gateway 10.0.0.1
relay3.example.net => 10.0.0.12 | gateway 10.0.0.1

每个中继都配置了后缀以侦听端口 25 和 587。

我需要实现的是,当任何人尝试发送直接连接到 3 个中继之一(relay1、relay2 或 relay3)的邮件时,会将应答数据包转发到默认网关。这通常是当任何外部邮件服务器尝试向我们发送电子邮件并随机连接到具有相同优先级的 3 台 MX 服务器之一时。

但是,当移动或 webmail 客户端连接到集群以将电子邮件中继到主中继时,该客户端连接到 3 台 MX 服务器之一以传递邮件。

这是集群的 HAProxy 配置:

# Puerto 25 - SMTP (Postfix Cluster)
frontend frontend-smtp-25
        bind 10.0.0.254:25 transparent
        option tcplog
        default_backend backend-smtp-25

backend backend-smtp-25
        option tcplog
        source 0.0.0.0 usesrc clientip
        server mx1 10.0.0.10:25 check
        server mx2 10.0.0.11:25 check
        server mx3 10.0.0.12:25 check

# Puerto 587 - STARTTLS (Postfix Cluster)
frontend frontend-smtp-587
        bind 10.0.0.254:587 transparent
        option tcplog
        default_backend backend-smtp-587

backend backend-smtp-587
        option tcplog
        source 0.0.0.0 usesrc clientip
        server mx1 10.0.0.10:587 check
        server mx2 10.0.0.11:587 check
        server mx3 10.0.0.12:587 check

内核参数:

net.ipv4.tcp_tw_reuse
net.ipv4.tcp_tw_recycle
net.ipv4.ip_local_port_range = 1025 65535

net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1

防火墙规则:

iptables -t mangle -N DIVERT
iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
iptables -t mangle -A DIVERT -j MARK --set-mark 1
iptables -t mangle -A DIVERT -j ACCEPT
ip rule add fwmark 1 lookup 100
ip route add local 0.0.0.0/0 dev lo table 100

现在使用此配置,如果我将中继盒的默认网关更改为主中继,一切正常,并且在后缀日志中我可以看到客户端的 IP 地址,而不是主中继的 IP 地址,但这里我有一个问题,如果任何人都直接连接到relay1,例如这个答案是通过主中继而不是通过网关,客户端丢弃数据包,因为不是来自relay1盒子。

我试图做的是在所有 3 个中继盒上标记主中继的源 MAC 地址,所有与标记匹配的都将默认网关更改为主中继的网关。

所有 IP 都是公共 IP,并且都可以从互联网上看到。

我能做的是将2个IP放在同一个接口中,如果有任何数据包到达IP1,则回复一个网关,如果涉及IP2,则回复另一个网关,但如果可能的话,我真的更喜欢mac规则。

我不能制定规则来强制如果数据包来自主中继 IP 地址再次回复它,因为它将使用客户端 IP 地址到达代理。

提前致谢

iptables postfix
  • 1 个回答
  • 658 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve