Ubuntu | 固定IPアドレスを設定する。
「/etc/network/interfaces」を編集。
sudo gedit /etc/network/interfaces
auto lo iface lo inet loopback
↓下記のように設定。
auto eth1 iface eth1 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1
項目 | 名前 | 意味 |
---|---|---|
address | IPアドレス | 一般家庭の場合192.168.1.XXXが多い |
netmask | ネットマスク | 通常は255.255.255.0でOK |
gateway | デフォルトゲートウェイ | ルーターのIPアドレス、192.168.1.1が多い |
ネットワークサービスの再起動
sudo /etc/init.d/networking restart
ネットワークに参加できているかをテスト
ifconfig(windowsのipconfigと似た動きをします)
ifconfig
eth1 Link encap:イーサネット ハードウェアアドレス 00:0c:29:b3:1e:71 inetアドレス:192.168.1.24 ブロードキャスト:192.168.1.255 マスク:255.255.255.0 inet6アドレス: fe80::20c:29ff:feb3:1e71/64 範囲:リンク UP BROADCAST RUNNING MULTICAST MTU:1500 メトリック:1 RXパケット:13 エラー:0 損失:0 オーバラン:0 フレーム:0 TXパケット:50 エラー:0 損失:0 オーバラン:0 キャリア:0 衝突(Collisions):0 TXキュー長:1000 RXバイト:1869 (1.8 KB) TXバイト:6510 (6.3 KB) 割り込み:17 ベースアドレス:0x1400 lo Link encap:ローカルループバック inetアドレス:127.0.0.1 マスク:255.0.0.0 inet6アドレス: ::1/128 範囲:ホスト UP LOOPBACK RUNNING MTU:16436 メトリック:1 RXパケット:682 エラー:0 損失:0 オーバラン:0 フレーム:0 TXパケット:682 エラー:0 損失:0 オーバラン:0 キャリア:0 衝突(Collisions):0 TXキュー長:0 RXバイト:34100 (33.3 KB) TXバイト:34100 (33.3 KB)
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=2.20 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.27 ms 64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=3.03 ms --- 192.168.1.1 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2000ms rtt min/avg/max/mdev = 1.277/2.171/3.038/0.721 ms