Configuring Linux static IP: Difference between revisions
Created page with "== 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 in..." |
No edit summary |
||
Line 62: | Line 62: | ||
IPV6_DEFROUTE=yes | IPV6_DEFROUTE=yes | ||
IPV6_FAILURE_FATAL=no | IPV6_FAILURE_FATAL=no | ||
Ubuntu Server | |||
network: | |||
version: 2 | |||
ethernets: | |||
enp3s0: | |||
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 |
Revision as of 21:31, 18 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
network: version: 2 ethernets: enp3s0: 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