Menu
Samba is a useful service found in most Unix and Linux system that allows you to share file and print services with another computer, particularly a Microsoft Windows client. In Ubuntu, while the Nautiilus File Manager comes with a series of connection protocols to access files from a remote server, it doesn’t turn the machine into a file server and accept connection from other PC. Samba is the one that does the job. In this tutorial, we will show you how to install and configure Samba so you can turn your Ubuntu PC into a file server.
Installing Samba
Samba is not installed by default. Open a terminal and type the following command:
Alternatively, you can install Samba via the Ubuntu Software Center.
Configuring Samba
To get Samba to work the way we want it to work, we have to make some changes to its configuration file.
In the terminal,
This will open the config file in Gedit.
Scroll down the page until you see the line:
This is the identifier of your PC. You can keep it as the default, but it is best to change it to something more meaningful, like “HOME-DESKTOP”.
Next, scroll down further till you reach the “Authentication” section. You should see the line:
Remove the “#” at the front of the line.
Continue to scroll down further until you reach the “Share Definitions” section. This is where you configure the files/folders that you want to share with others.
If you want the Home folder to be accessible, you should uncomment (remove the “;” at the front of the line) the following lines:
Don’t forget to change the
browseable value to “yes”. You can also uncomment the read only = no line if you allow others to write to your Home folder.
The last line
valid users = %S means that only you, or anyone with your login account, can connect to your own Home folder via Samba.
To add additional file sharing path, add the following lines to the end of the file:
Change the name of this share configuration and change the path to the folder you want to share.
You can change the “guest ok=yes” line to “guest ok=no” if you want the share path only available for logged in users.
Lastly, save and exit the file.
Setting Samba user password
To add yourself to the Samba user list, you just have to type the following command:
Replace <username> with your username. It will then prompt you to set a password for this Samba account.
Alternatively, you can also create a new user account and add this user to the Samba user list
To create a user account, use the following command:
Restart Samba services
That’s it. You should be able to connect to this PC from another PC.
More Samba Tips
If you are looking for an easier way to configure the Samba settings, you can install “Samba Server Configuration” GUI.
On your Nautilus File Manager, you can also right-click on any folder and select the Sharing Options to enable sharing.
Enjoy!
EbooksOn this page
This tutorial explains how to set a static IP on an Ubuntu system from the command line. It covers the network configuration for all recent Ubuntu versions and includes instructions to configure a static IP address, set the hostname and configure name resolving.
Network configuration on Ubuntu 17.10 and Ubuntu 18.04 LTS
The network configuration has been changed completely with Ubuntu 17.10. A new tool named Netplan has been introduced by Canonical (the company that develops the Ubuntu Linux distribution) for network setting management which will be used in all new Ubuntu versions starting with the 17.10 release. The former network configuration file /etc/network/interfaces is not used anymore.
Configure a Static IP Address with Netplan on Ubuntu
Compattelrunner.exe microsoft compatibility telemetry. Here the steps to configure a static IP address with Netplan. The Netplan configuration files are located in the directory /etc/netplan/. The default configuration file is /etc/netplan/01-netcfg.yaml.
Open the network config file with an editor:
The configuration syntax is in Python programming language (.yaml format), so the indentation of the lines is important!
Here is an example of a static IPv4 address 192.168.1.100 on the first network interface ens33 and gateway IP 192.168.1.1. The server will use the free Google DNS servers 8.8.8.8 and 8.8.4.4 to for name resolving.
Or as Screenshot from an Ubuntu 18.04 LTS server:
An IPv6 address can be added in the addresses line, separated by a comma. Example:
It is important that you wrap the IPv6 address into single quotes, you will get a syntax error otherwise.
To apply the changes, run:
Or use it with the --debug switch to get some useful output if parsing of the netplan config file was successful.
Configure a DHCP address with Netplan
Here is the configuration to get the network configuration for IPv4 and IPv6 from a DHCP server.
To apply the changes, run:
More Netplan config options
Netplan is a complex new configuration system to configure network cards, virtual devices, VLANs and bridges in Ubuntu 18.04. For more examples and an in-depth explanation of the syntax, see the man page.
Network configuration on Ubuntu 12.04 - 17.04 (incl. Ubuntu 16.04 LTS)Step 1: Configure the network interface
In this step, you will manually configure your network interface by editing the following files using your preferred text editor(nano gedit vi). For the purpose of this example, I'm using the 'nano' editor. You can edit the appropriate file by entering the following command into the terminal:
You can copy and paste directly from this line.
Enter your root password, once your preferred editor opens the file you can see this on older Ubuntu versions:
Ubuntu Systems with systemd (like Ubuntu 16.04 and newer), the network interface is named ens33 instead of eth0 now and the word 'dynamic' has been replaced with 'dhcp'.
A configuration where the IP address get's assigned automatically by DHCP will look like this:
Statically configured network cards will have a section like this on older Ubuntu versions:
Here is an example for an older Ubuntu Release:
And here an example for Ubuntu 16.04 and newer:
And here the complete network configuration file from an Ubuntu 16.04 system.
If you use 'nano' editor to edit the configuration file, type Ctrl+x to save changes.
Save modified buffer (ANSWERING 'No' WILL DESTROY CHANGES) ?
<---Type 'y'
File Name to Write: interfaces
<---ENTER
Step 2: Configure the DNS servers
Changes in /etc/resolv.conf are required only on Systems with Ubuntu < 14.04, for newer Ubuntu versions the nameservers get configured in the /etc/network/interfaces file.
a) Ubuntu versions < 14.04
In this step, you will manually configure your dns configuration file.
Once your editor opens the file you want to enter the following information..
If you use 'nano' editor, type Ctrl+x to save changes.
Save modified buffer (ANSWERING 'No' WILL DESTROY CHANGES) ?
<---Type 'y'
File Name to Write: resolv.conf
<---ENTER
Here is an example:
b) Ubuntu versions 14.04 and newer
Open the /etc/network/interfaces file again and add a line dns-nameservers 8.8.8.8 right after the gateway line.
The nameservers 8.8.8.8 and 8.8.4.4 are provided by Google for public use, so you can use them in your network configuration. Fortimail uri click protection.
If you use 'nano' editor, type Ctrl+x to save changes.
Save modified buffer (ANSWERING 'No' WILL DESTROY CHANGES) ?
<---Type 'y'
File Name to Write: interfaces
<---ENTER
Step 3: Restart networking
Manually restart your network interface with the new settings.
For Ubuntu < 14.04 use the networking init script:
This should return a result that looks like the following:
For Ubuntu versions 14.04 and newer use systemctl instead:
At this point you can check if the settings are correct:
If everything is correct you will get this result.
Configure the Hostname
The hostname of an Ubuntu Server or Desktop is being configured in the files /etc/hostname and /etc/hosts. The /etc/hostname file sets the actual system hostname while /etc/hosts is used for the local name resolution.
In this example, I will change the hostname of my system to obelix.example.com.
First, edit the /etc/hostname file
The hostname file contains the local part of the hostname only. The local part here is 'obelix'. Change the content of the /etc/hostname file to:
and save the file. The hostname file as it looks in nano after editing:
Then open the /etc/hosts file with an editor:
and change the line that starts with the IP address of the system like this:
Here a screenshot of the hosts file.
The format is like this:
[IP Addesss] [full hostname incl. domain] [local part of the hostname]
Finally, restart the system to apply the hostname change.
IntroductionIf you are having two network interface cards or some other component that connects you to the internet along with a network interface card installed in your ubuntu system, it can be transformed into an immensely powerful router. You can establish basic NAT (Network Address Translation), activate port forwarding, form a proxy, and prioritize traffic observed by your system so that your downloading stuff do not intervene with gaming. This article will explicate setting up your ubuntu system as a router which can later be configured as a firewall with prior knowledge of 'IPTables'. The resulting setup will help you to control traffic over ports and make your system less vulnerable to security breaches.Gateway SetupPre-requisites:
Host A (192.168.1.8) ⇐⇒ Eth1 ⇐⇒ Ubuntu Gateway ⇐⇒ Eth0 ⇐⇒ Host B (10.10.6.205) In summary:
Configuring Network Interface CardsEach network interface has to be assigned with a static IP address. The method of allocating static IP addresses to the interfaces differs for desktop edition and server edition of Ubuntu. Both the methods are elaborated below.For Ubuntu- Desktop edition: Config Route File Ubuntu VersionSystem Settings ⇒ Network ⇒ Select Interface ⇒ OptionsNetwork Config File UbuntuFor Ubuntu- Server edition: 1. Open Terminal (Ctrl+Alt+T) 2. Enter following command to edit 'interfaces' file: sudo vim /etc/network/interfaces 3. Edit the file with the following lines: auto lo iface lo inet loopback Mysql Config File Ubuntuauto eth0iface eth0 inet static address 10.10.6.203 netmask 255.255.255.0 gateway 10.10.6.203 auto eth1 iface eth1 inet static address 10.10.6.204 netmask 255.255.255.0 gateway 10.10.6.2 Enable IP forwardingConfigure the Ubuntu system so as to initiate routing between two interfaces by enabling IP forwarding: sudo sh -c “echo 1 /proc/sys/net/ipv4/ip forward’’ Edit /etc/sysctl.conf, and (up to 10.04) add these lines: net.ipv4.conf.default.forwarding=1 net.ipv4.conf.all.forwarding=1 From 10.10 onwards, it is sufficient to edit /etc/sysctl.conf and uncomment: # net.ipv4.ip forward=1 so that it reads: net.ipv4.ip forward=1 IP MasqueradingTo enable IP masquerading, enter following set of commands in terminal:sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE sudo iptables -A FORWARD -i eth1 -o eth0 -m state -–state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
Do not forget to save these IPTables rules. Unless they are saved, they will be lost after next system reboot as they are stored in volatile memory. # iptables-save > /etc/iptables.rules Above command will activate previously saved IPTables rules when system reboots making the changes permanent. Credits: Mr. Mahesh Doijade (TechDarting.com)
When you install Ubuntu Server 18.04, it will grab a dynamically assigned IP address from your DHCP server, But you cannot run a server with dynamic IP addresses. So it's important to assign a permanent static IP address in place right away.
When it comes to Ubuntu network interface configuration, the way in which you set a static IP has completely changed. The previous LTS version Ubuntu 16.04 used /etc/network/interfaces file to configure static IP addresses, but Ubuntu 18.04 use new method known as netplan.
In this tutorial we will learn how to configure network interfaces in Ubuntu server 18.04 Bionic Beaver with netplan. We will look at how to set static IP addresses, default gateway and DNS name servers.
Identify available network interface with ip command
Before configure static IP address, you need to identify the available network interfaces on your Ubuntu server 18.04 and what is the device ID assigned to a particular network interface.
If you run ip link show command it will list all available network interfaces on your server.
To view current IP configuration, run the ip addr command:
The output will display the currently assign IP configuration for all network interfaces.
Netplan and YAML format interface configuration file
the way in which you set a static IP has completely changed. Ubuntu 18.04 uses a new method called netplan. In netplan the interface configuration file resides in the /etc/netplan directory and configuration file have .yaml extension. YAML syntax is very easy to understand and you don't need to be an expert on yaml format to edit the interface file. You only need to know what is needed for the network configuration.
If you list the content of the /etc/netplan directory, you will see the interface configuration file with yaml extension.
In my Ubuntu server name of the file is 50-cloud-init.yaml, but it could be saved with a different name depends on the Install Type.
On my Ubuntu server content of the file looks like following:
By just looking at the last line: 'dhcp4: yes', we can say that the ethernet interface enp0s3 has been configured to lease IP address from the DHCP Server. So this the configuration you need to have if you are planning to assign dynamic IP addresses from a DHCP server.
Assigning static IP addresses (IPv4)
Here is the sample netplan configuration file with static IP Assignment (IPV4), In this configuration, interface enp0s3 has been configured with IP 192.168.1.100 and the default gateway of 192.168.1.1.
In order to apply the configuration, run the netplan command:
Then, run the ip add command to make sure that the changes being applied:
How it works.
In the above example, we configured enp0s3 ethernet interface to use static the IP address 192.168.1.100.
The first line:'version: 2' indicate this configuration block use netplan version 2 format.
The next line: 'renderer: networkd' tells that this interface is managed by the systemd-networkd service.
An alternative option to networkd is NetworkManager, if the interface is managed by the NetworkManager. If you looked at the netplan config file of the Ubuntu 18.04 desktop, the renderer option is set to NetworkManager, because in a graphical desktop environment interfaces are managed by the NetworkManager.
Next, we start the interface configuration:
Here, enp0s3 is the name of the interface, you can run ip link show command to list network interfaces on your Ubuntu server.
Next, we set the static IP to 192.168.1.100 with the netmask of 24:
The address option can be also defined in following format:
Next, we set the default gateway to 192.168.1.1:
We used the option gateway4 because this is IPv4 gateway, For IPv6 gateway we need to use gateway6 option.
Next, we set the DNS servers to 8.8.8.8 and 4.4.4.4.
To apply new interface configurations, we run the netplan command :
The command will Apply current netplan config to running system. We no longer need to do network restart to apply changes.
Configure static IPv6 Addresses on Ubuntu Server
The same netplan format use to assign IPv6 address, only difference is , we need to use the gateway6 option instead of gateway4 .
Assign multiple IP addresses to a single network interface
It is very common to have a single network interface configured with more that one IP address. Following is the sample Ubuntu netplan config file with two IPv4 address assigned to one network interface.
The address option can be also written in following format:
A single network interface can be configured with both IPv4 and IPv6 addresses as shown in the following netplan file:
Configure Multiple network interfaces
It is very common to install more that one network interface on a single server. Here's an example netplan file, configured with static addresses for two network cards:
Note that only the primary interface has been configured with a default gateway, In this case it is enp0s3. It is not practical to have more than one default gateway, the default gateway is the address you send traffic when you have no other route for it.
Let's look at another netplan example where both static and DHCP addresses being used:
In the preceding example, the wifi interface wlp3s0 has been configured to lease IP address from the DHCP server.
Summary
In this tutorial we learned how to configure static IP address on Ubuntu 18.04 Bionic Beaver, where the old /etc/network/interfaces file is no longer in used. Ubuntu 18 now uses the new method called netplan to manage networking.
With Netplan, configuration files for the network interfaces reside in the /etc/netplan directory, in YAML data format, while the netplan command uses to restart networking after configuration changes.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |