redhat 网络设置

用[]表示用户自己填写 Ip配置: 临时.

用[]表示用户自己填写

Ip配置:

临时-shell:ifconfig  eth0  [ipaddr]  netmask [netmaskn]

—————————————————————————

永久-配置文件:  /etc/sysconfig/network-scripts/ifcfg-eth0

动态ip:

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=dhcp

HWADDR=[mac]

静态ip:

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=static

IPADDR=[一个合适你的ip]

NETMASK=[根据你的ip填写]

 

注意:如果你的配置文件改了,需要重启响应的硬件,这里的话,是网卡,service network restart

 

————————————————————————————————————————————–

网关:/etc/sysconfig/network

NETWORKING=yes                 /*IPv4*/

NETWORKING_IPV6=no

HOSTNAME=[你的主机名]

 

GATEWAY=[你的网关]                      /*静态ip的时候一定要设置这里才可以访问外网的哦~*/

 

————————————————————————————————————————————–

Dns: /etc/resolv.conf

 

Nameserver [你的域名服务器,比如218.30.19.40]

————————————————————————————————————————————–

检测你的本机网络

Ping

1、    与网关:ping [your gateway]

2、    与外网交互,比如下载一个东西:

 

wget http://www.qq.com/

 

————————————————————————————————————————————–

一个机子绑定多个ip

Shell下:

ifconfig eth0:0  [ipaddr] netmask [子网掩码] up

ifconfig eth0:1  [ipaddr] netmask [子网掩码] up

去掉一个:

ifconfig eth0:1 down

 

————————————————————————————————————————————–

route:

查看路由信息: route –n

 

redhat 网络设置 - yinzhezq - yinzhezq的博客

 

 

设置默认网关: route add default gw [ipaddr]

添加一个静态路由:route add –net [netaddr] netmask [掩码] gw [ipaddr]  [eth0]

/*netaddr 为上图destination*/

删除一个静态路由:route del –net [netaddr] netmask [掩码] gw [ipaddr] [eth0]