User Tools

Site Tools


networking:linux:static_ip_addr

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
Last revision Both sides next revision
networking:linux:static_ip_addr [2020/12/17 14:04]
gcooper
networking:linux:static_ip_addr [2023/03/02 11:20]
gcooper
Line 3: Line 3:
 See also **[[https://www.techwizcr.com/remove-netplan-on-ubuntu-18-04/linux/|Remove Netplan]]** See also **[[https://www.techwizcr.com/remove-netplan-on-ubuntu-18-04/linux/|Remove Netplan]]**
  
-===== Ubuntu 18.04 =====+===== NetworkManager =====
  
-:!: Indenting is very important!+<file> 
 +nmcli con show 
 +</file> 
 + 
 +<file> 
 +nmcli con mod "Wired connection 1" ipv4.method manual \ 
 +  ipv4.addr 192.168.100.3/24 \ 
 +  ipv4.gateway 192.168.100.1 \ 
 +  ipv4.dns 192.168.100.1,8.8.8.8,8.8.4.4 \ 
 +  connection.id "Office LAN" 
 + 
 +nmcli con up "Office LAN" 
 +</file>
  
-:!: We use 'netplan' and 'networkd' for network configuration.+===== Netplan =====
  
-:!: YAML files can be named differently.+https://netplan.io/examples/
  
 https://blog.ubuntu.com/2017/07/05/quick-and-easy-network-configuration-with-netplan https://blog.ubuntu.com/2017/07/05/quick-and-easy-network-configuration-with-netplan
  
 https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
 +
 +:!: **Indentation** is very important!
 +
 +:!: We use ''netplan'' and ''networkd'' for network configuration.
 +
 +:!: YAML files can be **renamed**.
  
   * bonds   * bonds
Line 21: Line 39:
   * static addresses   * static addresses
   * DHCP addresses   * DHCP addresses
 +
 +==== Regenerate and Reapply After Editing ====
  
 <file> <file>
-sudo vi /etc/netplan/50-cloud-init.yaml+sudo netplan --debug generate 
 +sudo netplan --debug apply
 </file> </file>
  
-Example:+==== Ubuntu 18/20/22 (LACP Bond) ====
  
 <file> <file>
 network: network:
-    ethernets: +  version: 2 
-        eth0+  ethernets: 
-            addresses: [10.1.1.17/24] +    enp0s8
-            gateway4: 10.1.1.1 +      dhcp4: no 
-            nameservers: +    enp0s9: 
-              addresses: [10.1.1.20,10.1.1.21] +      dhcp4: no 
-        eth1+  bonds: 
-            addresses[10.1.9.17/24] +    bond0: 
-            mtu9000 +      interfaces: [enp0s8, enp0s9] 
-    version2+      addresses: [10.1.1.19/24] 
 +      routes: 
 +        - to: default 
 +          via: 10.1.1.1 
 +      nameservers: 
 +        search: [internal.domain, domain] 
 +        addresses: [10.1.1.20, 10.1.1.21] 
 +      parameters
 +        mode802.3ad 
 +        transmit-hash-policylayer3+4 
 +        mii-monitor-interval1
 </file> </file>
 +
 +==== Ubuntu 18/20/22 (Static) ====
  
 <file> <file>
-sudo netplan --debug generate +sudo vi /etc/netplan/50-cloud-init.yaml 
-sudo netplan apply+</file>
  
-sudo netplan --debug apply+<note tip>To suppress (or define) the default IPv6 ''link-local'' address (''fe80::''), add this to the interface definition (same indentation as ''addresses:''): 
 + 
 +''link-local: []'' 
 +</note> 
 + 
 +Example: 
 + 
 +<file> 
 +network: 
 +  ethernets: 
 +    eth0: 
 +      addresses: [10.1.1.17/24] 
 +      routes: 
 +        - to: 0.0.0.0/0 
 +          via: 10.0.0.1 
 +      nameservers: 
 +        addresses: [10.1.1.20,10.1.1.21] 
 +    eth1: 
 +      addresses: [10.1.9.17/24] 
 +        mtu: 9000 
 +version: 2
 </file> </file>
  
-If you have trouble, try removing these files, then regenerate and reapply:+==== Troubleshooting ==== 
 + 
 +If you have trouble with netplan, try removing these files, then regenerate and reapply:
  
   * Extra addresses   * Extra addresses
Line 84: Line 139:
  
 ===== Hostname ===== ===== Hostname =====
 +
 +<file>
 +hostname short-hostname
 +hostnamectl set-hostname fqdn-host-name
 +</file>
  
 <file> <file>
Line 89: Line 149:
  
 192.168.1.30   hostname.example.com     hostname 192.168.1.30   hostname.example.com     hostname
 +</file>
  
-sudo sh -c "echo new-hostname > /etc/hostname" +<file> 
- +echo new-hostname > /etc/hostname 
-sudo hostnamectl set-hostname new-hostname+</file>
  
 +<file>
 hostname hostname
 hostname -f hostname -f
Line 211: Line 273:
  
 ===== Name Resolution ===== ===== Name Resolution =====
 +
 +<file>
 +systemd-resolve --status
 +</file>
  
 https://www.shellhacks.com/setup-dns-resolution-resolvconf-example/ https://www.shellhacks.com/setup-dns-resolution-resolvconf-example/
Line 248: Line 314:
 reboot reboot
 </file> </file>
 +
 +===== Grub Boot Delay =====
 +
 +<file>
 +sed -i -e 's/GRUB_TIMEOUT=0/GRUB_TIMEOUT=5/g' /etc/default/grub
 +update-grub
 +</file>
 +
networking/linux/static_ip_addr.txt · Last modified: 2023/05/02 14:34 by gcooper