0

so I have the following problem. There is dedicated Ubuntu 18.04 host, that is supposed to be assigned a static ip address. There are two interfaces, eth0 and eth1.

eth0 ist getting its address via DHCP from the hoster. From the same hoster, we got another static IP address that we are supposed to configure on the server. So this is how the netplan config looks like:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: yes
    eth1:
      dhcp4: no
      dhcp6: no
        addresses: [$STATIC_IP/32]
      nameservers:
        addresses: [8.8.4.4,8.8.8.8]

When I netplan apply, the ip a shows

37: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP 
group default qlen 1000
link/ether ac:1f:6b:85:51:86 brd ff:ff:ff:ff:ff:ff
inet $DHCP_IP/32 scope global dynamic eth0
   valid_lft 85932sec preferred_lft 85932sec
inet6 fe80::ae1f:6bff:fe85:5186/64 scope link 
   valid_lft forever preferred_lft forever

65: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state 
DOWN group default qlen 1000
link/ether ac:1f:6b:85:51:87 brd ff:ff:ff:ff:ff:ff

So the eth1 doesn't seem to be configured at all.

Syslog says: systemd-networkd[27425]: eth1: IPv6 successfully enabled

networkd-dispatcher[10223]: WARNING:Unknown index 66 seen, reloading interface list

I searched for that warning, but came up with nothing that could help me.

This is the first part of the problem, since I can assign an address with ip addr add $STATIC_IP dev eth1. The interface is still showing as DOWN, but I can ping it from the outside:

65: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state 
DOWN group default qlen 1000
link/ether ac:1f:6b:85:51:87 brd ff:ff:ff:ff:ff:ff
inet $STATIC_IP/32 scope global eth1
   valid_lft forever preferred_lft forever

So far, so good.

When I try to set up the routing, so this interface gets used and is subsequently shown as the the sender IP, I get the following. Mind that I don't know the gateway address for sure, but I can ping it:

$ ip addr add default via $STATIC_IP_GATEWAY table staticip

results in Error: Nexthop has invalid gateway.

I tried all kinds of other combinations, and at this point, I am stumped and don't know if it's my inability or the hoster's.

In brief: I got given a static IP and want to use it for an interface so that this static IP shows as the origin address when I contact something from this server.

What am I missing? How is this usually done?

Thanks in advance and I'll happily provide more info as needed.

  • The problem is that eth1 is not connected. (NO-CARRIER) The ip gets set when the link is up, otherwise it is cleared. – mabagu Sep 26 '18 at 10:14
0

In the end, I figured it out. Configure one interface to have two IP addresses:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: yes
      addresses: [$STATIC_IP/32]

then add an iproute table:

echo "mytable >> /etc/iproute2/rt_tables

add a rule:

ip rule add from all lookup mytable

add a route to the table:

ip route add default via $DHCP_GATEWAY src $STATIC_IP table mytable

Perhaps somebody will find that useful.

  • Please accept your answer (by clicking the mark below the voting arrows), so the question is marked as solved in the system and doesn't pop up again and again. – Gerald Schneider Feb 4 at 7:30

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.