Set UP Static IP

Ames Computer Geek Corner News Set UP Static IP NYC New York City North Bergen County
https://www.raspberrypi.org/

A static IP address, or fixed IP address, is an IP address that never changes. Not everyone needs a static IP address. Static IP addresses are necessary for devices that need constant access. For example, a static IP address is necessary if your computer is configured as a server, such as an FTP server or web server. If the server was assigned a dynamic IP address, it would change occasionally, preventing your router from knowing which computer on the network is the server. In this article, we will be using NetworkManager to set up a static IP.

NetworkManager is a system network service that manages your network devices and connections and keep network connectivity active when available. It manages both ethernet and WiFi while also providing VPN integration with a variety of different VPN services. When NetworkManager is installed, it will take control of all networking devices in the system by creating a netplan configuration file in which it sets itself as the network management interface. NetworkManager is composed of two layers, a daemon running as root and a front end ( nmcli )[1]. NMCLI is short for Network Command-Line Interface and used to manage the NetworkManager and also show the status of a network connection when you don't have a GUI interface. To install NetworkManager, update and upgrade the system and then run the following command:


sudo apt-get install network-manager

Once installed, start and enable NetworkManger with the following comand:

sudo systemctl start NetworkManager.service 
sudo systemctl enable NetworkManager.service



Before we can use NetworkManager to set a static ip, we have modify the config file. We need to allow the network to be controlled by Network manager, to do this, we have to edit the config file /etc/NetworkManager/NetworkManager.conf. This must be done as root and can be done in any text editor. In our case, we will be using vim. To edit the file, type in the following: sudo vim /etc/NetworkManager/NetworkManager.conf. Edit the following and then restart NetworkManger:

[ifupdown]
managed=false


To

[ifupdown]
managed=true


NMCLI has several commands to list devices which can be found here. The NMCLI command should be done as sudo. We will use nmcli connection show to get the list of active connections on the machine. Once we get the list of active connections, we can use it ot modify a network interface to a static ip. Befor ewe do, we can check the current ip address by using the ip command, ip addr. Configuring the static ip isn't enough for internet access, we will need the gateway, netmask and the dns servers. A gateway is a network node that forms a passage between two networks operating with different transmission protocols[2]. All traffic that flows from the outside to in or inside to out passes through the gateway, without it, only local traffic will happen. The subnet divids a network into two or smaller networks, in our case, the lan and the wan. It increases routing efficiency by reducing the size of the broadcast domain. The DNS is a directory of names that match with numbers. The numbers, in this case are IP addresses, which computers use to communicate with each other. Most descriptions of DNS use the analogy of a phone book.[3]

In our example, we will set our static ip address to 192.168.1.101, subnet mask to 255.255.255.0, the gateway to 192.168.1.1, and the DNS to 8.8.8.8. This is done with nmcli in these steps:

First, run the command to set up the IP address.


$ nmcli con mod enps01 ipv4.addresses 192.168.1.101/24


Next, configure the default gateway.

$ nmcli con mod enps01 ipv4.gateway 192.168.1.101


Then set up the DNS server.

$ nmcli con mod enps01 ipv4.dns “8.8.8.8”


Next, change the addressing from DHCP to static.

$ nmcli con mod enps01 ipv4.method manual


Save the changes.

$ nmcli con up enps01


The changes will be written to /etc/sysconfig/network-scripts/ifcfg-enps01 file. To confirm the IP, run the ip addr command.

$ ip addr enps01

Now that we have set the ip address, we can restart the system using sudo reboot. When the system comes up again, you can confirm the ip address by typing in ip addr ens01. After this is done, you can use the static ip to host a variety of servers such as print server, web server, file server or any other device that you will use frequently.





[1]https://wiki.debian.org/NetworkManager "NetworkManager is composed of two layers:"

[2]https://www.tutorialspoint.com/what-are-gateways-in-computer-network 1st paragraph

[3]https://www.networkworld.com/article/3268449/what-is-dns-and-how-does-it-work.html first paragraph