本文主要描述的是单网卡主机的相关设置
1.设置IP地址(例如eth0网卡)
ifconfig eth0 x.x.x.x netmask x.x.x.x broadcast x.x.x.x
如果需要 关机后重启电脑 仍然保存修改,需要修改相应的配置文件/etc/network/interfaces
(1)静态获取ip
auto eth0
iface eth0 inet static
address x.x.x.x
gateway x.x.x.x
etmask x.x.x.x
(2)动态获取ip
auto eth0
iface eth0 inet dhcp
修改配置文件后 运行/etc/init.d/networking restart(重启网卡)
2.设置默认网关
route add default gw x.x.x.x
route del default gw x.x.x.x
3.配置DNS
(1)使用本机静态查询
修改文件/etc/hosts,添加主机名和对应的ip地址
(2)使用DNS服务器
修改配置文件/etc/resolv.conf 添加相应服务器的ip地址即可
4.使用traceroute命令测试所经网关(比ping 更加详细)
可使用操作ping www.baidu.com / traceroute www.baidu.com试试看
5.使用netstat命令检测链接状态
用于查看本机与哪些地址建立了链接 netstat -nt