Linux 之 网络相关设置

mac2022-06-30  22

网络相关设置


   参考教程:【千峰教育】


 

命令:

  ping:     作用:通常用于检测网络设备的连通性。     格式:ping IP/域名     选项:-c,指定方式测试数据包的次数     实例:ping www.baidu.com -c 3 会自动停止

 

  ifconfig:     作用:查看或设置网卡的信息     实例:       ifconfig:查看活动网卡信息       ifconfig eth0 down:关闭网卡,等价于ifdown eth0       ifconfig eth0 up:开启网卡,等价于ifup eth0     服务:       开启|关闭|重启网络服务       方式1:/etc/init.d/network start|stop|restart       方式2:service network start|stop|restart

 

  网卡配置文件:     文件路径:/etc/sysconfig/network-scripts/ifcfg-eth0     (注意:这里以centos6.8为参考,其他centos版本的网卡可能最后一位不是0)

    文件内容:      DEVICE=eth0       HWADDR=08:00:27:B5:95:4B      TYPE=Ethernet      UUID=9fb7ec7b-d295-444f-9817-f2032a9f0694      ONBOOT=yes|no       NM_CONTROLLED=yes      BOOTPROTO=dhcp|static      IPADDR=xxx.xxx.xxx.xxx      NETMASK=255.255.255.0      GATEWAY=xxx.xxx.xxx.xxx      DNS1=xxx.xxx.xxx.xxx      DNS2=xxx.xxx.xxx.xxx

    如果不在网卡的配置文件里添加DNS,可以编辑:/etc/resolv.conf。       xxx.xxx.xxx.xxx       xxx.xxx.xxx.xxx

 

  添加本地域名解析服务:编辑文件/etc/hosts   127.0.0.1 www.test.com


 

转载于:https://www.cnblogs.com/gyfluck/p/10450914.html

最新回复(0)