Linux – How to set a static IP address for a disconnected interface

command linelinuxnetwork-interfacenetworkingtcp/ip

I am setting up an Arch/Manjaro-based machine that only occasionally will be connected to network. I.e. most of the time its Ethernet card is disconnected.

I run into this curious problem – when I try to use networking commands the interface is down (I sit next to it with my laptop that has a Wi-Fi Internet connection). So I am not sure if it is working properly.

  • How do I set up the network without an Ethernet connection present so that when I finally plug in a cable I can be sure that the address will be 192.168.1.1?

I found the answer: use SkipNoCarrier=yes in the netctl profile. It is in Manjaro StaticIP wiki and in Arch netctl page.

Best Answer

Like this for example:

For a static IP configuration copy the /etc/netctl/examples/ethernet-static example profile to /etc/netctl and modify Interface, Address, Gateway and DNS) as needed.

For example:

/etc/netctl/my_static_profile

Interface=enp1s0
Connection=ethernet
IP=static
Address=('10.1.10.2/24')
Gateway=('10.1.10.1')
DNS=('10.1.10.1')

Link to the official Arch Wiki here.

This of course only works if you don't use Network Manager or something similar to control your network.

Related Question