| 235 | |
| 236 | = Ubuntu = |
| 237 | * CentOSとは違い、NICの設定ファイルは一つにまとまっている |
| 238 | * default が複数あるときの挙動については、CentOS同様に不明 |
| 239 | |
| 240 | == interfaces == |
| 241 | * /etc/network/interfaces |
| 242 | {{{ |
| 243 | auto lo |
| 244 | iface lo inet loopback |
| 245 | |
| 246 | auto eth0 |
| 247 | iface eth0 inet static |
| 248 | address 192.168.50.200 |
| 249 | netmask 255.255.255.0 |
| 250 | gateway 192.168.50.1 |
| 251 | |
| 252 | auto eth1 |
| 253 | iface eth1 inet static |
| 254 | address 192.168.60.200 |
| 255 | netmask 255.255.255.0 |
| 256 | gateway 192.168.60.100 |
| 257 | |
| 258 | auto eth2 |
| 259 | iface eth2 inet static |
| 260 | address 192.168.70.200 |
| 261 | netmask 255.255.255.0 |
| 262 | gateway 192.168.70.100 |
| 263 | |
| 264 | auto eth3 |
| 265 | iface eth3 inet static |
| 266 | address 192.168.40.200 |
| 267 | netmask 255.255.255.0 |
| 268 | gateway 192.168.40.1 |
| 269 | }}} |
| 270 | * route |
| 271 | {{{ |
| 272 | Kernel IP routing table |
| 273 | Destination Gateway Genmask Flags Metric Ref Use Iface |
| 274 | 192.168.70.0 * 255.255.255.0 U 0 0 0 eth2 |
| 275 | 192.168.50.0 * 255.255.255.0 U 0 0 0 eth0 |
| 276 | 192.168.60.0 * 255.255.255.0 U 0 0 0 eth1 |
| 277 | 192.168.40.0 * 255.255.255.0 U 0 0 0 eth3 |
| 278 | default 192.168.40.1 0.0.0.0 UG 100 0 0 eth3 |
| 279 | default 192.168.70.100 0.0.0.0 UG 100 0 0 eth2 |
| 280 | default 192.168.60.100 0.0.0.0 UG 100 0 0 eth1 |
| 281 | default 192.168.50.1 0.0.0.0 UG 100 0 0 eth0 |
| 282 | }}} |
| 283 | |
| 284 | * ping 219.94.129.108 -c1 |
| 285 | {{{ |
| 286 | listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes |
| 287 | 07:56:54.264373 IP 192.168.50.200 > 219.94.129.108: ICMP echo request, id 12822, seq 1, length 64 |
| 288 | 07:56:54.284695 IP 219.94.129.108 > 192.168.50.200: ICMP echo reply, id 12822, seq 1, length 64 |
| 289 | }}} |
| 290 | |
| 291 | |
| 292 | |
| 293 | 1. sudo ifdown eth2; sudo ifup eth2 |
| 294 | * route |
| 295 | {{{ |
| 296 | default 192.168.70.100 0.0.0.0 UG 100 0 0 eth2 |
| 297 | default 192.168.40.1 0.0.0.0 UG 100 0 0 eth3 |
| 298 | default 192.168.60.100 0.0.0.0 UG 100 0 0 eth1 |
| 299 | default 192.168.50.1 0.0.0.0 UG 100 0 0 eth0 |
| 300 | }}} |
| 301 | 1. sudo ifdown eth1; sudo ifup eth1 |
| 302 | * route |
| 303 | {{{ |
| 304 | default 192.168.60.100 0.0.0.0 UG 100 0 0 eth1 |
| 305 | default 192.168.70.100 0.0.0.0 UG 100 0 0 eth2 |
| 306 | default 192.168.40.1 0.0.0.0 UG 100 0 0 eth3 |
| 307 | default 192.168.50.1 0.0.0.0 UG 100 0 0 eth0 |
| 308 | }}} |
| 309 | * ping 219.94.129.108 -c1 |
| 310 | {{{ |
| 311 | 08:01:24.453913 IP 192.168.50.200 > 219.94.129.108: ICMP echo request, id 42262, seq 1, length 64 |
| 312 | 08:01:24.475447 IP 219.94.129.108 > 192.168.50.200: ICMP echo reply, id 42262, seq 1, length 64 |
| 313 | }}} |
| 314 | 1. sudo ifdown eth0; sudo ifup eth0 |
| 315 | * route |
| 316 | {{{ |
| 317 | default 192.168.50.1 0.0.0.0 UG 100 0 0 eth0 |
| 318 | default 192.168.60.100 0.0.0.0 UG 100 0 0 eth1 |
| 319 | default 192.168.70.100 0.0.0.0 UG 100 0 0 eth2 |
| 320 | default 192.168.40.1 0.0.0.0 UG 100 0 0 eth3 |
| 321 | }}} |
| 322 | * ping 219.94.129.108 -c1 |
| 323 | {{{ |
| 324 | 08:02:22.346792 IP 192.168.50.200 > 219.94.129.108: ICMP echo request, id 56854, seq 1, length 64 |
| 325 | 08:02:22.368070 IP 219.94.129.108 > 192.168.50.200: ICMP echo reply, id 56854, seq 1, length 64 |
| 326 | }}} |
| 327 | |
| 328 | == route コマンド == |
| 329 | * ifup コマンドとは別に保存される |
| 330 | 1. sudo route add default gw 192.168.40.1 |
| 331 | 1. sudo route add default gw 192.168.50.1 |
| 332 | 1. sudo route add default gw 192.168.60.100 |
| 333 | 1. sudo ifdown eth2; sudo ifup eth2 |
| 334 | 1. sudo ifdown eth0; sudo ifup eth0 |
| 335 | * route |
| 336 | {{{ |
| 337 | Kernel IP routing table |
| 338 | Destination Gateway Genmask Flags Metric Ref Use Iface |
| 339 | 192.168.70.0 * 255.255.255.0 U 0 0 0 eth2 |
| 340 | 192.168.50.0 * 255.255.255.0 U 0 0 0 eth0 |
| 341 | 192.168.60.0 * 255.255.255.0 U 0 0 0 eth1 |
| 342 | 192.168.40.0 * 255.255.255.0 U 0 0 0 eth3 |
| 343 | default 192.168.60.100 0.0.0.0 UG 0 0 0 eth1 |
| 344 | default 192.168.50.1 0.0.0.0 UG 0 0 0 eth0 |
| 345 | default 192.168.40.1 0.0.0.0 UG 0 0 0 eth3 |
| 346 | default 192.168.50.1 0.0.0.0 UG 100 0 0 eth0 |
| 347 | default 192.168.70.100 0.0.0.0 UG 100 0 0 eth2 |
| 348 | }}} |
| 349 | * ping 219.94.129.108 -c1 |
| 350 | {{{ |
| 351 | 08:35:41.384666 IP 192.168.50.200 > 219.94.129.108: ICMP echo request, id 39704, seq 1, length 64 |
| 352 | }}} |
| 353 | * 更にifdown/ifupするとdefault routeも追加される |
| 354 | 1. sudo ifdown eth1; sudo ifup eth1 |
| 355 | {{{ |
| 356 | default 192.168.60.100 0.0.0.0 UG 0 0 0 eth1 |
| 357 | default 192.168.50.1 0.0.0.0 UG 0 0 0 eth0 |
| 358 | default 192.168.40.1 0.0.0.0 UG 0 0 0 eth3 |
| 359 | default 192.168.60.100 0.0.0.0 UG 100 0 0 eth1 |
| 360 | default 192.168.50.1 0.0.0.0 UG 100 0 0 eth0 |
| 361 | default 192.168.70.100 0.0.0.0 UG 100 0 0 eth2 |
| 362 | }}} |
| 363 | * しかし、実際にパケットが通るのはeth0のまま |
| 364 | * ping 219.94.129.108 -c1 |
| 365 | {{{ |
| 366 | 08:37:52.757894 IP 192.168.50.200 > 219.94.129.108: ICMP echo request, id 52248, seq 1, length 64 |
| 367 | }}} |