春节期间因为疫情假期延长,导致连续鸽了两个星期,同时最近有点忙,会尽快补上的。
这一篇记录一下CentOS系统网络设置相关的命令。
查询当前IP地址
ifconfig

eth+序号代表不同的网络设置,对应的inet值即为各自IP地址。
如果显示ifconfig未安装(CentOS minimize最小化安装时一般不带),可以使用以下命令。
ip addr

如果没有inet对应的值,可以修改网络配置文件
vi /etc/sysconfig/network-scripts/ifcfg-eth0 ONBOOT=yes #开机自启动,然后保存此文件 systemctl restart network # 重启网络服务
也可以使用service network restart命令重启网络服务。
修改IP地址
vi /etc/sysconfig/network-scripts/ifcfg-eth0 BOOTPROTO=static #静态IP,默认为dhcp动态IP ONBOOT=yes #开机自启 IPADDR=192.168.0.230 #静态IP GATEWAY=192.168.0.1 #默认网关 NETMASK=255.255.255.0 #子网掩码 DNS1=192.168.0.1 #DNS 配置 DNS2=8.8.8.8 systemctl restart network#重启网络服务
另外可以试试nm-connection-editor(安装图形界面才能使用)和nmtui,图形化修改网络设置。
临时设置网络
重启网络服务后失效
ifconfig eth0 10.0.0.10 netmask 255.0.0.0 #设置IP和子网掩码 route add default gw 10.0.0.1 #设置网关 ifconfig eth0 hw ether 00:11:00:00:11:11 #设置物理地址(MAC地址) ifconfig eth0 up #启用eth0网络 ifconfig eth0 down #关闭eth0网络
修改hosts文件
hosts文件路径为/etc/hosts,与windows的hosts修改方式相同。
After all,tomorrow is another day.
毕竟,明天又是崭新的一天。
《飘》
——玛格丽特·米切尔


评论
Drop a link to your favorite blog post of yours in the comments below, I’d love to read more.
Your passion for what you do is evident in every post It’s inspiring to see someone truly fulfilling their purpose and making a positive impact
This blog is like a safe haven for me, where I can escape the chaos of the world and indulge in positivity and inspiration
I am constantly impressed by the depth and detail in your posts You have a gift for making complex topics easily understandable
I appreciate how well-researched and informative each post is It’s obvious how much effort you put into your work
This post came at just the right time for me Your words have provided me with much-needed motivation and inspiration Thank you
Your blog is a great source of positivity and inspiration in a world filled with negativity Thank you for making a difference
I appreciate how this blog addresses important issues in a respectful and informative manner It’s refreshing to see a blog use its platform for good
Your words have a way of touching hearts and inspiring minds Thank you for using your platform to spread love and positivity
Your posts are always so well-researched and informative I appreciate how thorough and detailed your content is
Let’s spread the love! Tag a friend who would appreciate this post as much as you did.
This blog serves as a reminder to take care of our mental health and well-being Thank you for promoting a healthier and happier mindset
176140 724632Sweet web web site , super style and style , rattling clean and utilize genial . 348760