linux 认为ip是属于主机的而不是接口的
ARP协议
响应:
路由类型:静态 动态
主机路由 网路路由 默认路由
查看网络跑ip
ifconfig
ip addr show
ip addr show eth0
ip -s link show (s 统计)
ip addr add ip地址 添加ip地址
ip link eth0 down 禁用eth0 的ip地址
网络设备的配置:
speed 100 或1000 手动设置速率
ethool -i eth0
-s eth0 speed 100 指定设置设备进行配置
duplex half 或 full 设置双工模式
autoneg on 或off 开启或关闭自动协商
dhcp 关闭时 会有一个自动专有地址:169.254 仅用来实现本地网络的通信
网卡绑定多个ip设置:格式:ifcfg-ethx:y (x y为数字)
cp ifcfg-eth0 ifcfg-etho:0
vim ifcfg-eth0:0 编辑
网卡绑定大量ip 格式:ifcfg-ethx-rangex
vim ifcfg-eth0-range0 添加
IPADDR_START=10.1.1.1
IPADDR_END=10.1.1.20
NETMASK=255.0.0.0
路由信息查看: ip route
netstat -rn
route -n
静态路由配置: route add -net ip/netmask gateway
route add -net 172.16.0.1/24 gt 172.16.0.2
route add -net host ip gateway ip
临时生效
永久生效 /etc/sysconfig/network-scripts/
编辑 route-eth0 加入ip 即可
ADDRESS0=10.10.10.0
NETWORK0=255.0.0.0
GETEWAY0=172.16.0.25
ADDRESS1=10.10.10.0
NETWORK1=255.0.0.0
GETEWAY1=172.16.0.25
重启网络 service network restart
网络测试命令:
ping
traceroute
修改主机名:/etc/sysconfig/network 永久生效 /etc/hosts 也可
临时的 hostname 主机名
systrl -w kernel.hostname=
dns 配置: /etc/resolv.conf
gethostip www.a.com 可以获得ip
host -t A www.a.com 也可
dig -t instructor.example.com
/etc/sysconfig/network-scripts/ifcfg-eth0:
设置PERDNS=no 可以不让覆盖DNS地址
netstat -t 查看tcp连接 -u udp连接 -tln 查看监听
nmap 探测扫描工具 yum install nmap
-p 扫描端口的
-sL 主机列表 nmap -sL 192.168.0.1-25 -o
抓包工具:
tcpdump -i eth0
wireshark yum install wireshark
wireshark-gnome 图形界面的
以太网通道绑定:网卡绑定 实现负载均衡和单点故障
modprobe bonding 加载绑定模块
自动加载该模块: 添加在etc/modprobe.conf
alias bond0 bonding