0

I have been working on this problem for 3 days now. FYI I have read all posts on this subject with no results. Always the same problem.

I am building an 18.04 LTS server with the Unity desktop as a media server, a new install. I'm trying to set a static IP for my media server. Never had a problem with 'INTERFACES'. However working with NETPLAN and YAML (50-cloud-init.yaml) is difficult. Always get the same repeating errors with the config, YAML file, for NETPLAN. Error most of the time returns indentation errors and what seems to be other parsing. I have written and re-written the file dozens of times. Triple checked indentation for too many spaces, not enough spaces, extra spaces spacing wrong. I get part of it worked out and then get a new or repeating error. Copied many so called working examples, pasted them in and replaced my data properly; still get those errors. Even checked the file in several YAML validators and it says the file is OK.

Tried to switch back to INTERFACES and IFUPDOWN but now I get systemd errors. Was able to switch back to NETPLAN but with DHCP. By no means an expert in linux and would appreciate any help in plain English with clear examples.

Please note I am disabled and have severe dyslexia and have worked through each iteration very carefully to make sure it correct.

Default 50-cloud-init.yaml -comments not included

network:
    ethernets:
        enp3s0:
            dhcp4: true
    version: 2

Desired config of 50-cloud-init.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      dhcpv4: no
      dhcpv6: no
    addresses:.192.168.10.1/24
      gateway4: 192.168.10.10
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]

/etc/network$ cat interfaces file. 
ifupdown is installed but nt in use at this time.


# 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

Generated errors. I recreated the file from scratch. 
All using double spaces. 

/etc/network$ sudo netplan --debug generate

DEBUG:command generate: running ['/lib/netplan/generate']
** (generate:27358): DEBUG: 10:35:10.506: Processing input file /etc/netplan/50-cloud-init.yaml..
/etc/netplan/50-cloud-init.yaml:15:18: Invalid YAML: inconsistent indentation:
      nameservers:

user@server:/etc/network$ sudo lshw -C network

  *-network DISABLED        
       description: Wireless interface
       product: AR9485 Wireless Network Adapter
       vendor: Qualcomm Atheros
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: wlp2s0
       version: 01
       serial: e0:06:e6:25:8a:23
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list rom ethernet physical wireless
       configuration: broadcast=yes driver=ath9k driverversion=4.15.0-91-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11
       resources: irq:16 memory:f7100000-f717ffff memory:f7180000-f718ffff
  *-network
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: enp3s0
       version: 07
       serial: 5c:f9:dd:6c:fa:90
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8168e-3_0.0.4 03/27/12 ip=192.168.10.10 latency=0 link=yes multicast=yes port=MII speed=1Gbit/s
       resources: irq:19 ioport:d000(size=256) memory:f2104000-f2104fff memory:f2100000-f2103fff
heynnema
  • 70,711
  • 1
    Please edit your question and show me 1) your .yaml file(s), 2) your /etc/network/interfaces file, 3) the output of sudo netplan --debug generate command, 4) sudo lshw -C network. Use copy/paste, not screenshots. Once you paste the text, select the pasted text, and then click the {} icon to format it. Start comments to me with @heynnema or I may miss them. – heynnema Mar 26 '20 at 02:41
  • I used this as a reference to eliminate netplan. It worked fine. – Doug Smythies Mar 26 '20 at 14:06
  • @heynnema ope I did this correctly\ – Stephen Salkin Mar 26 '20 at 17:51
  • Please see my answer. If it's helpful, please remember to return here and accept it by clicking the checkmark icon that appears just to the left of my answer. Thanks! – heynnema Mar 26 '20 at 18:09
  • @DougSmythies Recommending netplan removal, and ifupdown installation, via that link is not the right suggestion. People just need to learn some basic netplan... and yes... it can be a pain... but it's the future... for servers at least.. – heynnema Mar 26 '20 at 18:40
  • @heynnema : Are other distros switching to using netplan? I only know of canonical using it, and I want to use the same tools on multiple (debian based) distributions. – Doug Smythies Mar 26 '20 at 20:53
  • @DougSmythies I don't know. I just disagree with heavily modifying an OS by removing major pieces of it. How do we support that? – heynnema Mar 26 '20 at 21:04
  • @StephenSalkin Status please... – heynnema Mar 26 '20 at 21:06
  • @StephenSalkin Status please... – heynnema Mar 27 '20 at 18:21
  • @StephenSalkin Status please... – heynnema Apr 05 '20 at 13:21

2 Answers2

0

Your .yaml file is incorrect. Try this one... make sure to keep the spacing, indentation, and no tabs...

Note: I also reversed your IP addresses, as I think you had them backwards. Check them out.

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      addresses: [192.168.10.10/24]
      gateway4: 192.168.10.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

sudo netplan --debug generate # generate config files

sudo netplan apply # apply new plan

reboot # reboot computer

Note: see https://netplan.io/examples for more info

heynnema
  • 70,711
0

After ubuntu came with versions 18.04 and 20.04, it is netplan that applies to get a random IP address. I have tried a number of copies on how to do this, but only one method worked for me. Do not understand that there must be so many different methods here. What worked just fine for me is the following: network:

ethernets:
    enp0s25:
        addresses:
        - 192.168.1.19/24
        gateway4: 192.168.1.2
        nameservers:
            addresses:
            - 8.8.8.8
            - 8.8.4.4

Do not use a tab for the indentations, use space. The IP address and network name must be edited for your use.

Tejas Lotlikar
  • 2,945
  • 5
  • 17
  • 26