linux_wiki:configure_networking_and_hostname_resolution_statically_or_dynamically

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:configure_networking_and_hostname_resolution_statically_or_dynamically [2018/03/18 15:59]
billdozor [CLI Tool: nmcli]
linux_wiki:configure_networking_and_hostname_resolution_statically_or_dynamically [2019/05/25 23:50] (current)
Line 96: Line 96:
 </code> </code>
   * The above produces the following config:   * The above produces the following config:
-    * /etc/sysconfig/network-scripts/ifcfg-mycon-static<code bash>TYPE=Ethernet +    * /etc/sysconfig/network-scripts/ifcfg-mycon-static<code bash>TYPE=Ethernet    # from: 'type ethernet' 
-BOOTPROTO=none +BOOTPROTO=none    # from: 'ipv4.method manual' 
-IPADDR=10.0.0.5 +IPADDR=10.0.0.5    # from: 'ip4 10.0.0.5/24' 
-PREFIX=24 +PREFIX=24    # from: 'ipv 10.0.0.5/24' 
-GATEWAY=10.0.0.254+GATEWAY=10.0.0.254    # from: 'gw4 10.0.0.254'
 DEFROUTE=yes DEFROUTE=yes
 IPV4_FAILURE_FATAL=no IPV4_FAILURE_FATAL=no
Line 109: Line 109:
 IPV6_PEERROUTES=yes IPV6_PEERROUTES=yes
 IPV6_FAILURE_FATAL=no IPV6_FAILURE_FATAL=no
-NAME=mycon-static+NAME=mycon-static    # from: 'con-name "mycon-static"'
 UUID=f7e0c9af-715d-43da-9576-e6ce218d0c28 UUID=f7e0c9af-715d-43da-9576-e6ce218d0c28
-DEVICE=eth1 +DEVICE=eth1    # from: 'ifname eth1' 
-ONBOOT=yes</code>+ONBOOT=yes    # from: 'autoconnect yes'</code>
  
 \\ \\
Line 131: Line 131:
 <code bash> <code bash>
 nmcli con mod eth0 ipv4.addresses 192.168.1.50/24 nmcli con mod eth0 ipv4.addresses 192.168.1.50/24
-nmcli con mod etho ipv4.gateway 192.168.1.254+nmcli con mod eth0 ipv4.gateway 192.168.1.254 
 +nmcli con mod eth0 ipv4.method manual
 nmcli con up eth0 nmcli con up eth0
 </code> </code>
 +  * Changes do not take place until "nmcli con up eth0"
  
 ---- ----
Line 145: Line 147:
  
 \\ \\
-Set temporary(transient) hostname+Set **temporary**(transient) hostname
 <code bash> <code bash>
 hostname myserver.domain.com hostname myserver.domain.com
Line 161: Line 163:
  
 \\ \\
-Set persistent(static) hostname+Set **persistent**(static) hostname
 <code bash> <code bash>
 hostnamectl set-hostname myserver.com hostnamectl set-hostname myserver.com
Line 167: Line 169:
  
 \\ \\
-Order of name resolution+Order of name resolution (hosts entry)
 <code bash> <code bash>
 /etc/nsswitch.conf /etc/nsswitch.conf
 +
 +#....other entries above
 +
 +# hosts: search local files and then DNS
 +hosts:      files dns
 +
 +#....other entries below
 </code> </code>
  
Line 187: Line 196:
 /etc/hosts /etc/hosts
  
-10.1.1.2  myserver.com+# IP      Hostname                Aliases 
 +10.1.1.2  myserver01.example.com  website.domain.com
 </code> </code>
  
 \\ \\
-Add DNS for eth0 with nmcli or with config file +**Add DNS** (not replace) for eth0 with nmcli or with config file 
-<code bash>+  * nmcli method<code bash>
 nmcli con show nmcli con show
 (observe NAME field) (observe NAME field)
-nmcli con mod "System eth0" +ipv4.dns 8.8.8.8 +nmcli con mod "System eth0" +ipv4.dns 8.8.8.8</code> 
-</code> +  * Edit files directly method<code bash>
-OR +
-<code bash>+
 vim /etc/sysconfig/network-scripts/ifcfg-eth0 vim /etc/sysconfig/network-scripts/ifcfg-eth0
  
-DNS1=8.8.8.8 +DNS1=8.8.8.8</code> 
-</code> +  * Apply changes: Issue nmcli command or restart NetworkManager 
-  * Both methods require the NetworkManager service to be restarted for changes to take effect. (systemctl restart NetworkManager)+    * nmcli method<code bash>nmcli con up eth0</code> 
 +    * Service restart<code bash>systemctl restart NetworkManager</code>
  
 ---- ----
  
  • linux_wiki/configure_networking_and_hostname_resolution_statically_or_dynamically.1521403147.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)