Howto Set Static IP on boot in initramfs for dropbear or other purposes NFS, Linux, Debian, Ubuntu, CentOS

This is only really necessary in the case you don't want DHCP.  If you are dealing with an encrypted LUKS server on the internet, you will often want to have a static IP so you know which IP to connect to (or if you have a semi-static IP assigned by DHCP).

SET IP Address by /etc/initramfs-tools/initramfs.conf

IP Address=192.168.1.27
Gateway=192.168.1.1
Subnet Mask: 255.255.255.0
Hostname=myhome.com

IP=192.168.1.27::192.168.1.1:255.255.255.0:myhost.com

The format is below, note the "double colon" :: after the IP.  If you don't do that, things won't work properly including being unable to set the gateway and/or hostname errors.
**Double note that the kernel documentation states otherwise that a single color is to be used for all field separation, but at least in most newer Debian's this does not work.

Set IP for certain NIC

You could also add another ":" after hostname which would indicate which NIC device the IP would be applied to.  Otherwise by default it is the first NIC.

#eg if you wanted to have it use ens3 then change the line by adding another colon and the device eg. :ens3
IP=192.168.1.27::192.168.1.1:255.255.255.0:myhost.com:ens3

Follow this guide if you want your NICs named properly (eg. eth0, eth1) so you don't have to wonder whether you have an eno1, ens3 etc.

Final Step

Make sure you update initramfs or this will not be applied or work until you do.

sudo update-initramfs -u


Tags:

howto, static, ip, initramfs, dropbear, purposes, nfs, linux, debian, ubuntu, centosthis, dhcp, encrypted, luks, server, semi, assigned, etc, conf, gateway, subnet, hostname, myhome, myhost, format, quot, colon, unable, errors, kernel, documentation, separation, newer, nic, indicate, applied, default, eg, ens, adding, update, sudo,

Latest Articles

  • systemd-journald high memory usage solution
  • How to Install FreePBX in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide
  • Abusive IP ranges blacklist
  • How to Install Any OS on a Physical Drive from Windows Using VMware Workstation (Linux, Windows, BSD)
  • CDN Cloudflare how to set and preserve the real IP of the client without modifying application code on Apache
  • CentOS 7 fix Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was 14: curl#6 -
  • Ubuntu Debian How To Install Recommended Packages Automatically
  • How to set Linux Ubuntu Redhat Debian Command Line http https socks proxy for yum apt
  • How to resize a pdf without losing much quality in Linux Mint Ubuntu Debian Redhat Solution
  • qemu: could not load PC BIOS 'bios-256k.bin' solution