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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!