前不久,在实验室时,由于内部的局域网有192.168.1.0 这个网段的IP地址,如果要连接到外网,需要将IP改变172.16.20.0 这个网段,192.168.1.0这个网段可以访问老师的FTP,172.16.20.0这个网段可以访问互联网。
我需要两个网段都用,设置来设置去很麻烦。所以直接将网卡绑定多IP,一劳永逸。
在RHEL中,有两个方式来绑定多IP,一种 是手工一个一个添加,一种是批量添加。
先讲第一种:
话不多话,我的习惯是上图说明一切:
[root@localhost network-scripts]# vi ifcfg-eth0:0
将DEVICE 改为eth0:0 IP地址也改为自己想要的。
这样就可以同时使用两个IP了。
如果需要两个以上的IP时,一个一个的创建ifcfg-eth0:x文件很麻烦。RHEL提供了批量添加的方法:
650) this.width=650;”>
[root@localhost network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:febf:ce97/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:308 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:56737 (55.4 KiB)
Base address:0xd010 Memory:f0000000-f0020000
eth0: Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:0 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:172.16.20.100 Bcast:172.16.20.127 Mask:255.255.255.192
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:1 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:2 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.12 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:3 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.13 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:4 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:5 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.15 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:6 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.16 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:7 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.17 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:8 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.18 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:9 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.19 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
eth0:10 Link encap:Ethernet HWaddr 08:00:27:BF:CE:97
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xd010 Memory:f0000000-f0020000
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:1539 errors:0 dropped:0 overruns:0 frame:0
TX packets:1539 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2335532 (2.2 MiB) TX bytes:2335532 (2.2 MiB)
[root@localhost network-scripts]#