Home network windows and linux

How to setup a network between a windows computer and a linux computer?

I connected my Windows computer to my Linux computer with an Ethernet cable. The problem is that the Linux interface enp5s0 doesn’t acquire an IP and when I try to ping the Windows computer it says network unreachable. I have tried systemctl start dhcpcd@enp5s0.service but it fails to start with

Which should be normal, but then how do I set an IP for the Linux machine in this network of two? And how do I enable the Linux machine to ping and download files from the Windows machine?

wiki.archlinux.org/index.php/… shows you how to setup a static IP. You may want to set up Samba for file sharing.

are you sure you are either a cross-over cable between your two computers or at least one of the network interfaces have signal auto-sensing capability ?

@MelBurslan: Fortunately, many Ethernet adapters from the last decade support both types of cables so hopefully one of them supports it.

Sorry to contradict you @RuiFRibeiro, but I’ve seen 100mbps adapters that support both cables 12 years ago.

1 Answer 1

In order to acquire an IP adress on the Linux machine using the DHCP method you have to install an DHCP-Server on the Windows machine first and configure it.

I assume that is not really what you want. In order to exchange network packages between both hosts you have to assure that both hosts are on the same network. In this hardware setting the best way to do so is to manually set up static network configurations on both hosts.

Configuration on the Windows (7?) machine:

When the cable is connected via ethernet your networking notifier in the windows task bar should show a wired connection symbol (or a spinning circle notifying you it is trying to automatically get an IP via DHCP).

Читайте также:  Kali linux virtualbox wifi адаптер

Click on the symbol and then open the network and sharing center. On the right hand side of the upcoming window you should see something like an underlined «LAN-connection 1». Click on it an then go to «Properties». In the upcoming list mark «Internet Protocol Version 4 (TCP/IPv4)» and then again click on «Properties». Now check «Use the following IP-Adresses» (or something like that — I only have the german version of Windows on my screen and can’t tell what the exact english translation is). Now type in the following fields:

  • IP-adress: 10.0.0.1
  • subnet mask: 255.255.255.0
  • gateway: 10.0.0.2 (does not matter as there is no way out of your small two host network. Using the following configuration steps, your Linux host will be the gateway host)

Configuration on the Linux machine (Debian/Ubuntu):

Open up a terminal window and do the following commands (as superuser):

ifconfig enp5s0 up ifconfig enp5s0 10.0.0.2 ifconfig enp5s0 netmask 255.255.255.0 

You have now set up a small network containing the two hosts with the Linux machine being the gateway host (when the Linux host has a second interface connected to an WAN and the forwarding is set up properly then it can act as a «real» internet-gateway for the windows machine).

Verify the setup using the ping command on the both hosts (the terminal can be used on both OSes to do so).

And both should consecutively show up successfully issued ping packets.

Источник

How to join a Windows network with your Linux device

The network used for this tutorial does not assign IP automatically by using DHCP, we’ll assign everything manually. In this tutorial I assume your Linux device is a Debian or Ubuntu based distribution, it may be useful for other distributions too but some commands may be different, for example when restarting services like Samba.

The first step is to remove all previous data belonging to old connections or networks by executing the command “dhclient -r

Читайте также:  Practical guide to linux commands editors and shell programming

Where “dhclient” makes mention to the dhcp client and “-r” is similar to the “release” used in Windows (ipconfig /release) .

Next we need to learn what network device will interact with the network by running “ifconfig”, similar to the Windows command “ipconfig”, in this case the wired network device is “enp2s0” as shown in the screenshot below.

Then we’ll check information on the network from a Windows workstation by running the equivalent command “ipconfig” to see the IP range and gateway address.

We can see the network device has assigned two IP addressed, in this case I know one IP address (10.100.100.141) is limited by a switch to a little portion of the network without internet access while the second (172.31.124.141) has total access. I apologize but the network belongs to a Latin American company and all workstation are in Spanish. Where “Direcciòn” means “address” and “Puerta de enlace determinada” means “gateway”.

From the Windows workstation we’ll ping IP addresses belonging to the same range in order to get an unassigned, or free IP to assign our device (remember within a network IP addresses can’t be repeated, and each device must an unique address). In this case I did ping to the IP 172.31.124.142 and it was unresponsive, therefore it was free.

The next step is to assign to our Linux device it’s own IP and enroute it through the proper gateway by executing “ifconfig enp2s0 X.X.X.X” to assign the IP address and “route add default gw X.X.X.X¨ to determine the gateway.

Remember to replace “X.X.X.X” for the proper addresses according to your Windows network information as shown in the following image.

Then we need to edit the file /etc/resolv.conf which stores the DNS addresses (Domain Name Server) to add Domain Name Servers capable to translate domain names like www.linuxhint.com to IP address. To edit the file we’ll use the text editor Nano by running “nano /etc/resolv.conf

Читайте также:  Разновидности linux операционных систем

We’ll use Google’s Domain Name Server 8.8.8.8, you can use the same DNS for your network if you are looking for Internet access too.

After editing the file we’ll save it by pressing CTRL+X and confirm by pressing Y.

Next we’ll test our internet access by pinging an internet address like google.com

If we want more than internet access and need to interact with other devices within the same network we need to install Samba, a service which allows us to interact with Windows services.

After Samba was installed we’ll need to add the Workgroup, in this tutorial I assume you know to use Windows graphically, you can check the Workgroup by pressing on “This Computer” with a right click and then checking the Properties. In this case the Workgroup is “Modernizacion”, we’ll edit our Samba configuration file stored at /etc/samba by using Nano again:


We’ll see the same file shown below, and among the first uncommented lines the parameter “workgroup”, the one we need to edit in order to add our device to the Windows workgroup.

Again to save the file press CTRL+X and then Y when asked if you want to save it.

After making changes on samba´s configuration file we’ll need to restart the service to apply the changes by running “/etc/init.d/smbd restart

Now we can check with our file manager new locations and printers belonging to the network.

Adding a Linux device to a Windows network is really easy, it may even be easier than in this tutorial if the network assigned IP addresses automatically with the DHCP server.

I hope this tutorial was helpful. Have a great day and keep enjoying by reading LinuxHint.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.

Источник

Оцените статью
Adblock
detector