Advertisement: Linux VPS for $4/month - based on OpenVZ, credit card accepted, automatic setup.
+ Post New Thread
Results 1 to 2 of 2

Thread: How to set static IP on Linux with NetworkManager (most of the Linux distributions?)

  1. #1
    Fli is offline
    Administrator Fli's Avatar
    Join Date
    Mar 2013

    How to set static IP on Linux with NetworkManager (most of the Linux distributions?)

    This is any attempt:

    in router configuration, DHCP LAN client list, you may be able to make it remember current IP so it always use it (until you reset the router).

    right click the network conenction icon in the Linux menu bar (NetworkManager), Edit connections, Edit your main conenction, go to IPv4 tab, switch from DHCP to manual and set your desired LAN IP (if router is, then maybe mask is 24, gateway is router IP, DNS is router IP and then after coma add maybe (cloudflare's open dns IP). Disable/enable this connection in NetworkManager (NM).

    1. If you do not know your router address and you are connected to it, IP can be listed by "ip r|grep default"
    2. Open current main network interface NetworkManager configuration file located in: /etc/NetworkManager/system-connections/:
    Following may work to do it:
    nic=$(ip -o -4 route show to default|head -n1|awk '{print $5}') && sudo nano /etc/NetworkManager/system-connections/"$nic".nmconnection||sudo vi /etc/NetworkManager/system-connections/"$nic".nmconnection
    3. in [ipv4] section replace that section lines, mybe just 1 line: "method=auto" by something like following (using your LAN 192.168.x.x IPs):
    4. run:
    nmcli network off;nmcli network on;nmcli;echo -e "\nWaiting 10 seconds for the network interface to come up to ping to internet";sleep 10;ping -c 2 -w 2
    if using VPN, restart it after done

  2. #2
    Junior Member johncena's Avatar
    Join Date
    Oct 2021

    Is this useful / helpfull? Yes | No
    Thanks for sharing this information..very useful content

+ Post New Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
 Protected by : ZB BLOCK  &  StopForumSpam