1

I have several servers on a private network, each with a private IP address assigned and a public IP assigned. I want the servers to only communicate with each other using their private IP addresses.

I have set up the IP addresses using Netplan, but am now trying to set up the routes so that if Server A is trying to communicate with Server B it does so via Server A's private ip, not through any other IP assigned to the server.

This is my Netplan configuration file so far (I've XXX'd out parts of the public IP addresses for security):

network:
  ethernets:
    ens160:
      addresses:
      - 217.147.XXX.43/26
      - 172.17.1.151/24
      dhcp4: false
      #gateway4: 217.147.XXX.1
      #gateway4: 172.17.1.1
      nameservers:
        addresses:
        - 172.17.1.2
        - 172.17.1.3
        - 8.8.8.8
        search: []
      routes:
      - to: 0.0.0.0/0
        via: 217.147.XXX.1
        metric: 100
      - to: 172.17.1.0/24
        via: 172.17.1.1
        metric: 101
  version: 2

The output of ip route command:

$ ip route
default via 217.147.XXX.1 dev ens160 proto static metric 100 
172.17.1.0/24 dev ens160 proto kernel scope link src 172.17.1.151 
172.17.1.0/24 via 172.17.1.1 dev ens160 proto static metric 101 
217.147.XXX.0/26 dev ens160 proto kernel scope link src 217.147.XXX.43 

Output of the ifconfig command:

$ ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 217.147.XXX.43  netmask 255.255.255.192  broadcast 217.147.XXX.63
        inet6 fe80::2cc:29cc:fef5:966f  prefixlen 64  scopeid 0x20<link>
        ether 00:cc:29:cc:96:6f  txqueuelen 1000  (Ethernet)
        RX packets 728  bytes 71057 (71.0 KB)
        RX errors 0  dropped 119  overruns 0  frame 0
        TX packets 355  bytes 58475 (58.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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 1000  (Local Loopback)
        RX packets 102  bytes 8213 (8.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 102  bytes 8213 (8.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

The problem that I have is that private network is not visible.

$ ping 172.17.1.155
PING 172.17.1.155 (172.17.1.155) 56(84) bytes of data.
From 172.17.1.151 icmp_seq=1 Destination Host Unreachable
From 172.17.1.151 icmp_seq=2 Destination Host Unreachable
From 172.17.1.151 icmp_seq=3 Destination Host Unreachable
. . .

the server 172.XXX.XXX.155 is available from other servers in private network.

Any help would be greatly appreciated. I'm fairly new to networking and Netplan and I'm struggling with the official documentation.

2
  • By obfuscating all of the IP addresses with XXX, it is impossible to tell which numbers are the same or different in your config, and therefore impossible to notice any errors in the routing config. Please update your question to de-obfuscate the private IPs (they are private, so this doesn't give anyone any sensitive information that could be used in an attack against you). – slangasek Feb 11 at 2:30
  • @slangasek You are right, I've udated the post. – LONGMAN Feb 11 at 10:26
1
  - to: 172.17.1.0/24
    via: 172.17.1.1
    metric: 101

This is incorrect. 172.17.1.0/24 is your local network, and you are trying to route all traffic for it via 172.17.1.1. That machine is probably not configured to route traffic both to and from 172.17.1..0 on the same interface. If you drop this route, traffic to 172.17.1.155 will be routed via your local network instead, which should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.