| | 1 | [[PageOutline]] |
| | 2 | |
| | 3 | = default gateway = |
| | 4 | * default gateway (default route)の変更方法・扱い |
| | 5 | |
| | 6 | = 複数設定されているとき = |
| | 7 | == CentOS == |
| | 8 | === ifcfg-eth? === |
| | 9 | * ifcfg-eth? に書いた場合 |
| | 10 | |
| | 11 | * /etc/sysconfig/network-scripts/ifcfg-eth0 |
| | 12 | {{{ |
| | 13 | DEVICE=eth0 |
| | 14 | BOOTPROTO=static |
| | 15 | IPADDR=192.168.40.200 |
| | 16 | NETMASK=255.255.255.0 |
| | 17 | GATEWAY=192.168.40.1 |
| | 18 | ONBOOT=yes |
| | 19 | }}} |
| | 20 | * /etc/sysconfig/network-scripts/ifcfg-eth1 |
| | 21 | {{{ |
| | 22 | DEVICE=eth1 |
| | 23 | BOOTPROTO=static |
| | 24 | IPADDR=192.168.50.200 |
| | 25 | NETMASK=255.255.255.0 |
| | 26 | GATEWAY=192.168.50.1 |
| | 27 | ONBOOT=yes |
| | 28 | }}} |
| | 29 | * service network restart |
| | 30 | {{{ |
| | 31 | Bringing up interface eth0: [ OK ] |
| | 32 | Bringing up interface eth1: [ OK ] |
| | 33 | }}} |
| | 34 | * 結果 => route |
| | 35 | {{{ |
| | 36 | Kernel IP routing table |
| | 37 | Destination Gateway Genmask Flags Metric Ref Use Iface |
| | 38 | 192.168.50.0 * 255.255.255.0 U 0 0 0 eth1 |
| | 39 | 192.168.40.0 * 255.255.255.0 U 0 0 0 eth0 |
| | 40 | 169.254.0.0 * 255.255.0.0 U 0 0 0 eth1 |
| | 41 | default 192.168.50.1 0.0.0.0 UG 0 0 0 eth1 |
| | 42 | }}} |
| | 43 | * この状態で、実際にWANへpingを送るとeth1を通る |
| | 44 | * tcpdump icmp -n -i eth1 |
| | 45 | {{{ |
| | 46 | listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes |
| | 47 | 01:32:42.314543 IP 192.168.50.200 > 219.94.129.108: ICMP echo request, id 16947, seq 1, length 64 |
| | 48 | 01:32:42.330849 IP 219.94.129.108 > 192.168.50.200: ICMP echo reply, id 16947, seq 1, length 64 |
| | 49 | }}} |
| | 50 | |
| | 51 | * eth0とeth1を逆にしてみる |
| | 52 | * eth0 |
| | 53 | {{{ |
| | 54 | IPADDR=192.168.50.200 |
| | 55 | NETMASK=255.255.255.0 |
| | 56 | GATEWAY=192.168.50.1 |
| | 57 | }}} |
| | 58 | * eth1 |
| | 59 | {{{ |
| | 60 | IPADDR=192.168.40.200 |
| | 61 | NETMASK=255.255.255.0 |
| | 62 | GATEWAY=192.168.40.1 |
| | 63 | }}} |
| | 64 | * service network restart |
| | 65 | {{{ |
| | 66 | Bringing up interface eth0: [ OK ] |
| | 67 | Bringing up interface eth1: [ OK ] |
| | 68 | }}} |
| | 69 | * 結果 => route |
| | 70 | {{{ |
| | 71 | Kernel IP routing table |
| | 72 | Destination Gateway Genmask Flags Metric Ref Use Iface |
| | 73 | 192.168.50.0 * 255.255.255.0 U 0 0 0 eth0 |
| | 74 | 192.168.40.0 * 255.255.255.0 U 0 0 0 eth1 |
| | 75 | 169.254.0.0 * 255.255.0.0 U 0 0 0 eth1 |
| | 76 | default 192.168.40.1 0.0.0.0 UG 0 0 0 eth1 |
| | 77 | }}} |
| | 78 | * 今度もeth1を通る |
| | 79 | * tcpdump icmp -n -i eth1 |
| | 80 | {{{ |
| | 81 | listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes |
| | 82 | 01:39:05.380029 IP 192.168.40.200 > 219.94.129.108: ICMP echo request, id 26423, seq 1, length 64 |
| | 83 | 01:39:05.392541 IP 219.94.129.108 > 192.168.40.200: ICMP echo reply, id 26423, seq 1, length 64 |
| | 84 | }}} |
| | 85 | |
| | 86 | * LinkUPの順番を変える |
| | 87 | * ifup eth1; ifup eth0 |
| | 88 | {{{ |
| | 89 | Kernel IP routing table |
| | 90 | Destination Gateway Genmask Flags Metric Ref Use Iface |
| | 91 | 192.168.50.0 * 255.255.255.0 U 0 0 0 eth0 |
| | 92 | 192.168.40.0 * 255.255.255.0 U 0 0 0 eth1 |
| | 93 | 169.254.0.0 * 255.255.0.0 U 0 0 0 eth0 |
| | 94 | default 192.168.50.1 0.0.0.0 UG 0 0 0 eth0 |
| | 95 | }}} |
| | 96 | * tcpdump icmp -n -i eth0 |
| | 97 | {{{ |
| | 98 | listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes |
| | 99 | 01:42:55.952191 IP 192.168.50.200 > 219.94.129.108: ICMP echo request, id 52536, seq 1, length 64 |
| | 100 | 01:42:55.965580 IP 219.94.129.108 > 192.168.50.200: ICMP echo reply, id 52536, seq 1, length 64 |
| | 101 | }}} |
| | 102 | |
| | 103 | ==== 結論 ==== |
| | 104 | * 最後にLinkUPしたデバイスのgatewayが有効になる |