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.
Best Answer
In the end, I figured it out. Configure one interface to have two IP addresses:
then add an iproute table:
add a rule:
add a route to the table:
Perhaps somebody will find that useful.