linux網(wǎng)絡(luò)基本配置

1.IP
    1.1 修改IP及子網(wǎng)掩碼并激活
         # ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up

    1.2修改文件
         # vi /etc/sysconfig/network-scripts/ifcfg-ethN  --N是網(wǎng)卡序號

    1.3 同時(shí)修改IP, Mask, Broadcast
         # ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.25.255 up

2. 網(wǎng)關(guān)
    2.1 添加網(wǎng)關(guān)
        # route add default gw 192.168.30.1 eth0

    2.2修改文件
         # vi /etc/sysconfig/network

3. 域名系統(tǒng)
    3.1 # vi /etc/resolv.conf
          nameserver 202.131.80.1
          nameserver 202.131.80.5

4. 服務(wù)
    4.1 # service network restart

5. 防火墻
    5.1 # service iptables start  --啟動(dòng)

    5.2 # service iptables stop --關(guān)閉

    5.3 # service iptables on --啟動(dòng)但需重啟

    5.4 # service iptables on --關(guān)閉但需重啟

6. ifcfg-ethN文件解釋
    device--設(shè)備名
    IPAddr--IP地址
    netmask--子網(wǎng)掩碼
    network--網(wǎng)絡(luò)地址(可不要)
    Broadcast--廣播地址(可不要)
    gateway--網(wǎng)關(guān)
    onboot=yes|no 引導(dǎo)時(shí)是否啟動(dòng)該設(shè)備(eg: eth0)
    userctl=yes|no 非root用戶是否可以控制該設(shè)備
    bootproto=static|dhcp IP地址是靜態(tài)指定還是動(dòng)態(tài)獲取