Score:1

Create network alias in Ubuntu 20.04

jp flag

I have a local application that will try to connect to MySQL on 172.1.0.1 when it's on production but I want to be able to test it locally.

At this time, changing the source code is not an option, so all I need really is for 172.1.0.1 to map to be routed to localhost (127.0.0.1). Something that will persist through reboots but it's easy to revert.

I've seen some solutions using iptables or ifconfig but also Ubuntu 20 uses netplan and I'm afraid I'll mess something up (I'm a noob at this).

Can someone give me some pointers?

Thanks in advance for any help.

Score:1
jp flag

I seem to have found the answer to my question. What I did was edit the default file found in /etc/netplan to look like this:

network:
version: 2
renderer: NetworkManager
ethernets:
    lo:
    renderer: networkd
    match:
        name: lo
    addresses:
        - 172.1.0.1/32

And then restarted the network with:

sudo netplan apply
ca flag
Note that, as well as I understand the configuration of `netplan`, you don't need to edit the _default_ file, but rather add a _new_ one (ending in `.yaml`) just with the above configuration, and call it something alphanumerically after the original file. That way, you won't need to break any original configuration files and this will just add a _new_ loopback interface. Also note that it's always a good idea to test the current configuration with `sudo netplan try`, which will give you 2 minutes to approve the current config or else revert to the previous one (disclaimer: netplan noob here!)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.