Configuring Linux static IP: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 63: | Line 63: | ||
IPV6_FAILURE_FATAL=no | IPV6_FAILURE_FATAL=no | ||
Ubuntu Server | Ubuntu Server | ||
file on /etc/netplan | |||
network: | network: | ||
version: 2 | version: 2 | ||
ethernets: | ethernets: | ||
<network interface>: | |||
dhcp4: no | dhcp4: no | ||
addresses: | addresses: | ||
- ip/mask | - <ip>/<mask> | ||
gateway4: gateway | gateway4: <gateway> | ||
nameservers: | nameservers: | ||
addresses: | addresses: | ||
- nameserver1 | - <nameserver1> | ||
- nameserver2 | - <nameserver2> | ||
(e.g.) | (e.g.) | ||
network: | network: |
Latest revision as of 15:32, 31 October 2024
How to configure static IP on Linux distros
I'll not cover gui network managers, only file stuff.
Debian
File : /etc/network/interfaces
Configuration:
auto NETWORK-INTERFACE iface NETWORK-INTERFACE inet static address xxx.xxx.xxx.xxx gatway xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx
Let's suppose that you want to configure the interface ens18 with the ip 192.168.0.100 netmask 255.255.255.0 and gateway 192.168.0.1:
auto ens18 iface ens18 inet static address 192.168.0.100 gatway 255.255.255.0 netmask 192.168.0.1
Oracle Linux
file : /etc/sysconfig/network-scripts/ifcfg-interface-name
NAME=interface-name DEVICE=interface-name ONBOOT=yes NETBOOT=yes UUID=auto-filled IPV6INIT=yes TYPE=Ethernet BOOTPROTO=none IPADDR=xxx.xxx.xxx.xxx NETMASK=xxx.xxx.xxx.xxx GATEWAY=xxx.xxx.xxx.xxx PROXY_METHOD=none BROWSER_ONLY=no PREFIX=24 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no
Let's suppose that you want to configure the interface eth0 with the ip 192.168.0.100 netmask 255.255.255.0 and gateway 192.168.0.1:
file : /etc/sysconfig/network-scripts/ifcfg-eth0
NAME=eth0 DEVICE=eth0 ONBOOT=yes NETBOOT=yes UUID=auto-filled IPV6INIT=yes TYPE=Ethernet BOOTPROTO=none IPADDR=192.168.0.100 NETMASK=255.255.255.0 GATEWAY=192.168.0.1 PROXY_METHOD=none BROWSER_ONLY=no PREFIX=24 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no
Ubuntu Server
file on /etc/netplan
network: version: 2 ethernets: <network interface>: dhcp4: no addresses: - <ip>/<mask> gateway4: <gateway> nameservers: addresses: - <nameserver1> - <nameserver2>
(e.g.)
network: version: 2 ethernets: enp3s0: dhcp4: no addresses: - 192.168.0.2/24 gateway4: 192.168.0.1 nameservers: addresses: - 1.1.1.1 - 2.2.2.2