跳到主要内容

Changing your IP address

在 Firewalls and Networking 中
作者列表
已发布: 2022年5月12日|最后更新: 2024年9月26日

The following guide covers how to manually change your IP address on Ubuntu 20.04 LTS or Ubuntu 22.04 LTS. These distros use netplan for network management, so the guide will explain how to modify the IP configuration through that.

Note

As the OVA and Windows versions of the OPC use an Ubuntu 20.04 LTS virtual machine, these instructions should work for most use cases.

Changing your IP address Copy link to Changing your IP address to clipboard

Login to your OPC server via SSH, and cd /etc/netplan

Within this directory (ls), you should be able to see one of two files:

  • 00-installer-config.yaml

  • 50-cloud-init.yaml

This file is what you will need to modify with your new network configuration.

If you open the file with a text editor (i.e. vi or nano), it should look similar to this:

# This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens160: dhcp4: true match: macaddress: 00:0c:29:f0:92:c3 set-name: ens160 version: 2
copy

In this example, the NIC ens160 is configured for DHCP on IPv4, and it is set to match the mac address of the NIC. We want to disable that DHCP configuration, and specify a static IP in its place.

To set a static IP, you need to modify the file to include the IP configuration

# This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens160: dhcp4: false addresses: [{IP in CIDR notation}] gateway4: {Gateway IP} nameservers: addresses: [{DNS servers in comma separated list}] match: macaddress: 00:0c:29:f0:92:c3 set-name: ens160 version: 2
copy

If you are not sure of the CIDR notation for your IP address, you can find it by comparing the subnet mask against the CIDR.

Some of the more common subnet sizes are in the table below:

CIDR

Subnet Mask

/32

255.255.255.255

/31

255.255.255.254

/30

255.255.255.252

/29

255.255.255.248

/28

255.255.255.240

/27

255.255.255.224

/26

255.255.255.192

/25

255.255.255.128

/24

255.255.255.0

As an example, this is what it should look like once completed:

# This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens160: dhcp4: false addresses: [192.168.1.100/24] gateway4: 192.168.1.1 nameservers: addresses: [1.1.1.1, 1.0.0.1] match: macaddress: 00:0c:29:f0:92:c3 set-name: ens160 version: 2
copy
Warning


YAML files are very specific in the spacing, and each level below should be indented by an additional 2 spaces.

i.e. As ethernets: is contained within network:, there are 2 spaces before to indicate it is inside that section, and as ens160: is contained within the ethernets: section, there are an additional 2 spaces before, making 4 spaces in front of the parameter.

Do not use tabs in this file, as it will cause errors.

If you are modifying the 50-cloud-init.yaml file, this configuration file will be reset on reboot unless cloud-init is disabled. To do that, create a file called /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg containing the following line:

network: {config: disabled}
copy

Once you have modified the file, apply the changes with sudo netplan apply, and to confirm, run the command ip addr to list the configured IP addresses on the server.

Configuring the OPC Copy link to Configuring the OPC to clipboard

After changing your IP address, you will need to inform the OPC that the IP address has changed. You can do so with the following command:

sudo opc config set --host-address '{ip_address]'
copy

If you allow access to your Deskpro instance via the IP address, you will also need to switch that on for the new IP. Log in to the OPC via the web interface, then select your instance, and under Access via IP Address, enable access for your new IP.

Final Steps Copy link to Final Steps to clipboard

If you have been using a hostname or a proxy to access your instance, you may need to configure your DNS to use the new IP address, or configure your proxy to direct traffic to your new IP address.

If you are not using a domain and accessing the instance using an IP, navigate to Admin > Configuration > Branding, select the relevant brand, and review the settings in the right-hand panel to ensure that the configured domain reflects the new IP address.

By following these steps, you can ensure seamless access to your Deskpro instance after changing your IP address.

有帮助没有帮助

5 人中 3 人认为这个页面有帮助

下一个页面Limiting the OPC and instances to specific IPs

请登录或注册以提交评论。