[CENTOS] Set a fixed IP in the Linux environment

Purpose

Set a fixed IP for the CentOS 8 virtual machine created in Hyper-V Connect to virtual machine with Tera Term

environment

CentOS 8.1.1911

procedure

Check current status

● Check the status with a command

# ip a
# ip a show dev eth0

eth0: inet 192.168.10.4/24

This will give you the current private IP address. Network address "192.168.10" Host address "4"

Edit configuration file

● Edit the interface setting file as follows.

/etc/sysconfig/network-scripts/ifcfg-eth0


IPV6INIT="no"
#IPV6_AUTOCONF="yes"
#IPV6_DEFROUTE="yes"
#IPV6_FAILURE_FATAL="no"
#IPV6_ADDR_GEN_MODE="stable-privacy"

BOOTPROTO="none"
IPADDR=192.168.10.100
PREFIX=24
GATEWAY=192.168.10.1
DNS1=192.168.10.1
DNS2=8.8.8.8

I don't use IPV6, so I changed IPV6INIT from "yes" to "no". Other parameters related to IPV6 have been excluded.

・ BOOTPROTO: IP address specification method [none / dhcp / bootp] If you want to specify a fixed IP, you can use "none" or "static".

・ IPADDR: IP address to specify Add an appropriate host address to the previous network address.

・ PREFIX: Prefix length Maybe this is NETMASK or either parameter? maybe. .. ..

・ GATEWAY: Router IP

・ DNS "8.8.8.8" is Google Public DNS

● After setting, restart the network

# systemctl restart NetworkManager

When you check the status ... eth0: inet 192.168.10.100/24

ipv6 disabled

Even if I checked after restarting in the previous procedure, inet6 was set. There may be no problem, but I didn't intend to use it in the settings, so I will disable it.

● Create the following files

:/etc/sysctl.d/disable_ipv6.conf


net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

● Reflection

# sysctl -p/etc/sysctl.d/disable_ipv6.conf

When I checked the status, inet6 disappeared.

Verification

● Enter the set IP address コメント 2020-02-09 112306.jpeg

● Connect after entering the user and password コメント 2020-02-09 112307.jpeg

I was able to connect. For the time being, let's assume that you have done what you want to do.

Recommended Posts

Set a fixed IP in the Linux environment
Ubuntu18.04.05 Creating a python virtual environment in LTS
Set a fixed IP in the Linux environment
Build a Selenium environment on Amazon Linux 2 in the shortest time
Use the latest pip in a virtualenv environment
The story of building the fastest Linux environment in the world
[Linux] How to put your IP in a variable
Completely disable mouse acceleration in the Linux desktop environment
SSH restrictions in Linux environment
Collaborate in a remote environment
Define a task to set the fabric env in YAML
Build Azure Pipelies with Azure DevOps in a Linux self-hosted environment
Create a Linux environment on Windows 10
Get the client's IP address in Django
Building a Python3 environment with Amazon Linux2
[Understanding in 3 minutes] The beginning of Linux
Replace the directory name and the file name in the directory together with a Linux command.
Write the test in a python docstring
Set the environment variable PYTHONPATH on zsh
Cut out A4 print in the image
Change the list in a for statement
A quick overview of the Linux kernel
[Linux] Command to get a list of commands executed in the past
Associate the table set in python models.py
Run the Python interpreter in a script
I set the environment variable with Docker and displayed it in Python
View the full path (absolute path) of a file in a directory in Linux Bash
Set up Pipenv in Pycharm in Windows environment
[Linux] Build a jenkins environment with Docker
[Development environment] How to create a data set close to the production DB
Use a shortcut to enable or disable the touchpad in Linux Mint
Install rJava on Linux in R3.6 environment.
Creating a virtual environment in an Anaconda environment
Install CaboCha in a non-Anaconda environment (Win)
I started Node.js in a virtual environment
Install the package in an offline environment
Use WebDAV in a Portable Docker environment
[Linux] Build a Docker environment with Amazon Linux 2
Arrange the numbers in a spiral shape
Set the number of elements in a NumPy one-dimensional array to a power of 2 (0 padded)
[AWS] Let's run a unit test of Lambda function in the local environment
I want to set a life cycle in the task definition of ECS
Create a Django project and application in a Python virtual environment and start the server
On Linux (Ubuntu), tune the Trackpad and set the function to a three-finger swipe
Instructions for connecting Google Colab. To the local runtime in a Windows environment
A tool to insert the country name and country code in the IP address part
Set up a simple HTTPS server in Python 3
Build a LAMP environment in a very short time
[Python] Get the files in a folder with Python
System switching occurs in a CentOS 7 cluster environment
Open a ZIP created on Windows in Linux
Get the caller of a function in Python
Start Django in a virtual environment with Pipenv
ffmpeg-Build a python environment and split the video
Set up a test SMTP server in Python.
Install the python package in an offline environment
Get only the subclass elements in a list
Set up a UDP server in C language
Precautions when installing packages in the conda environment
Think about building a Python 3 environment in a Mac environment
Work in a virtual environment with Python virtualenv.
Output in the form of a python array