SUSE Linux网络配置/SUSE Linux单网卡双IP

1. 直接配置文件:
cd /etc/sysconfig/network 修改ifcfg-ethx文件,格式如下:

 BOOTPROTO='static'
 BROADCAST=''
 ETHTOOL_OPTIONS=''
 IPADDR='192.168.1.158'
 MTU=''
 NAME='AMD PCnet - Fast 79C971'
 NETMASK='255.255.255.0'
 NETWORK=''
 REMOTE_IPADDR=''
 STARTMODE='auto'
 UNIQUE='rBUF.weGuQ9ywYPF'
 USERCONTROL='no'
 _nm_name='bus-pci-0000:02:00.0'


2. 也可以直接用ifconfig命令来配置, 立即生效, 但是重启后配置丢失后:

3. 采用YAST工具

4. 添加默认路由:
cd /etc/sysconfig/network
添加routes文件, 文件中增加: default xxx.xxx.xxx.xxx
或者: route add default gw xxx.xxx.xxx.xxx

5. 重启网络服务:
cd /etc/rc.d ./network start.

6. 同一网卡配置多IP:
在上面网卡的配置文件中增加以下内容:

 IPADDR_1='192.168.2.158'
 NETMASK_1='255.255.255.128'
 LABEL_1='1'
 PREFIXLEN_1=''

7. 多网卡绑定:
vi /etc/sysconfig/network/ifcfg-bond0写入

 BOOTPROTO='static'
 IPADDR='192.168.26.68'
 NETMASK='255.255.255.0'
 STARTMODE='onboot'
 BONDING_MASTER='yes'
 BONDING_MODULE_OPTS='mode=1 miimon=200'
 BONDING_SLAVE0='eth1'
 BONDING_SLAVE1='eth2'

即将eth1/eth2绑定为bond0,静态ip为192.168.26.68


首先配置好网卡的IP地址

vi /etc/sysconfig/network/ifcfg-eth0

BOOTPROTO='static'
 
BROADCAST=''
 
ETHTOOL_OPTIONS=''
 
IPADDR='10.100.50.12'
MTU=''
 
NAME=''
 
NETMASK='255.255.0.0'
 
NETWORK=''
 
REMOTE_IPADDR=''
 
STARTMODE='auto'
 
USERCONTROL='no'
 
_nm_name='static-0'

以上是网卡IP的配置信息,然后加入如下内容

IPADDR_1='10.100.150.1'

NETMASK_1='255.255.0.0'

LABEL_1='1'

/第一个附加IP地址信息/

IPADDR_2='10.100.150.2'

NETMASK_2='255.255.0.0'

LABEL_2='2'

/第二个附加IP地址信息/

保存退出,重启服务

/etc/init.d/network restart
ifconfig
 
eth0      Link encap:Ethernet  HWaddr 00:E0:81:B8:93:D4
inet addr:10.100.50.12  Bcast:10.100.255.255  Mask:255.255.0.0
inet6 addr: fe80::2e0:81ff:feb8:93d4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:11252 errors:0 dropped:0 overruns:0 frame:0
TX packets:6666 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1858349 (1.7 Mb)  TX bytes:3309213 (3.1 Mb)
 
eth0:1    Link encap:Ethernet  HWaddr 00:E0:81:B8:93:D4
inet addr:10.100.150.1  Bcast:10.100.255.255  Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 
eth0:2    Link encap:Ethernet  HWaddr 00:E0:81:B8:93:D4
inet addr:10.100.150.2  Bcast:10.100.255.255  Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 
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:4594 errors:0 dropped:0 overruns:0 frame:0
TX packets:4594 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:378101 (369.2 Kb)  TX bytes:378101 (369.2 Kb)

参照如下:

I've always been used to the Redhat/Fedora way of setting up aliases in /etc/sysconfig/network-scripts-ifcfg-: but SuSe/Novell Linux is slightly different. I see a lot of hackish examples/bad advice on the internet on how to set it up on SuSe/Novell Linux so I figured I'd make a note of it here.

To do it "right" under SuSe, you modify the main configuration file for your ethernet adapter.

For example, 'ifcfg-eth-id-de:ad:co:ed:ba:be' where the de:ad:co:ed:ba:be is replaced by a real MAC address.

As an example, you want the main IP of the system to be statically set to 192.168.100.1, and the other IPs to be 192.168.100.100, 192.168.100.101, and 192.168.100.102

Your original configuration will probably look something like this:

BOOTPROTO='static'

BROADCAST='192.168.100.255'

IPADDR='192.168.100.100'

MTU=1500

NAME='My awesome no-name PCI \"bus-mastering\" NE-2000 clone $1.99 CPU-cycle-hogging wondercard'

NETMASK='255.255.255.0'

NETWORK='192.168.100.0'

REMOTE_IPADDR=''

STARTMODE='onboot'

USERCONTROL='no'

_nm_name='bus-pci-0000:01:04.0'

You will want to change it to look like this:

BOOTPROTO='static'

BROADCAST='192.168.100.255'

IPADDR='192.168.100.100'

MTU=1500

NAME='My awesome no-name PCI \"bus-mastering\" NE-2000 clone $1.99 wondercard'

NETMASK='255.255.252.0'

NETWORK='192.168.100.0'

REMOTE_IPADDR=''

STARTMODE='onboot'

USERCONTROL='no'

_nm_name='bus-pci-0000:01:04.0'

IPADDR1='192.168.100.100'

NETMASK1='255.255.255.0'

LABEL1='0'

IPADDR2='192.168.100.101'

NETMASK2='255.255.255.0'

LABEL2='1'

IPADDR3='192.168.100.102'

NETMASK3='255.255.255.0'

LABEL3='2'

Save that and restart networking with '/etc/init.d/network restart' and you are good to go with:

eth0 set to 192.168.100.1

eth0:0 set to 192.168.100.100

eth0:1 set to 192.168.100.101

eth0:2 set to 192.168.100.102

The 'LABELx' settings are just setting the alias label you see after the 'eth0:'

You can get away with leaving out the 'LABELx' statements. One side effect is that you won't see the aliases under 'ifconfig'.

I know you can do this with 'yast' and other utilities but this seems more direct and easier to do on a high latency SSH console.

原文在这里:http://blog.tiensivu.com/aaron/archives/397-The-correct-way-to-add-IP-aliases-multiple-IPs-on-one-device-in-SuSe-Linux-10-and-below.html

还没有评论,快来抢沙发!

发表评论

  • 😉
  • 😐
  • 😡
  • 😈
  • 🙂
  • 😯
  • 🙁
  • 🙄
  • 😛
  • 😳
  • 😮
  • emoji-mrgree
  • 😆
  • 💡
  • 😀
  • 👿
  • 😥
  • 😎
  • ➡
  • 😕
  • ❓
  • ❗
  • 71 queries in 0.077 seconds