设置IP

首先用ethtool eth 查看哪个端口开着。

比如: ethtool eth0

           ethtool eth1

linux-d109:/ # ethtool eth0
Settings for eth0:
Cannot get device settings: No such device
Cannot get wake-on-lan settings: No such device
Cannot get message level: No such device
Cannot get link status: No such device
No data available
linux-d109:/ # ethtool eth1
Settings for eth1:
Cannot get device settings: No such device
Cannot get wake-on-lan settings: No such device
Cannot get message level: No such device
Cannot get link status: No such device
No data available
linux-d109:/ # ethtool eth2
Settings for eth2:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: d
        Wake-on: d
        Current message level: 0x00000007 (7)
        Link detected: yes

那么 接下来 设置IP

 

linux-d109:/ # ifconfig eth2 192.168.8.0 netmask 192.168.9.253

 

查看 IP ,执行  ifconfig 就可以了。

 

如果想永久设置IP 的话, 就要修改文件

linux-d109:/etc/sysconfig/network # cat ifcfg-eth2
BOOTPROTO='static'
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR='192.168.8.223'
NETMASK='255.255.254.0'
STARTMODE='onboot'
USERCONTROL='no'
linux-d109:/etc/sysconfig/network #

 

如果 /etc/sysconfig/network 下面只有 ifcfg-eth0,

而用ethtool eth 查看结果又只有eth2的话

就 cp ifcfg-eth0 ifcfg-eth2

自己copy一个文件出来。

 

然后执行  service network restart.

 

这样IP 就生效了。

你可能感兴趣的:(Linux内核学习,network,service,pair)