LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to set a static IP using netplan? (running Ubuntu Bionic server) (https://www.linuxquestions.org/questions/linux-networking-3/how-to-set-a-static-ip-using-netplan-running-ubuntu-bionic-server-4175650146/)

mrjayviper 03-14-2019 02:14 AM

How to set a static IP using netplan? (running Ubuntu Bionic server)
 
I've followed/looked at several guides (like this one) on how to do the above.

My problem is that no static IP is getting assigned to the built-in ethernet port. I have run
Code:

netplan apply
several times. I've also rebooted the PC and still no luck.

I am sure the ethernet port works as I was previously using it on Ubuntu 16.04 just before I decided to fresh install 18.04.2.

Any ideas what I could be doing wrong? I am going to use the ethernet port to connect my main PC to the Ubuntu server via a crossover cable.

If I set the ethernet port to use
Code:

dchp4:true
and connect an ethernet cable from it to my modem/router and disable my WiFi card (by removing the netplan config), the PC can connect to the net without any issues.

Thanks

---------------------------

This is the output of
Code:

netplan --debug apply
which also shows the contents of my YAML files. I have tried with and without dhcp4/dchp6/gateway4/renderer.

screenshot of netplan --debug: https://i.imgur.com/lBIFoa1.jpg

krishan25 03-17-2019 07:18 AM

Static IP address using netplan
 
To configure Static IP address on your Ubuntu Bionic Server, you have to follow these steps:
1. Go to /etc/netplan/ directory in your server.
2. Now, you have to open a file called “01-netcfg.yaml” or “50-cloud-init.taml”. In this you have to Configure the following things:
• addresses: Here, you have to enter static IP address here for example (192.168.1.50/24)
• Gateway4: Here, you have to enter default gateway IP address for example (192.168.1.1)
• Nameserver: You have to add DNS entry for example (8.8.8.8, 8.8.4.4)
• Dhcp4: no
3. Now, you have to run “sudo netplan apply” command.
4. If there is an issue, you can run “sudo netplan –debug apply” command.

jmgibson1981 03-19-2019 07:46 PM

My netplan config for reference. Spacing is very important. Do not use tabs. This is configured to use itself for dns.

Code:

network:
 renderer: networkd
 version: 2
 ethernets:
  enp2s0:
  dhcp4: false
  dhcp6: false
  addresses: [192.168.1.2/24]
  gateway4: 192.168.1.1
  nameservers:
    addresses: [192.168.1.2]

A bridge would be similar.

Code:

network:
 renderer: networkd
 version: 2
 ethernets:
  enp2s0:
  dhcp4: false
  dhcp6: false
 bridges:
  br0:
  interfaces: [enp2s0]
  dhcp4: false
  dhcp6: false
  addresses: [192.168.1.2/24]
  gateway4: 192.168.1.1
  nameservers:
    addresses: [192.168.1.2]

No point having the bonds, bridges, vlans tags if you aren't using them. They just are more potential problems that you need to isolate as not being the issue.

patrickjburt 03-21-2019 04:59 AM

Good info to know here!!!

patrickjburt 03-21-2019 05:04 AM

Good info to know here!!!


All times are GMT -5. The time now is 04:03 PM.