0

I am having issues on 18.04 Server when I switch from dhcp to static IP on my device. The reason I was switching is that I was getting a new IP address on my server randomly even though my router had a reserved static IP address for my primary interface (eth0). I switched to static and now I'm having issues resolving /routing to my gateway. My setup has three interfaces (eth0 (primary), eth1, eth3). Don't know what is really causing the issues with the bond0 implementation. Data is moving ok within the network but outside is not and therefore I am unable to update the system unless I swap back to dhcp and live with the randomly changing dhcp address.

cat /etc/network/interfaces
# ifupdown has been replaced by netplan(5) on this system.  See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
#    sudo apt install ifupdown
#
# loopback
auto lo
iface lo inet loopback

# primary network card
auto eth0
iface eth0 inet manual
bond-master bond0
bond-primary eth0

# second network interface card
auto eth1
iface eth1 inet manual
bond-master bond0

# third network interface card
auto eth3
iface eth3 inet manual
bond-master bond0

# bond0 network interface
auto bond0
iface bond0 inet static
        address 192.168.0.100
        gateway 192.168.0.1
        netmask 255.255.255.0
        dns-nameservers 192.168.0.1 208.67.222.222 208.67.220.220
                bond_mode 6
                bond-miimon 100
                bond-slaves none

ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::6ef0:49ff:fe5e:c194  prefixlen 64  scopeid 0x20<link>
        ether 6c:f0:49:5e:c1:94  txqueuelen 1000  (Ethernet)
        RX packets 298900  bytes 19550931 (19.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2089172  bytes 3153193403 (3.1 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 6c:f0:49:5e:c1:94  txqueuelen 1000  (Ethernet)
        RX packets 354297  bytes 21749288 (21.7 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15785  bytes 15597970 (15.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=6147<UP,BROADCAST,SLAVE,MULTICAST>  mtu 1500
        ether 6c:f0:49:5e:c9:95  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

eth3: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 00:14:5e:77:45:c6  txqueuelen 1000  (Ethernet)
        RX packets 296791  bytes 19306412 (19.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4487992  bytes 6786908424 (6.7 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xfdee0000-fdf00000

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 7759  bytes 1630081 (1.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7759  bytes 1630081 (1.6 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.0.1     0.0.0.0         UG    0      0        0 bond0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 bond0

root@mediasvr:/home/xxxx# ping www.cnn.com
ping: www.cnn.com: Temporary failure in name resolution

root@mediasvr:/home/xxxx# nslookup www.cnn.com
;; connection timed out; no servers could be reached

root@mediasvr:/home/xxxx# ping 192.168.0.100
PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data.
64 bytes from 192.168.0.100: icmp_seq=1 ttl=64 time=0.059 ms
64 bytes from 192.168.0.100: icmp_seq=2 ttl=64 time=0.053 ms

--- 192.168.0.100 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1028ms
rtt min/avg/max/mdev = 0.053/0.056/0.059/0.003 ms

**root@mediasvr:/home/xxxx# ping 192.168.0.1**
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
From 192.168.0.100 icmp_seq=4 Destination Host Unreachable
From 192.168.0.100 icmp_seq=5 Destination Host Unreachable
From 192.168.0.100 icmp_seq=6 Destination Host Unreachable
From 192.168.0.100 icmp_seq=16 Destination Host Unreachable
From 192.168.0.100 icmp_seq=17 Destination Host Unreachable
From 192.168.0.100 icmp_seq=18 Destination Host Unreachable
From 192.168.0.100 icmp_seq=19 Destination Host Unreachable
From 192.168.0.100 icmp_seq=20 Destination Host Unreachable

--- 192.168.0.1 ping statistics ---
23 packets transmitted, 0 received, +8 errors, 100% packet loss, time 22504ms

root@mediasvr:/home/xxxx# systemd-resolve --status
Global
         DNS Servers: 192.168.0.1
                      208.67.222.222
                      208.67.220.220
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 8 (bond0)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 6 (eth4)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 5 (eth3)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 4 (eth2)
      Current Scopes: none
       LLMNR setting: yes

I am including the additional information requested.

root@mediasvr:/etc/netplan# cat 50-cloud-init.yaml

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
network:
    version: 2
    renderer: networkd
    ethernets:
      bond0:
        dhcp4: no
        dhcp6: no
        addresses: [192.168.0.100/24]
        gateway4: 192.168.0.1
        nameservers:
            addresses: [208.67.222.222, 208.67.220.220]

root@mediasvr:/etc/netplan# ls -al /etc/resolv.conf

lrwxrwxrwx 1 root root 27 Apr 12 14:40 /etc/resolv.conf -> /run/resolvconf/resolv.conf

root@mediasvr:/etc/netplan# cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 208.67.222.222,
nameserver 208.67.220.220
nameserver 127.0.0.53

@heynnema - Update

So I changed both the interface and the .yaml file and applied the netplan without errors (debug) however, I am still having network issues:

  1. I can ping my interface
  2. Team bond is fine according to /proc/net/bonding/bond0 (static) However,
  3. Route command delays to pop up
  4. Unable to ping the gateway
  5. Unable to resolve DNS

Here are the updates I performed:

cat /etc/network/interfaces

# ifupdown has been replaced by netplan(5) on this system.  See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
#    sudo apt install ifupdown
#
# loopback
auto lo
iface lo inet loopback

/etc/netplan/50-cloud-init.yaml

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
network:
  version: 2
    renderer: networkd
    ethernets:
      eth0:
        dhcp4: no
      eth1:
        dhcp4: no
      eth3:
        dhcp4: no
    bonds:
      bond0:
        interfaces: [eth0, eth1, eth3]
        addresses: [192.168.0.100/24]
        gateway4: 192.168.0.1
        nameservers:
          search: [local]
          addresses: [208.67.222.222, 208.67.220.220]
        parameters:
          mode: balance-alb
          mii-monitor-interval: 1
          gratuitious-arp: 5

@heynnema - Update (Thank you for your expertise/time. I believe we are getting closer to resolving this problem)

I enabled an extra unused interface and set it to dhcp in the yaml file and applied via netplan. I kept the team bond the same on the existing 3 nics (eth1-eth3)

eth4: dhcp4: true optional: true

root@mediasvr:/home/raul# route

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         _gateway        0.0.0.0         UG    0      0        0 bond0
default         _gateway        0.0.0.0         UG    100    0        0 eth4
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth4
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 bond0
_gateway        0.0.0.0         255.255.255.255 UH    100    0        0 eth4

root@mediasvr:/home/raul# netstat -rn

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 bond0
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 eth4
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 eth4
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 bond0
192.168.0.1     0.0.0.0         255.255.255.255 UH        0 0          0 eth4

root@mediasvr:/home/raul# traceroute 192.168.01

traceroute to 192.168.01 (192.168.0.1), 64 hops max
  1   192.168.0.1  0.569ms  0.359ms  0.370ms
  1. I am able to ping/perform traceroute to the gateway which I couldn't before.
  2. I can perform DNS lookups
  3. I can ssh into the server remotely via dhcp address

However, 4. I am unable to connect to repositories to get updates - connect (113: No route to host) Could not connect to archive.ubuntu.com:80 (91.189.88.149). 5. I am unable to connect to the plex media server which is now listening on the dhcp address

tcp        0      0 mediasvr:32400          192.168.0.11:10558      TIME_WAIT
tcp        0      0 mediasvr:49206          mediasvr:32400          ESTABLISHED

@heynnema - Updated yaml file (would you rather continue this in a chat?)

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
network:
  version: 2
    renderer: networkd
    ethernets:
      eth0:
        dhcp4: no
        optional: true
      eth1:
        dhcp4: no
        optional: true
      eth3:
        dhcp4: no
        optional: true
      eth4:
        dhcp4: true
        optional: true  
    bonds:
      bond0:
        interfaces: [eth0, eth1, eth3]
        addresses: [192.168.0.100/24]
        gateway4: 192.168.0.1
        nameservers:
          search: [local]
          addresses: [192.168.0.1, 208.67.222.222, 208.67.220.220]
        parameters:
          mode: balance-alb
          mii-monitor-interval: 1
          gratuitious-arp: 5

@heynnema - Update - I've applied your suggestion on the yaml changes. It appears that it has improved a couple of things. Specifically;

  1. I can now ping both eth4 and bond0 internally/externally and the gateway.
  2. DNS resolution works
  3. I can SSH into the server

However, 1. Plex uses the first nic it sees which in this case is the dhcp interface 2. I am unable to interact with the internet

UPDATED Yaml file
    network:
      version: 2
      renderer: networkd
      ethernets:
        eth0:
         dhcp4: no
         optional: true
        eth1:
         dhcp4: no
         optional: true
        eth3:
         dhcp4: no
         optional: true
        eth4:
         dhcp4: true
         optional: true
      bonds:
        bond0:
         interfaces: [eth0, eth1, eth3]
         addresses:
           - 192.168.0.100/24
         #gateway4: 192.168.0.1
         routes:
           - to: 0.0.0.0/0
             via: 192.168.0.1
             metric: 100
         nameservers:
           search: [local]
           addresses: [208.67.222.222, 208.67.220.220]
         parameters:
           mode: balance-alb
           mii-monitor-interval: 1
           gratuitious-arp: 5

root@mediasvr:/home/raul# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 bond0
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 eth4
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 bond0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 eth4
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 bond0
192.168.0.1     0.0.0.0         255.255.255.255 UH        0 0          0 eth4
  • Edit your question and show me cat /etc/netplan/* and ls -al /etc/resolv.conf and cat /etc/resolv.conf. Report back. Start comments to me with @heynnema – heynnema Apr 12 '19 at 23:56
  • @heynnema - I've supplied the additional information you requested – Raul Maldonado Apr 13 '19 at 13:46
  • You've mixed and matched NetworkManager and netplan scripts at the same time. Netplan is normally used in servers, where the configuration is very static. All of the entries that you added to /etc/network/interfaces (except for the original 8 lines) need to be deleted, and moved to /etc/netplan/*.yaml in "netplan-ez" language. See https://netplan.io/examples for guidance. To pick up the reserved addresses in your router, you must set dhcp4: true in your .yaml file. And your bond0 must define what interfaces to use. – heynnema Apr 13 '19 at 14:00
  • @heynnema - I've made the changes to both files, see edits and thanks for the input. I still am having issues – Raul Maldonado Apr 13 '19 at 16:32
  • A couple of things... in /etc/resolv.conf I see "nameserver 208.67.222.222," and I don't know if it's a typo, but there should not be a trailing ",". How/where are those OpenDNS server addresses coming from? Your .yaml looks good to me. I'd add "optional: true" to eth0/1/3 so there's no boot delay. I'd remove the dhcp reserved address for eth0 from your router. Please explain... which ethX is your WAN? What about eth2? What's on eth1/3, and are those really the ports you want to bond? – heynnema Apr 13 '19 at 17:21
  • Probably a typo. The nameserver addresses are Cox DNS servers. I have removed the dhcp reserved address from the router I've added the optional statement to all three interfaces. The server runs plex media, samba and backup. My goal in bonding all three interfaces is to allow my data to be streamed and since some of these video files are large 5-30 gigabytes in size I wanted plenty of bandwidth. Which I was getting minus the IP address change which messes with finding the plex server. Bond0 is the IP address I am using to connect to the server. The server is on my internal network only. – Raul Maldonado Apr 13 '19 at 17:41
  • Give me a couple of minutes to put together an answer for you. It may not be 100% final, but it'll give us some direction... – heynnema Apr 13 '19 at 17:43
  • Show me your current .yaml. – heynnema Apr 13 '19 at 19:21
  • Are you sure your ports are called eth0/1/3/4? Your dhcp4 on eth4 has improper indentation, and could cause problems. Remember when you add formatted text to your answer, you select it, then click the {} icon to make it human-readable here. I've been editing your updates for you :-) – heynnema Apr 13 '19 at 19:36
  • Yes on the ports and my bad on the indentation (typo) it is correct in the yaml file. Thanks for the tip on the editing since this is my first post and was wondering how to accomplish that. – Raul Maldonado Apr 13 '19 at 19:40
  • Since you edited your existing .yaml, are there any tabs or unnecessary spaces in your .yaml? – heynnema Apr 13 '19 at 19:42
  • I made a slight change in my .yaml. I commented out gateway4:, and added a routes: stanza. I'm not a routing expert, so I don't know if it'll help or not. Try it. Report back. – heynnema Apr 13 '19 at 19:58
  • In Plex, go to the Settings/Network/Preferred Network Interface, and select bond0. – heynnema Apr 13 '19 at 20:22
  • Ah, I missed your update to your question. Another tip... send me a comment that starts with @heynnema to send me a notification. Sounds like we're making another small improvement, yes? Did you set the Plex Preferred Network Interface? re:"Plex uses the first nic it sees which in this case is the dhcp interface 2"... interface 2? Power cycle the router/modem by REMOVING AC POWER, replug them, wait 30 seconds, reboot the server, and try Internet access again. Retry Plex. – heynnema Apr 13 '19 at 22:49
  • Eh, instead of rebooting the server, POWER CYCLE it too, after the modem/router. Then reboot. – heynnema Apr 13 '19 at 23:19
  • If it still can't reach the Internet, temporarily comment out optional: true on eth4, and reboot the server. Retry Internet. – heynnema Apr 13 '19 at 23:22
  • Show me sudo lshw -C network. – heynnema Apr 14 '19 at 00:48
  • Where did you go? Status please. – heynnema Apr 14 '19 at 09:49
  • re: "re:"Plex uses the first nic it sees which in this case is the dhcp interface 2"... interface 2?" Never mind this question, I figured it out. – heynnema Apr 14 '19 at 09:50

2 Answers2

0

I have found that in Ubuntu Server 18.04, there is a new way to communicate w/ exterior connections. If you look in /etc/netplan/, there will be a file called 50-cloud-init.yaml.

This is the file, supposedly, that needs to be altered to work w/ static ip addresses. I actually posted a familiar question and there was this fellow that helped out. See here: RE: Getting Ubuntu Server to Show Web Page URL instead of Just my IP Address.

...

If this helps, this is a good notation to make. I also found some similar instances on this site that are dedicated to the server side of Ubuntu.

Seth

P.S. I do not have a 100% cure for this static ip issue yet but my page is up and running w/ "Port Forward" on my router as of now. I actually tried to change out my .yaml file, the file I described earlier in /etc/netplan/, w/out satisfaction. Look to netplan(5) for starter info. and a good set of conclusions on the daemon. Also, w/ this being a resort, you can get a third party like no-ip to host your static ip for you if this is too large of an issue.

...

So,

For Static IP Addresses: Use your favorite editor w/ the file /etc/netplan/50-cloud-init.yaml or use a third party like no-ip.com.

For setting up your DNS: Use bind9, e.g. sudo apt install bind9. You have to uncomment your file at /etc/bind/named.conf.options and set your IP:

   forwarders { 
  8.8.8.8; 
  8.8.4.4; 
};

I have been reading out of Lacroix's book, "Mastering Ubuntu Server." It is dedicated to the new release of Ubuntu Server during specific sections.

Anyway...the above code should not be commented and it, as is, is directed at google's DNS servers. You can point them to your ISP's DNS servers too.

Now...restart the bind service w/ sudo systemctl restart bind9.

Let me know if this is clear or too muddy. I will try to make sense out of your situation more as time persists. Please let me know if this supports you cause.

Oh! Are you using a router and access point for your server or just a router?

To make a gateway w/ an access point and router, use this command:

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

I got that command from the book, too.

Now, to make that command work after reboots, go to the file, /etc/sysctl.conf, to change things. Use this change.

#net.ipv4.ip_forward=1

to:

net.ipv4.ip_forward=1

Just uncomment out the hash mark.

This should stop the reboot from cancelling out your server w/ Ubuntu Server.

De Funct
  • 131
0
  • I'm assuming that eth0 is your WAN connection

  • I'm not bonding 3 interfaces in my .yaml

  • let eth0 pick up any IP address via dhcp4 for right now

  • we can set a router reserved address for eth0 later...

    • sudo lshw -C network or ifconfig or ip addr# identify proper MAC for eth0
    • set router reserved dhcp using that MAC, and the desired IP
  • some tweaking will be required along the way

sudo netplan --debug generate # generate config files

sudo netplan apply # apply new configuration

reboot # and verify proper operation


network:
  version: 2
    renderer: networkd
    ethernets:
      eth0:
        dhcp4: true
        optional: true
      eth1:
        dhcp4: false
        optional: true
      eth3:
        dhcp4: false
        optional: true
      eth4:
        dhcp4: false
        optional: true
    bonds:
      bond0:
        interfaces: [eth1,eth3,eth4]
        addresses: [192.168.0.100/24]
        #gateway4: 192.168.0.1 # not used with routes
        routes:
          - to: 0.0.0.0/0
            via: 192.168.0.1
            metric: 100
        nameservers:
          search: [local]
          addresses: [208.67.222.222,208.67.220.220]
        parameters:
          mode: balance-alb
          mii-monitor-interval: 1
          gratuitious-arp: 5
heynnema
  • 70,711