Linux命令之服务器的网络配置hostname,sysctl,ifconfig,service,ifdown,ifup,route,ping的使用
news/
2024/7/27 16:01:40/
文章来源:https://blog.csdn.net/Coin_Collecter/article/details/135637154
1、查看当前主机名称,编辑配置文件修改主机名为你姓名拼音的首字母(如张三,则为zs)
![](https://img-blog.csdnimg.cn/direct/ebc549b46d984fb7ab917b828dec7172.png)
![](https://img-blog.csdnimg.cn/direct/90fd8f00cd104695b7b8f1faed7ef6d1.png)
2、查看本机网卡IP地址,编辑/etc/sysconfig/network-scripts/ifcfg-ens33,要求在一块物理网卡上绑定2个IP地址,IP地址分别为192.168.1100/24,192.168.1101/24。
![](https://img-blog.csdnimg.cn/direct/c5365e61eed043fe8adef6d5ae8f65cb.png)
![](https://img-blog.csdnimg.cn/direct/31506e55d6694d528b1f10af4ee38f59.png)
![](https://img-blog.csdnimg.cn/direct/1981f958e90746fd83c4db6fc7796b33.png)
![](https://img-blog.csdnimg.cn/direct/fb31defc56594a3194c17d78b4816018.png)
3、编辑/etc/hosts文件,实现主机名称(第1题设置的)和IP地址(192.168.1100)的映射关系。ping 主机名,看是否可以ping通。
![](https://img-blog.csdnimg.cn/direct/c86caa8d3cd141afa530ff7d39abc3f5.png)
![](https://img-blog.csdnimg.cn/direct/1194ccbf337f42af9cc24ae3b3348009.png)
4、使用ifconfig配置IP地址为192.168.0.168/24及辅助IP地址192.168.0.208/24(注意:临时生效,重启失效)
![](https://img-blog.csdnimg.cn/direct/ada0fc139ab4480f8d011705a54cc9aa.png)
5、先禁用网卡ens33,ping 192.168.0.168。再启用网卡ens33,ping 192.168.0.168。
![](https://img-blog.csdnimg.cn/direct/289ad7bc185e4e82a33182f2b03eb4b6.png)
6、重新启动network服务。
![](https://img-blog.csdnimg.cn/direct/415a5568dba144469dfdb80398f9cee7.png)
7、更改ens33网卡MAC地址为00:11:22:33:44:55(注意:临时生效,重启network服务失效)
![](https://img-blog.csdnimg.cn/direct/5405e887d4064e35a7ac948ea9aa3ff5.png)
8、查看本机路由表信息,然后使用route命令设置默认网关为192.168.11.254。
![](https://img-blog.csdnimg.cn/direct/7f4c2989a2434e6db8f26c92233444b2.png)
9、加到达目标网络192.168.1.0/24的网络路由,经由ens33网络接口,并由路由器192.168.11.254转发。
![](https://img-blog.csdnimg.cn/direct/dd0b9ec648e1426a8218ece6b735ad92.png)
10、添加到达192.168.1.10的主机路由,经由ens33网络接口,并由路由器192.168.11.254转发。
![](https://img-blog.csdnimg.cn/direct/a1e361e1cb7646168633ee7af202a7cf.png)
11、删除到达目标网络192.168.1.0/24的路由条目,删除到达主机192.168.1.10的路由条目。
![](https://img-blog.csdnimg.cn/direct/5019915ffcaf4696b243e8fd6c8e32df.png)
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_925669.aspx
如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!