Created
October 21, 2013 05:03
-
-
Save vunb/7078902 to your computer and use it in GitHub Desktop.
Cấu hình Centos sử dụng 2 gateway và đi ra ngoài mạng
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Sao chép cấu hình interface theo thứ tự, ifcfg-eth0:0 | |
[root@Manlab network-scripts]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0 | |
2. cấu hình các tham số cấu hình file ifcfg-eth0:0 phù hợp với mong muốn | |
- NAME | |
- DEVICE | |
- IPADDR | |
- GATEWAY | |
- DNS1/DNS2 | |
3. Restart lại service network là ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@Manlab network-scripts]# ifconfig | |
eth0 Link encap:Ethernet HWaddr 00:1E:EC:E9:54:F5 | |
inet addr:10.2.4.58 Bcast:10.2.4.255 Mask:255.255.255.0 | |
inet6 addr: fe80::21e:ecff:fee9:54f5/64 Scope:Link | |
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 | |
RX packets:261828 errors:0 dropped:0 overruns:0 frame:0 | |
TX packets:120428 errors:0 dropped:0 overruns:0 carrier:0 | |
collisions:0 txqueuelen:1000 | |
RX bytes:267908235 (255.4 MiB) TX bytes:18202613 (17.3 MiB) | |
eth0:0 Link encap:Ethernet HWaddr 00:1E:EC:E9:54:F5 | |
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.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:10005 errors:0 dropped:0 overruns:0 frame:0 | |
TX packets:10005 errors:0 dropped:0 overruns:0 carrier:0 | |
collisions:0 txqueuelen:0 | |
RX bytes:1088071 (1.0 MiB) TX bytes:1088071 (1.0 MiB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@Manlab network-scripts]# more ifcfg-eth0 | |
TYPE=Ethernet | |
BOOTPROTO=none | |
DEFROUTE=yes | |
IPV4_FAILURE_FATAL=yes | |
IPV6INIT=no | |
NAME="eth0" | |
UUID=62531160-5cdf-4ae9-9d32-c272cc45d49c | |
ONBOOT=yes | |
HWADDR=00:1E:EC:E9:54:F5 | |
PEERROUTES=yes | |
LAST_CONNECT=1381225046 | |
IPADDR=10.2.4.58 | |
NETMASK=255.255.255.0 | |
GATEWAY=10.2.4.1 | |
DEVICE=eth0 | |
USERCTL=no | |
DNS1=8.8.8.8 | |
DNS2=8.8.4.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@Manlab network-scripts]# more ifcfg-eth0:0 | |
TYPE=Ethernet | |
BOOTPROTO=none | |
DEFROUTE=yes | |
IPV4_FAILURE_FATAL=yes | |
IPV6INIT=no | |
NAME="eth0:0" | |
UUID=62531160-5cdf-4ae9-9d32-c272cc45d49c | |
ONBOOT=yes | |
HWADDR=00:1E:EC:E9:54:F5 | |
PEERROUTES=yes | |
LAST_CONNECT=1381225046 | |
IPADDR=192.168.1.100 | |
NETMASK=255.255.255.0 | |
GATEWAY=192.168.1.1 | |
DEVICE=eth0:0 | |
USERCTL=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@Manlab network-scripts]# ping google.com | |
PING google.com (113.171.244.251) 56(84) bytes of data. | |
64 bytes from localhost (113.171.244.251): icmp_seq=1 ttl=57 time=6.88 ms | |
64 bytes from localhost (113.171.244.251): icmp_seq=2 ttl=57 time=7.02 ms | |
^C | |
--- google.com ping statistics --- | |
2 packets transmitted, 2 received, 0% packet loss, time 1692ms | |
rtt min/avg/max/mdev = 6.885/6.956/7.028/0.109 ms | |
[root@Manlab network-scripts]# ^C | |
[root@Manlab network-scripts]# ping 192.168.1.1 | |
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. | |
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.43 ms | |
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.347 ms | |
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.317 ms | |
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.333 ms | |
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.414 ms | |
^C | |
--- 192.168.1.1 ping statistics --- | |
5 packets transmitted, 5 received, 0% packet loss, time 4789ms | |
rtt min/avg/max/mdev = 0.317/0.568/1.432/0.433 ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@Manlab network-scripts]# route -n | |
Kernel IP routing table | |
Destination Gateway Genmask Flags Metric Ref Use Iface | |
10.2.4.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 | |
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 | |
0.0.0.0 10.2.4.1 0.0.0.0 UG 0 0 0 eth0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@Manlab network-scripts]# service network restart | |
Shutting down interface eth0: [ OK ] | |
Shutting down loopback interface: [ OK ] | |
Bringing up loopback interface: [ OK ] | |
Bringing up interface eth0: Active connection state: activated | |
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/40 | |
[ OK ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment