私の質問を更新します。
Stack Overflowにも同じ質問をしましたが、ここで質問する方が良いです。
最小オペレーティングシステムをインストールした後にワークステーションネットワークを設定するのに問題があります。vi /etc/sysconfig/network-scripts/ifcfg-em1
静的に編集しました。インターネット検索でWebサービスを再起動しました。ただし、まだインターネットやpingに接続できません(除くping 127.0.0.1
)。これが私の設定です。
[root@workstation ~]# uname -a
Linux workstation.XXXXX 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@workstation ~]# ifconfig
em1 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX
inet addr:aaa.bbb.ccc.xxx Bcast:aaa.bbb.211.255 Mask:255.255.252.0
inet6 addr: XXXX::XXXX:XXX:XXXX:XXXX/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12465754 errors:0 dropped:0 overruns:0 frame:0
TX packets:238 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1507354446 (1.4 GiB) TX bytes:35268 (34.4 KiB)
Interrupt:16
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:65536 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1316 (1.2 KiB) TX bytes:1316 (1.2 KiB)
[root@workstation ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
inet aaa.bbb.ccc.xxx/22 brd aaa.bbb.211.255 scope global em1
inet6 XXXX::XXXX:XXXX:XXXX:XXXX/64 scope link
valid_lft forever preferred_lft forever
3: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
[root@workstation ~]# vi /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
HWADDR=54:9F:35:1F:58:D0
TYPE=Ethernet
UUID=7337edf4-f9f0-4dab-9d3d-6f031e7180cc
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=aaa.bbb.ccc.132
NETMASK=255.255.252.0
NAME="System em1"
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
PREFIX=22
GATEWAY=aaa.bbb.156.5
DNS1=aaa.bbb.10.2
DOMAIN=168.126.63.1
[root@workstation ~]# service network restart
Shutting down interface em1: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface em1: Determining if ip address aaa.bbb.208.132 is already in use for device em1...
[ OK ]
[root@workstation ~]# yum list
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os&infra=stock error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot find a valid baseurl for repo: base
[root@workstation ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=workstation.XXXXX
GATEWAY=aaa.bbb.156.5
答えてくれてありがとう。例 @larsks em1 は DHCP ではなく固定 IP です。 ipパスです
[root@workstation ~]# ip route
aaa.bbb.ccc.0/22 dev em1 proto kernel scope link src aaa.bbb.ccc.xxx
169.254.0.0/16 dev em1 scope link metric 1002
これはvi /etc/resolv.conf
[root@workstation ~]# vi /etc/resolv.conf
nameserver aaa.bbb.10.2
search 168.126.63.1
変更しましたが、NETWORK
まだGATEWAY
インターネットに接続できません。
また、助けてくれてありがとう。私は解決策に近いと思います。
答え1
ついに問題を解決しました。
[root@workstation network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
aaa.bbb.ccc.0 0.0.0.0 255.255.252.0 U 0 0 0 em1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 em1
「デフォルトゲートウェイ」はありません。
[root@workstation network-scripts]# ip route add 155.230.156.5 dev em1
[root@workstation network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
aaa.bbb.156.5 0.0.0.0 255.255.255.255 UH 0 0 0 em1
aaa.bbb.ccc.0 0.0.0.0 255.255.252.0 U 0 0 0 em1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 em1
次に、
[root@workstation network-scripts]# route add default gw 155.230.156.5 dev em1
[root@workstation network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
aaa.bbb.156.5 0.0.0.0 255.255.255.255 UH 0 0 0 em1
aaa.bbb.ccc.0 0.0.0.0 255.255.252.0 U 0 0 0 em1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 em1
0.0.0.0 aaa.bbb.156.5 0.0.0.0 UG 0 0 0 em1 ← "default GATEWAY"
接続を確認し、
[root@workstation network-scripts]# ping www.google.co.kr
PING www.google.co.kr (216.58.199.99) 56(84) bytes of data.
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=1 ttl=50 time=82.8 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=2 ttl=50 time=47.2 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=3 ttl=50 time=46.9 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=4 ttl=50 time=47.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=5 ttl=50 time=57.3 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=6 ttl=50 time=47.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=7 ttl=50 time=47.6 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=8 ttl=50 time=47.6 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=9 ttl=50 time=46.9 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=10 ttl=50 time=47.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=11 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=12 ttl=50 time=47.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=13 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=14 ttl=50 time=57.8 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=15 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=16 ttl=50 time=47.4 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=17 ttl=50 time=53.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=18 ttl=50 time=47.6 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=19 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=20 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=21 ttl=50 time=47.0 ms
^C
--- www.google.co.kr ping statistics ---
21 packets transmitted, 21 received, 0% packet loss, time 20694ms
rtt min/avg/max/mdev = 46.961/50.269/82.824/7.940 ms
しかし、私はreboot
または。service network restart
今永久に保存する方法を知りたいです。
私はLinuxネットワーキングについてある程度の知識を持っています。助けてくれてありがとう。