1. IP
1) 临时设置
ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
# 指定广播
ifconfig eth0 210.34.6.89 netmask 255.255.255.128 broadcast 210.34.6.127
# 修改MAC地址
ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE
# 绑定多个IP地址,最多支持255个
ifconfig eth4:0 10.137.7.160 netmask 255.255.255.0 up
# 添加或删除IP地址
ip addr add 192.168.1.1/24 dev eth0
ip addr del 192.168.1.1/24 dev eth0
# 丢弃源地址属于192.168.2.0/24网络的所有数据报
ip rule add from 192.168.2.0/24 prio 32777 reject
2) 永久设置
vi /etc/sysconfig/network-scripts/ifcfg-eth0 (Rehat)
vi /etc/sysconfig/network/ifcfg-eth0 (Suse)
DEVICE=eth9
IPADDR=10.137.5.155
NETMASK=255.255.254.0
ONBOOT=yes
BOOTPROTO=static
GATEWAY=10.137.4.1
3) 重启网络
service network restart
/etc/init.d/network restart
ifdown eth0; ifup eth0
ifconfig eth0 down; ifconfig eth0 up
2. Gateway
1) 临时设置
route add default gw 192.168.30.1 eth0
route del default gw 192.168.30.1 eth0
2) 永久设置
vi /etc/sysconfig/network (Rehat)
NETWORKING=yes
HOSTNAME=cbs5155
GATEWAY=10.137.4.1
vi /etc/sysconfig/network/routes (Suse)
default 10.186.18.1 - -
3. DNS
vi /etc/resolv.conf
nameserver 10.98.48.39
nameserver 10.72.255.100
4. 防火墙
service iptables start
service iptables stop
service iptables on
service iptables off
5. 修改主机名
1) Redhat
vi /etc/sysconfig/network
HOSTNAME=CentOS6.7
2) Suse
vi /etc/hostname
Suse11
/etc/rc.d/boot.localnet start
3) 临时指定主机名
hostname Suse11
cat /proc/sys/kernel/hostname
4) IP与hostname映射关系(静态路由表)
vi /etc/hosts
10.186.19.148 CentOS6.7
10.186.19.149 Suse11
6. 路由追踪
traceroute 10.137.5.155
7. ip命令
ip addr
ip rule
ip neigh # 只显示有效的网卡