@bobnoordam

Determine or change your configured ip, determine your external ip

In the series, ‘spare me the lecture, just tell me how it works’, here is a bunch of quick reminders about your ip configuration on your Ubuntu linux box.

ifoncig.me is a handy website that will show you all kinds of information in your web browser, such as your public facing ip, hostname and other goodies about your connection. take a look

From the command line this can be used too, and will response without the clutter you may see in a browser. To do this, just use:

curl ifconfig.me

which will respond with the ip you are using for your internet connection.

Next, to show your local configuration, use

ifconfig

If your system uses netplan, and you want to set a static ip address, move into the directory /etc/netplan, which should contain teh file to configure your ethernet card. The file may be named different, but that doesn matter.

:/etc/netplan# ls
50-cloud-init.yaml

Edit the file to switch between options. Configuration for dhcp:

network:
    ethernets:
        eth0:
            addresses: []
            dhcp4: true
    version: 2

Configuration for using a static ip address

network:
    ethernets:
        eth0:
            addresses:
            - 10.25.9.11/22
            dhcp4: false
            gateway4: 10.25.9.25
            nameservers:
                addresses:
                - 10.25.9.12
                - 10.25.9.13
    version: 2

Sample netmasks

/24255.255.255.0
/25255.255.255.128
/26255.255.255.192
/27255.255.255.224
/28255.255.255.240
/29255.255.255.248
/30255.255.255.252

See also: https://netplan.io/examples