2020616课堂笔记

@[TOC]第一章 Linux 网络设置与基础服务

查看及测试网络

1.1 查看活动的网络接口设备
命令:ifconfig (不接限定内容,显示全部接口)
查看指定网络接口:ifconfig ens33
查询后显示内容,主要查看ether 网络的物理地址
inet 网络接口的IP地址
broadcast 网络接口所在的网络广播地址
netmask 子网掩码
2.1 查看路由表、接口统计
命令:netstat
-n 以数字形式查看
-a 所有
p 显示与网络连接相关联的进程号
t 查看tcp协议相关的信息

[root@localhost /]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.99.2 0.0.0.0 UG 100 0 0 ens33
192.168.99.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0

3.1 ping 命令 测试网络连通性

4.1 追踪命令 traceroute
[root@localhost /]# traceroute www.baidu.com
traceroute to www.baidu.com (14.215.177.39), 30 hops max, 60 byte packets
1 gateway (192.168.99.2) 0.435 ms 0.231 ms 0.116 ms
2 * * *
3 * * *

5.1 nslookup 测试域名解析
[root@localhost /]# nslookup www.firefox.com
Server: 192.168.99.2
Address: 192.168.99.2#53

Non-authoritative answer:
www.firefox.com canonical name = firefox.com.
Name: firefox.com
Address: 63.245.208.212

网络配置命令

1、修改网卡的地址、状态ifconfig
修改网卡的地址、子网掩码
ifconfig ens33 192.168.99.129/24
ifconfig ens33 192.168.99.129 netmask 255.255.255.0
禁用、激活网络接口
ifconfig ens33 down ifconfig ens33 up
or ifdown ens33 ifup ens33
绑定虚拟接口
[root@localhost /]# ifconfig ens33:0 172.16.0.1
[root@localhost /]# ifconfig
ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.0.1 netmask 255.255.0.0 broadcast 172.16.255.255
ether 00:0c:29:ea:44:c7 txqueuelen 1000 (Ethernet)
2、添加、删除静态路由
静态路由 使本机访问网段192.168.3.0/24 的数据包都发给192.168.2.22接口
route add -net 192.168.3.0/24 gw 192.168.2.22
删除
route del -net 192.168.3.0/24
默认路由 同一主机只应有一个默认路由
添加 route add default gw 192.168.2.22
删除 route del default gw 192.168.2.1

修改网络配置文件

网络接口配置文件
配置文件为:ifcfg-*** 网络接口名称
配置前先查询:ls /etc/sysconfig/network-scripts/
vim /etc/sysconfig/network-scripts/ens33
DEVICE:网络接口的名称
ONBOOT:设置为启动时激活
BOOTPROTO: 网络接口配置方式“static”或者“dhcp”
IPADDR: IP地址
NETMASK: 子网掩码
GATEWAY: 默认网关
DNS1: 域名解析

主机名称配置文件
vim /etc/hostname

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值