春节期间因为疫情假期延长,导致连续鸽了两个星期,同时最近有点忙,会尽快补上的。
这一篇记录一下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.
毕竟,明天又是崭新的一天。
《飘》
——玛格丽特·米切尔
评论
951529 380778Fantastic info many thanks sharing and reaching us your subscriber list. 935780
My brother suggested I may like this blog. He was entirely right. This submit truly made my day. You cann’t believe just how so much time I had spent for this info! Thank you!
https://www.emedesuministros.es/impresoras-multifuncion/142870-hp-28b55a-smart-tank-impresora-multifuncion-7006-color-impresora-para-impresion-escaneado-co-0195908302391.html
818886 699522Nice web site. On your blogs really interest and i will tell a buddies. 445646
Thanks for some other informative blog. The place else may I get that kind of info written in such an ideal way? I’ve a mission that I’m just now running on, and I’ve been on the look out for such information.
https://youtu.be/T8Q36ab1HCc
Valuable information. Lucky me I found your site by accident, and I am shocked why this accident didn’t happened earlier! I bookmarked it.
https://youtu.be/dwqHphZKTtA
Your home is valueble for me. Thanks!…
https://youtu.be/7IDhVlV6-38
I visited a lot of website but I conceive this one has got something extra in it in it
https://youtu.be/BanYFY6l55c
Keep working ,remarkable job!
https://youtu.be/lYIqeNvx2Ik
I love it when people come together and share opinions, great blog, keep it up.
https://youtu.be/gKr3OKOswAs
What’s Going down i am new to this, I stumbled upon this I’ve discovered It positively helpful and it has aided me out loads. I am hoping to give a contribution & help different customers like its aided me. Great job.
https://youtu.be/2DjsAW75aeM