This document will help you assign a static IP address on CGW machine.
If you want to use static IP address (public or private) on CGW machine which is already up and running, you can follow the steps mentioned here.
Once the static IP and default gateway for WAN interface is configured on admin console, CGW will configure those parameters automatically. No manual commands/steps will be required.
If a machine is deployed with fresh OS installation and you don't have DHCP server available for WAN interface. You can follow below steps to configure static IP and gateway. CGW deployment requires internet access before execution of installation command.
# sudo ip addr add <Static-IP-Address/Netmask> dev <WAN-Interface-Name>
# sudo ip route add default via <Default-GW-IP>
Above steps will configure interface with static IP and allow users to do SSH remotely or connect to internet. It will not make configuration static.
Identify the Network Interface Name: Use the ip addr or ifconfig command to list all network interfaces. Identify the one you want to configure (e.g., eth0, ens33).
# ip addr
# ifconfig
Edit the Netplan Configuration File: Netplan configuration files are typically located in /etc/netplan/. Use ls to locate the YAML file, e.g., 01-netcfg.yaml.
ls /etc/netplan/
Backup: Before making changes, back up the original configuration file:
sudo cp /etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml.bak
Modify the YAML File: Open the Netplan YAML file using a text editor like nano:
sudo nano /etc/netplan/01-netcfg.yaml
Update the file with the static IP configuration. Here's an example configuration:
network:
version: 2
ethernets:
eth0: # Replace "eth0" with your interface name
addresses:
- 192.168.1.100/24 # Replace with your desired static IP and subnet (private or public)
gateway4: 192.168.1.1 # Replace with your gateway IP (private gw or public gw)
nameservers:
addresses:
- 8.8.8.8 # Google DNS or another DNS server
- 8.8.4.4
dhcp4: false
eth1: # Replace "eth0" with your interface name
dhcp4: true # Change it true/false as per your requirement and add configuration accordingly
Apply the Configuration: After saving the file, apply the changes with:
sudo netplan apply
This command activates the new network settings immediately and make it persistent.
Verify the Configuration: Check if the static IP is assigned and the gateway is configured:
# ip addr
# ip route
Ensure the output reflects the static IP and gateway settings you configured.
Test Connectivity: Test network connectivity by pinging an external server, such as Google:
ping -c 4 8.8.8.8
ping -c 4 google.com
File Format: Ensure the YAML file is properly indented, as incorrect indentation can cause errors. YAML is sensitive to spaces.
Troubleshooting: If netplan apply fails, use sudo netplan try to test the configuration interactively.