Linux 中设置静态的IP

Topic (What i going to write)

Setting the static Ip address in linux

Main Information

Firstly use CD enter the location /etc/sysconfig/network-scripts

Then , we can use the command ls to the all the files in the folder ,like below

find the file with prefix ifcfg-en[]

Next, use vim open it. Edit the BOOTPROTO to static

Next,Add extra line under the text, IPADDR, GATEWAY and DNS1

What you should mentioned is that your network segment shoule the same with your hard-machine (real computer )

and the gateway also need same as your real computer's gate way .

Explanation

一定要注意- 配置网络地址的时候需要跟物理机保持在相同的网段内,否则无法进行通讯, 其次虚拟机的网关和DNS 需要和物理机保持一致

-> 在修改完网络配置以后 使用命令 systemctl restart network to 重启网卡


conclusion (Summary)

我的配置如下

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no

这里设置静态(可以直接复制 , 因为markdown的语法显示成了标题 下述一致)

BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=740837dc-6070-4971-8137-82901e8527f5
DEVICE=enp0s3
ONBOOT=yes

静态IP地址

IPADDR=192.168.0.9

网关地址

GATEWAY=192.168.0.1

DNS 地址

DNS1=192.168.0.1

posted @ 2023-01-30 17:14  站在山顶的人  阅读(213)  评论(0编辑  收藏  举报