linux_wiki:static_ip

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_wiki:static_ip [2014/11/24 22:37]
billdozor
linux_wiki:static_ip [2019/05/25 23:50] (current)
Line 1: Line 1:
 ====== Static IP ====== ====== Static IP ======
  
-**Distro(s):** Debian and Redhat based.+**General Information**
  
-**Description:** Configure static IP, Mask, Gateway, and DNS.+Configure static IP, Mask, Gateway, and DNS.
  
-Assuming eth0 is the network interface to edit;+**Checklist** 
 +  * Distro(s): Debian or Enterprise Linux
  
-__**Debian/Ubuntu Systems**__+---- 
 + 
 +===== Configure Static Network Info ===== 
 + 
 +==== Debian/Ubuntu Systems ====
 if possible, bring interface down first: ifdown eth0. if possible, bring interface down first: ifdown eth0.
  
-1) Edit /etc/network/interfaces +  * Edit /etc/network/interfaces<code bash>vim /etc/network/interfaces</code>
-<code bash> +
-nano /etc/network/interfaces +
-</code>+
  
-2) DHCP Setup Example (Default) +  * DHCP Setup Example (Default)<code bash>auto eth0 
-<code bash> +iface eth0 inet dhcp</code>
-auto eth0 +
-iface eth0 inet dhcp +
-</code>+
  
-3) Static Setup Example +  * Static Setup Example<code bash>auto eth0
-<code bash> +
-auto eth0+
 iface eth0 inet static iface eth0 inet static
   address 192.168.0.100   address 192.168.0.100
   netmask 255.255.255.0   netmask 255.255.255.0
   gateway 192.168.0.254   gateway 192.168.0.254
-  dns-nameservers 8.8.8.8 8.8.4.4 +  dns-nameservers 8.8.8.8 8.8.4.4</code>
-</code>+
  
-4) Bring the interface up (if brought down at the start) +  * Bring the interface up (if brought down at the start)<code bash>ifup eth0</code>
-<code bash> +
-ifup eth0 +
-</code>+
  
-5) Otherwise, restart to fix nameserver conflicts between dhclient and static. +  * Otherwise, restart to fix nameserver conflicts between dhclient and static.<code bash>shutdown -r now</code>
-<code bash> +
-shutdown -r now +
-</code>+
  
-__**Redhat/CentOS Systems**__+----
  
-1) Edit /etc/sysconfig/network-scripts/ifcfg-eth0 +==== Redhat/CentOS Systems ====
-<code bash> +
-vi /etc/sysconfig/network-scripts/ifcfg-eth0 +
-</code>+
  
-2) DHCP Setup Example (Default) +Classic and NetworkManager methods of setting IP addresses for EL distros. 
-<code bash> + 
-DEVICE=eth0+=== Classic (networkMethod === 
 + 
 +Using config files and the network service. 
 + 
 +  * Edit /etc/sysconfig/network-scripts/ifcfg-eth0<code bash>vim /etc/sysconfig/network-scripts/ifcfg-eth0</code> 
 + 
 +  * DHCP Setup Example (Default)<code bash>DEVICE=eth0
 ONBOOT=no (change to yes to have DHCP start automatically) ONBOOT=no (change to yes to have DHCP start automatically)
 NM_CONTROLLED=yes NM_CONTROLLED=yes
-BOOTPROTO=dhcp +BOOTPROTO=dhcp</code>
-</code>+
  
-3) Static Setup Example +  * Static Setup Example<code bash>DEVICE=eth0
-<code bash> +
-DEVICE=eth0+
 ONBOOT=yes ONBOOT=yes
-NM_CONTROLLED=yes+NM_CONTROLLED=no
 BOOTPROTO=static BOOTPROTO=static
 IPADDR=192.168.0.101 IPADDR=192.168.0.101
 NETMASK=255.255.255.0 NETMASK=255.255.255.0
-GATEWAY=192.168.0.254 +GATEWAY=192.168.0.254</code>
-</code>+
  
-4) Edit /etc/resolv.conf +  * Edit /etc/resolv.conf<code bash>vim /etc/resolv.conf
-<code bash> +
-vi /etc/resolv.conf+
  
 nameserver 8.8.8.8 nameserver 8.8.8.8
-nameserver 8.8.4.4 +nameserver 8.8.4.4</code> 
-</code>+ 
 +  * Restart network service<code bash>/etc/init.d/network restart</code> 
 + 
 +=== Network Manager === 
 + 
 +Using the NetworkManager service. 
 + 
 +\\ 
 +Static IP/Gateway 
 +  * Set a static IP on an existing interface (eth0)<code bash>nmcli con mod eth0 autoconnect yes ipv4.method manual ip4 192.168.1.50/24 gw4 192.168.1.254</code> 
 +  * Apply settings<code bash>nmcli con up eth0</code> 
 + 
 +\\ 
 +Static DNS 
 +  * Set a static DNS entry<code bash>nmcli con mod eth0 ipv4.dns 1.1.1.1</code> 
 +  * Apply changes<code bash>nmcli con up eth0</code> 
 + 
 +----
  
-5) Restart network service 
-<code bash> 
-/etc/init.d/network restart 
-</code> 
  • linux_wiki/static_ip.1416886663.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)