Linux IP命令教程
首先,先了解传统的网络配置命令: 1. 使用ifconfig命令配置并查看网络接口情况 示例1: 配置eth0的IP,同时激活设备: 1 # ifconfig eth0 192.168.4.1 netmask 255.255.255.0 up 示例2: 配置eth0别名设备 eth0:1 的IP,并添加路由 1 # ifconfig eth0:1 192.168.4.2 2 # route add –host 192.168.4.2 dev eth0:1 示例3:激活(禁用)设备 # ifconfig eth0:1 up(down) 示例4:查看所有(指定)网络接口配置 # ifconfig (eth0) ————————— 2. 使用route 命令配置路由表 示例1:添加到主机路由 1 # route add –host 192.168.4.2 dev eth0:1 2 # route add –host 192.168.4.1 gw 192.168.4.250 示例2:添加到网络的路由 1 # route add –net IP netmask MASK eth0 2 # route add –net IP netmask MASK gw IP 3 # route add –net IP/24 eth1 示例3:添加默认网关