-1

I have a CentOS 7 PC (with 2 NIC cards) and 2 servers. I'd like to access these servers from the 2 NICs in a different way. Something like one server can be reached only from NIC1, and the other server should be accessed only from NIC2. I've realized that I'm unable to put them into the same subnet using the IP addresses 10.10.10.{1-4}/29 for some reason.

However, should this work?

NIC1: 10.10.10.1/30     ->     Server1: 10.10.10.2/30
NIC2: 10.10.10.4/30     ->     Server2: 10.10.10.5/30

I'm always confused with networking and subnetting. Please advise.

Humberto Castellon
  • 879
  • 1
  • 7
  • 17
Bert
  • 1,028
  • 1
  • 16
  • 33
  • 3
    I'm afraid those addresses/masks don't make sense. A `/30` subnet has two usable host IPs each. In the case of `10.10.10.0/30`, you have the correct host IPs - `.1` on your client host, and `.2` on the server host. Unfortunately, the only 2 usable IPs for `10.10.10.4/30` are `.5` and `.6`. `.4` **cannot** be used for a host, as it is the network address. Before going any further, you need to fix those assignments for NIC2. Once you do that, it *should* just work. – guzzijason Oct 18 '18 at 14:56
  • Use a firewall (e.g. **iptables**) on the servers to limit which source IP addresses can connect to the servers. On the client with the two NICs either you get a setup with two /30 networks and it will use the correct source IP address to connect to each server or, if all IP addresses are the in a /24 network, you should use static host routes to use the correct exit interface. – Tommiie Oct 18 '18 at 14:58

1 Answers1

0

@guzzijason have technically answered the question for me and pointed out a mistake I've made calculating the IP address.

So the sollution was:

  • PC:

    • eth0: 10.10.10.1/30
    • eth1: 10.10.10.5/30
  • Server1

    • eth0: 10.10.10.2/30
  • Server2

    • eth0: 10.10.10.6/30

Thank you Mate!

Bert
  • 1,028
  • 1
  • 16
  • 33
  • Of course, using `/30` networks for point-to-point links wastes half of the network addresses. Look at _[RFC 3021, Using 31-Bit Prefixes on IPv4 Point-to-Point Links](https://tools.ietf.org/html/rfc3021)_. – Ron Maupin Oct 19 '18 at 15:18
  • I don't need the rest of that network, so this is OK for me :) – Bert Oct 19 '18 at 15:20