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

  • python mysql install error: /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found mysql_config --version
  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 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