linux基础六
九、网络管理
1.Ipv4网络
• IP地址
• 网关GATEWAY
• DNS,域名服务器
2.IP地址
3.网关
4.DNS
DNS(Domain Name System,域名系统),因特网上作为域名
和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP。
5.网络管理命令
ifconfig
ip addr show eth0
ping -c 1 -w 1
ip route
traceroute
6.网络管理命令nmcli
nmcli con add .. 添加一个新连接
命令使用
nmcli dev status 列出所有设备
nmcli con show 列出所有连接
nmcli con up <name> **某个连接
nmcli con down <name> 关闭某个连接
nmcli dev dis <dev> 断开某个设备
nmcli con mod <ID> 修改连接
nmcli con del <ID> 删除连接
7.网络管理命令
nmcli connection add type ethernet con-namewestos ifname
eth0 autoconnect yes
nmcli connection add type ethernet con-namewestos ifname
eth0 ip4 172.25.254.10/24
nmcli connection delete westos
nmcli connection show
nmcli connection down westos
nmcli connection up westos
nmcli connection modify "westos"ipv4.addresses newip/24
nmcli connection modify "westos"ipv4.method
<auto|manual>
nmcli device connect eth0
nmcli device disconnect eth0
nmcli device show
nmcli device status
8.网络管理文件
动态获取IP配置:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 //接口使用设备
BOOTPROTO=dhcp //网卡工作模式
ONBOOT=yes //网络服务开启时自动**
NAME=eth0 //网络接口名称
静态IP配置:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static|none
ONBOOT=yes
NAME=eth0
IPADDR=172.25.0.100
NETNASK=255.255.255.0 //子网掩码,通过也可PREFIX=24
• 配置文件:/etc/sysconfig/gateway
GATEWAY = IP
• 查看:route -n
名称解析
两个文件:
/etc/hosts
/etc/resolv.conf
一个配置文件:
/etc/nsswitch.conf