/etc/sysconfig/network 是全局性网络配置文件 修改将会影响计算机所有网卡信息
NETWORKING=yes/表示启用ipv4
/etc/sysconfig/network-scripts/ 每一张网卡的配置文件
[root@VM_0_4_centos network-scripts]# cd /etc/sysconfig/network-scripts/
[root@VM_0_4_centos network-scripts]# ls
ifcfg-eth0 ifdown-Team ifup-post
ifcfg-lo ifdown-TeamPort ifup-ppp
ifdown ifdown-tunnel ifup-routes
ifdown-bnep ifup ifup-sit
ifdown-eth ifup-aliases ifup-Team
ifdown-ippp ifup-bnep ifup-TeamPort
ifdown-ipv6 ifup-eth ifup-tunnel
ifdown-isdn ifup-ippp ifup-wireless
ifdown-post ifup-ipv6 init.ipv6-global
ifdown-ppp ifup-isdn network-functions
ifdown-routes ifup-plip network-functions-ipv6
ifdown-sit ifup-plusb route6-eth0
cat ifcfg-ech0
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=dhcp
DEVICE=eth0
HWADDR=52:54:00:d6:38:67 #MAC地址
NM_CONTROLLED=no #是否收到networkmanager 管理,当前是不受networkmanger管理
ONBOOT=yes #是否随开机启动
PERSISTENT_DHCLIENT=yes
TYPE=Ethernet #网卡类型:以太网类型
USERCTL=no #普通用户是否有权限来更改配置此网卡
service network restart 网络重启
iwconfig 可以设置无线网络
/etc/host 本地DNS服务器
ifconfig -a 查看所有网卡信息
ifconfig -网卡名字 查看某一个网卡
ifconfig eth0 1.1.1.1 nemask 255.255.255.255 up 临时设置网卡信息
ifconfig eth0 down 暂停eth0这张网卡
ifconfig eth0 up 启用eth0这张网卡 这两条命令并不改变暂停前eth0的网卡信息,也就是说如果暂停前临时设置了eth0de 信息,那么在启用的时候并不改变
ifdown 关闭eth0这张网卡
ifup 重新启用这张网卡 这两条命令重新启用网卡信息,但是会根据配置文件重启
ip addr show eth0 查看eth0网卡信息 显示三层信息(网络层、数据链路层、物理层)
ip link show eth0 显示二层信息
ip link set eth0 down 关闭 eth0
ip link set eth0 name tiankong 将eth0重命名为天空 (系统重启仍然为eth0)
ip link set tiankong up 激活tiankong(eth0)
如果要永久更改eth0的名字需要更改/etc/udev/rules.d/70-persistent-net.rules里面的内容
以及/etc/sysconfig/network-scripts中 ifcfg-eth0文件的名字
ip link set eth0 mtu 更改mtu
ip addr add 192.168.30.101/24 dev eth0
route
route -n 的区别
route -n 将不会进行反向解析,也就是说不会讲ip地址解析成主机名字
例如
[root@VM_0_4_centos network-scripts]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 0 0 0 eth0
link-local 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
172.27.0.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
#在route的情况下 Destination 一栏显示的是主机名
在route -n 的情况下直接显示的就是ip地址
不进行反向解析会节省一定时间
[root@VM_0_4_centos network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.27.0.1 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
172.27.0.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
给网卡增加网关
route add default gw 192.168.30.2 (此时一般为eth0)
删除网关
route del default gw 192.168.30.2
指明给哪儿一个网卡配置网关
route add default gw 192.168.30.2 dev 网卡名
增加网关时,网关一定要和IP地址在同一个网段
不然会发生以下错误
SIOCADDRT: Network is unreachable
iwconfig 查看无线网卡信息
网络排错以及两台主机连接
linux 中 ping 命令默认一直ping下去
traceroute :跟中两个节点之间经过多少个路由
netstat -ntulp 查看系统当前使用哪儿些端口以及连接情况
-n 表示不做反响解析
-t 查看tcp情况
-u 查看udp情况
-l listen 表示正在监听的
-p 显示出来这些端口对应进程
netstat -r 查看网关等同于route
host 命令域名对应的主机名
eg host yuchanglove.coub
将会显示出yuchanglove.club对应的ip地址
[root@VM_0_4_centos ~]# host yuchanglove.club
yuchanglove.club has address 118.24.87.88
hostname 显示查询的主机名
hostname zuofeng 将主机名更改为zuofeng
若要用就更改主机名可以在/etc/sysconfig/network文件中更改
远程登陆telnet
telnet 登录过程中是明文传输,所有通信都是不仅过加密的 它是非常不安全的远程登陆方式
同时telnet 也可以连接到一个网站
eg telnet baidu.com (具体情况情再次参考相关资料)
Pidgin
一个通信的小软件,可以用来登陆QQ