# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:30 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1872 (1.8 Kb) TX bytes:1872 (1.8 Kb)
发现只有本地换回口开着,eth0之类的网口没开。
好,有时该使用下暴力手段了。
#ifconfig eth0 up
eth0: unknown interface: 没有那个设备
。。。。。。居然提示没有设备,好吧,看看其他的网口
#ifconfig eth1 up
看看情况,总算起来了。
# ifconfig
eth1 Link encap:Ethernet HWaddr 00:0C:29:F6:2F:B1
inet6 addr: fe80::20c:29ff:fef6:2fb1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:77 errors:0 dropped:0 overruns:0 frame:0
TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7038 (6.8 Kb) TX bytes:5801 (5.6 Kb)
Interrupt:19 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:30 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1872 (1.8 Kb) TX bytes:1872 (1.8 Kb)
# /etc/init.d/network restart
Shutting down network interfaces:
eth1 device: Advanced Micro Devices
No configuration found for eth1
Nevertheless the interface will be shut down. done
Shutting down service network . . . . . . . . . done
Hint: you may set mandatory devices in /etc/sysconfig/network/config
Setting up network interfaces:
eth1 device: Advanced Micro Devices
No configuration found for eth1 unused
Setting up service network . . . . . . . . . . done
SuSEfirewall2: Setting up rules from /etc/sysconfig/SuSEfirewall2 ...
SuSEfirewall2: using default zone 'ext' for interface eth1
SuSEfirewall2: batch committing...
SuSEfirewall2: Firewall rules successfully set
No configuration found for eth1 unused说明系统没有针对eth1的配置
先看看eth1有没有配上ip
好吧,端口都关闭了
# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:30 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1872 (1.8 Kb) TX bytes:1872 (1.8 Kb)
既然提示针对eth1的配置文件没有找到,那么就需要到配置目录看看喽。
suse linux的网络配置文件的存放目录是在/etc/sysconfig/network/下面,瞧瞧去
/etc/sysconfig/network # ls -l
总用量 88
-rw-r--r-- 1 root root 13895 11月 19 2014 config
-rw-r--r-- 1 root root 9956 11月 19 2014 dhcp
-rw-r--r-- 1 root root 169 11月 17 06:37 ifcfg-eth0
-rw------- 1 root root 172 2月 1 2012 ifcfg-lo
-rw-r--r-- 1 root root 29333 2月 1 2012 ifcfg.template
drwxr-xr-x 2 root root 4096 11月 19 2014 if-down.d
-rw-r--r-- 1 root root 239 2月 1 2012 ifroute-lo
drwxr-xr-x 2 root root 4096 11月 19 2014 if-up.d
drwx------ 2 root root 4096 5月 5 2010 providers
drwxr-xr-x 2 root root 4096 11月 19 2014 scripts
果然没有ifcfg-eth1的配置文件,咋办呢?不是还有ifcfg-eth0的嘛,参考一下。
/etc/sysconfig/network # cat ifcfg-eth0
BOOTPROTO='dhcp'
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR=''
MTU=''
NAME='79c970 [PCnet32 LANCE]'
NETMASK=''
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto'
USERCONTROL='no'
明显这就是我们想要的用dhcp动态分配ip的配置文件,拷贝成ifcfg-eth1看看。
/etc/sysconfig/network # cp ifcfg-eth0 ifcfg-eth1
重新启动网络配置,成功了,哈哈
# /etc/init.d/network restart
Shutting down network interfaces:
eth1 device: Advanced Micro Devices done
Shutting down service network . . . . . . . . . done
Hint: you may set mandatory devices in /etc/sysconfig/network/config
Setting up network interfaces:
eth1 device: Advanced Micro Devices
eth1 Starting DHCP4+DHCP6 client. . . . . . . .
eth1 IP address: 192.168.27.125/24
eth1 DHCP6 continues in background done
Setting up service network . . . . . . . . . . done
SuSEfirewall2: Setting up rules from /etc/sysconfig/SuSEfirewall2 ...
SuSEfirewall2: using default zone 'ext' for interface eth1
SuSEfirewall2: batch committing...
SuSEfirewall2: Firewall rules successfully set