Access Web App on Linux Server via Ethernet Cable Without Router

iotnetworkmanagerubuntu 18.04webserver

I have a web app on an Ubuntu 18.04 Linux web server, and I simply want to access it from a web browser on my laptop, which is connected to the server directly via ethernet cable.

How can I use nmcli (network manager) on the Ubuntu server to create a static IP address at which I can access my web app? It's using port 80 and I've allowed TCP on that port via UFW.

Background:
The server is actually an IoT gateway, and the web app is an admin console for setting the cellular modem APN on the gateway. I want to connect the laptop via ethernet directly to the server gateway, type a static IP address into the laptop's browser, and set the cellular APN (ie create a cellular data connection via nmcli) via the convenient web app.

Thanks!!

EDIT: I asked a very similar new question here about doing the same with a network bridge:
Access web app on Linux server from laptop via network bridge, no router

Best Answer

If there is a router in the connection, it (most probably) assigns automatic IP addresses (DHCP function) to the network devices. Hence, when connecting two devices with a cable, you need to make sure that they BOTH have an IP address which belongs to the same network (e.g., 192.168.0.1, 192.168.0.2, subnet 255.255.255.0). To assign those addresses, use the ifconfig as mentioned in @sawdust answer.

Related Question