Como servir uma sub-rede diferente com uma placa NIC, de acordo com “dhcp-server-identifier”, em centos7

3

Eu tenho um sistema isolado que não consegue acessar a Internet.

Eu quero usar um dos servidores para executar o servidor dhcp, e dar ip diferente em sub-rede diferente em que o cliente quer morar.

Eu posso enviar uma requisição para a subnet2 do cliente para o servidor, mas o servidor sempre retorna o ip na subnet1.

Abaixo está minha configuração.

/etc/dhcp/dhcpd.conf

subnet 172.16.50.0 netmask 255.255.255.0 {
  range 172.16.50.100 172.16.50.200;
  option subnet-mask 255.255.255.0;
  option routers 172.16.50.254;
  option broadcast-address 172.16.50.255;
  option ip-forwarding off;
  option domain-name-servers 8.8.8.8;
  if exists user-class and option user-class = "iPXE" {
    filename "bootstrap.ipxe";
  } else {
    filename "undionly.kpxe";
  }
  next-server   172.16.50.31;
}
subnet 172.16.51.0 netmask 255.255.255.0 {
  range 172.16.51.100 172.16.51.200;
  option subnet-mask 255.255.255.0;
  option routers 172.16.51.254;
  option broadcast-address 172.16.51.255;
  option ip-forwarding off;
  option domain-name-servers 8.8.8.8;
  if exists user-class and option user-class = "iPXE" {
    filename "bootstrap.ipxe";
  } else {
    filename "undionly.kpxe";
  }
  next-server   172.16.51.31;
}

configuração de ip

$ sudo modprobe dummy
$ sudo ip link set name eth10 dev dummy0
$ sudo ip addr add 172.16.51.31/24 brd + dev eth10 label eth10:0

$ ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 04:7d:7b:d8:bb:6a brd ff:ff:ff:ff:ff:ff
    inet 172.16.50.31/24 brd 172.16.50.255 scope global enp1s0f0
       valid_lft forever preferred_lft forever
    inet6 fe80::67d:7bff:fed8:bb6a/64 scope link
       valid_lft forever preferred_lft forever
3: enp1s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether 04:7d:7b:d8:bb:6b brd ff:ff:ff:ff:ff:ff
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
    link/ether 52:54:00:36:03:d7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500
    link/ether 52:54:00:36:03:d7 brd ff:ff:ff:ff:ff:ff
7: eth10: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN
    link/ether d2:b8:2e:44:a5:2f brd ff:ff:ff:ff:ff:ff
    inet 172.16.51.31/24 brd 172.16.51.255 scope global eth10:0
       valid_lft forever preferred_lft forever

$ ifconfig

enp1s0f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.50.31  netmask 255.255.255.0  broadcast 172.16.50.255
        inet6 fe80::67d:7bff:fed8:bb6a  prefixlen 64  scopeid 0x20<link>
        ether 04:7d:7b:d8:bb:6a  txqueuelen 1000  (Ethernet)
        RX packets 5288228  bytes 1902558434 (1.7 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6310647  bytes 6023578728 (5.6 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xdfe20000-dfe3ffff

enp1s0f1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 04:7d:7b:d8:bb:6b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xdfe00000-dfe1ffff

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 6164718  bytes 2009821769 (1.8 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6164718  bytes 2009821769 (1.8 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:36:03:d7  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

"no cliente" /etc/dhcp/dhclient.conf

send dhcp-server-identifier 172.16.51.31;

executar o cliente dhcp

$ dhclient -r -v ens20f0
    Listening on LPF/ens20f0/54:ab:3a:3d:2c:7a
    Sending on   LPF/ens20f0/54:ab:3a:3d:2c:7a
    Sending on   Socket/fallback
    DHCPRELEASE on ens20f0 to 172.16.50.31 port 67 (xid=0x41973da)

$ dhclient -s 172.16.51.31 -v ens20f0
    Listening on LPF/ens20f0/54:ab:3a:3d:2c:7a
    Sending on   LPF/ens20f0/54:ab:3a:3d:2c:7a
    Sending on   Socket/fallback
    DHCPDISCOVER on ens20f0 to 172.16.51.31 port 67 interval 7 (xid=0x2c4dfe6c)
    DHCPREQUEST on ens20f0 to 172.16.51.31 port 67 (xid=0x2c4dfe6c)
    DHCPOFFER from 172.16.50.31
    DHCPPACK from 172.16.50.31 (xid=0x2c4dfe6c)
    bound to 172.16.50.116 -- renewal in 20324 seconds.

Eu envio uma solicitação para 172.16.50.31. Mas eu só tenho o ip em 172.16.50.0/24.

Li uma solução on-line: link

Mas isso é no Ubuntu, não no centos. Eu não posso fazer isso passo a passo.

Existe algum método para fornecer ip na subnet differnet no CentOS 7?

    
por Iven CJ7 10.10.2016 / 15:08

1 resposta

2

Eu encontrei a solução sozinho.

Adicionar a interface virtual como interface permanente em / etc / sysconfig / network-script / permitirá que o servidor ofereça sub-redes múltiplas com uma interface real.

Se a interface for adicionada como temporária (ex. ifconfig eth0:1 172.16.52.0/24 ), o servidor não poderá atender com várias sub-redes.

    
por 15.10.2016 / 21:27