Announcement

Collapse
No announcement yet.

How to: Static IP (for home router)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [CONFIGURATION] How to: Static IP (for home router)

    I have two laptops that I want to be able to ssh back and forth from on my home router. It really helps to have a predictable (static) IP address on the LAN for this. So I figured it out. And here's my notes on how I done it. I'm running Kubuntu 22.04 but I think it will be very similar if not the exact same on other versions in the same general release time frame.


    Setting up a static IP in Kubuntu 22.04 (and probably others too)

    Useful URLs

    Check which ports are open:
    https://www.cyberciti.biz/faq/unix-l...n-use-command/


    Many commands and how to use
    https://www.cyberciti.biz/faq/unix-l...in-use-command


    Control UFW by CLI
    https://www.cyberciti.biz/faq/how-to...ntu-20-04-lts/


    Using Network Manager CLI to set up static IP
    https://linux.fernandocejas.com/docs...tic-ip-address


    What you will need
    • The UUID of the LAN connection on your computer
    • Your IP on the LAN
    • The subnet on the LAN
    • The Gateway address of the LAN
    • DNS server address for the LAN

    get the UUID
    Code:
    $ nmcli connection show
    or
    Code:
    $ nmcli con show
    - console output -
    NAME UUID TYPE DEVICE
    Home-wifi egd6cdd8-8ewd-8bf8-a0fd-cjkhkiu34f1e wifi wlp3s0
    Starbucks WiFi 24181ab4-6f1d-446b-a350-f6b123xyzu94 wifi --
    Wired connection 1 b92e3a8a-d798-3bff-ae0d-9f1abc123ea4 ethernet --


    To get your IP
    Code:
    $ hostname -I
    ( upercase i )


    to get your subnet
    Code:
    $ ifconfig
    Look for your IP, subnet follows, looks like 255.255.255.0
    Count the quantity of 255
    Multiply the quantity by 8
    your subnet is forward slash that number
    in this example:
    3 x 8 = 24
    subnet = /24

    to get the LAN gateway address
    Code:
    $ ip r | grep default
    looks like:
    default via 192.168.62.1 dev wlp4s0 proto dhcp metric 600

    The gateway in this example is: 192.168.62.1

    to get the DNS address for the LAN
    Not sure. try 1.1.1.1

    Code:
    $ resolvectl status
    pulls up the DNS you are using on the www

    Code:
    $ cat /etc/resolv.conf
    shows your computer's dns


    Setting the static IP address
    - Note: the values in this section are all made-up example values and may not work IRL. You have to find your own actual values.


    The basic command syntax is the same for each step, may require sudo

    Code:
    nmcli con modify [UUID] ipv4.[name of thing you want to change] [value you want to set]
    - "con" is short for "connection" - either will work. I show "connection" below to make it easier to read and remember

    In this case I will set a static IP for my home wifi.
    I want a static IP address of 192.168.69.007 (because I'm really a British super-spy)

    set IP address AND /subnet mask
    Code:
    $ nmcli connection modify egd6cdd8-8ewd-8bf8-a0fd-cjkhkiu34f1e ipv4.addresses 192.168.69.007/24

    set Gateway address
    Code:
    $ sudo nmcli connection modify egd6cdd8-8ewd-8bf8-a0fd-cjkhkiu34f1e ipv4.gateway 192.168.1.1
    set DNS
    Code:
    $ sudo nmcli connection modify egd6cdd8-8ewd-8bf8-a0fd-cjkhkiu34f1e ipv4.dns 1.1.1.1
    set Method
    Code:
    $ sudo nmcli connection modify egd6cdd8-8ewd-8bf8-a0fd-cjkhkiu34f1e ipv4.method manual
    - Note: "manual" is the actual value you want for a static ip.

    Activate the connection
    Code:
    $ sudo nmcli connection up [UUID]
    Check your work
    Code:
    $ sudo cat /etc/NetworkManager/system-connections/[network name].nmconnection​


    Last edited by TwoFistedJustice; Jun 19, 2023, 02:38 PM.
Working...
X