Ubuntu(桌面+服务器)16.04:添加以太网(LAN)
情况:
我有一台PC和一台服务器(不是虚拟机)。 我对配置硬件完全陌生。 我需要使用LAN电缆设置以太网。 以太网电缆直接从PC连接到服务器(不带以太网交换机)。
电脑资讯:
Operating system:
Ubuntu Desktop 16.04.4
Architecture:
64位(AMD64)
Connected to the Internet (wi-fi):
是(Wi-Fi)
Network interfaces ($ ipconfig -a):
enp4s0 Link encap:Ethernet HWaddr 90:2b:34:18:80:37 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) 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:3872 errors:0 dropped:0 overruns:0 frame:0 TX packets:3872 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:283996 (283.9 KB) TX bytes:283996 (283.9 KB)
Network card ($ lspci | egrep -i --color 'network|ethernet'):
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
服务器信息:
Model:
HP ProLiant DL580 G7 ( 全手册 )
Operating system:
Ubuntu Server 16.04.4
Architecture:
64位(AMD64)
Connected to the Internet (wi-fi):
没有
问题:
如何在服务器和PC之间设置以太网?
我的服务器上的规格是否有任何特定问题?
谢谢您的帮助
您需要静态为两台计算机分配IP地址。
PC:192.168.10.1 255.255.255.0
服务器:192.168.10.2 255.255.255.0
对于头部Ubuntu服务器网络配置,您将需要编辑/ etc / network / interfaces 这里有用的文章服务器的示例配置:
# The primary network interface auto enp4s0 iface enp4s0 inet static address 192.168.10.2 netmask 255.255.255.0 network 192.168.10.0 broadcast 192.168.10.255
您将无法使用此配置的互联网,因为需要通过您的PC配置路由。
此外,不太可能,但可能需要交叉电缆,因为您要将设备转到设备,尽管大多数现代NIC都会自动处理此问题。
注意:您可以使用CIDR 192.168.10.0/30限制地址范围,仅允许两个设备。
来自Bennett
回答:
要使用本地网络(以太网)连接两台计算机,您需要:
1.将LAN电缆连接到server
和personal computer
2.将网络接口添加到server
:
在终端中运行sudo nano /etc/network/interfaces
。
将此代码段添加到文件中:
# My Ethernet interface auto enp4s0f0 iface enp4s0f0 inet static address 192.168.10.2 netmask 255.255.255.0 network 192.168.10.0 broadcast 192.168.10.255
使用Ctrl + X
快捷方式保存文件。
在终端中运行sudo reboot
以设置新配置。
3.将网络接口添加到personal computer
:
在终端中运行sudo nano /etc/network/interfaces
。
将此代码段添加到文件中:
# My Ethernet interface auto enp4s0 iface enp4s0 inet static address 192.168.10.1 netmask 255.255.255.0 network 192.168.10.0 broadcast 192.168.10.255
使用Ctrl + X
快捷方式保存文件。
在终端中运行sudo reboot
以设置新配置。
祝贺你! 设置server
和personal computer
之间的以太网连接
PS:
请注意,您需要自己配置接口的代码段。 这是一个模板:
# My Ethernet interface auto iface inet static address netmask network broadcast
哪里:
:
名称(运行ifconfig -a
获取接口列表)
:接口的IPv4地址(模板: ip1.ip2.ip3.ip4
)
:接口的网络掩码(通常为255.255.255.0
)
:接口网络的IPv4地址( ip1.ip2.ip3.0
)
:接口广播的IPv4地址( ip1.ip2.ip3.255
)