歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux下兩種網絡配置方式

Linux下兩種網絡配置方式

日期:2017/2/28 17:35:27   编辑:Linux教程
第一種方式:
1. 加IP地址:ifconfig eth0 192.168.1.3 netmask 255.255.255.0
2. 增加默認網關:route add default gw 192.168.1.1 dev eth0
提示:刪除默認網管命令是route del default gw 134.77.8.10 dev eth0

第二種方式:以root用戶操作:
1. $vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.2 SIPSIR

2.$ vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

3. cd /etc/rc.d/init.d
$./network restart

NETMASK的最後一個數是255.255.255.0,那麼IPADDR的可用的范圍是:192.168.1.1~192.168.1254,其中192.168.1.0是網絡地址,192.168.1.255是廣播地址,這2個地址是不可以用的。
Copyright © Linux教程網 All Rights Reserved