How do i staticly assign a ip in CentOS7 - linux

Trying to follow the guides online but i have no ifcfg-Eth0 or ensp3? or what ever all i have i ifcfg-lo and the contents look nothing like https://www.youtube.com/watch?v=5Hwv6OcfazI https://i.imgur.com/bxovaJ1.png also been trying to assign ip in Ubuntu 18.04 which doesn't use ect/network/interface no more it uses Netplan and even after i edit that and apply it i never have internet access. why on earth is linux so difficult to give addresses, i also tried the GUI way but i can never get online after. Is it something to do with Vmware?

You must add nic to your VM and centos must have driver for this nic. After that you can ask a question in "Unix & Linux Stack Exchange" (how to configure network connection in centos7) or try to configure it youself.
I recommend to do something like:
[root#centos7]# nmcli con show
NAME UUID TYPE DEVICE
enp0s3 d77bd8ad-ec13-4442-bb2b-ccee7a697552 ethernet enp0s3
[root#centos7minimal network-scripts]# nmcli con mod "enp0s3" ipv4.address "192.168.1.2/25, 192.168.1.3/32" ipv4.gateway "192.168.1.1" ipv4.dns "192.168.1.1, 8.8.8.8"
[root#centos7minimal network-scripts]# nmcli con up enp0s3
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)

Related

How to access a raspberry pi localhost from a linux?

I set up a php file in my raspberry pi so that I can access some files on it from my local network.
Within raspbian, it works well in any browser using localhost/test. I tested it also in a Windows and a Mac computer in the same network, using my.local.ip.address/test in my browsers and it also worked fine.
Now here is the problem: in my linux computer, it does not work. It simply says that "the site cannot be reached". I already tried disabling the firewall (UFW) but it doesn't change anything.
I also tried several browsers in linux and the result is the same.
I think I am overseeing something obvious but I cannot see it.
Could someone give me a pointer on what might be wrong?
ifconfig -a output (Linux machine)
ifconfig -a output (Raspberry Pi machine)
It's possible that your Ubuntu machine is not in the same network. You can try theses steps to confirm :
Ping
Go on your ubuntu machine and type :
ping <rasp.pi.local.ip.address>
Go on your Raspberry Pi and type :
ping <ubuntu.local.ip.address>
If the ping request do not succeed your machines are probably in different networks. Your can use this command to watch the path used by packets between your ubuntu machine and your Raspberry Pi :
traceroute <rasp.pi.local.ip.address>
Change network card settings
Before this step, check if your are able to connect your machines togather (switch, router, vlan...).
ifconfig <interface> down
ifconfig <interface> <ip.network> netmask <netmask.network>
ifconfig <interface> up
After completing theses steps try to ping again and access to your website.

How to set static IP address using connman for wifi network

I'm trying to set a static IP(manual, no dhcp) address for wifi network using connmanctl. I'm running angstrom linux.
I get the following:
connmanctl
connmanctl> config wifi_"HASH"_managed_psk --ipv4 manual 192.168.10.2 255.255.255.0 192.168.10.1
Error wifi_"HASH"_managed_psk: Not supported
anyone has an idea how to do it?
Instead of editing settings under /var/lib/connman/wifi_<HASH>_managed_psk/, one should edit the config file /var/lib/connman/service-name.config instead.
e.g.
debian#beaglebone:/var/lib/connman$ sudo cat wifi.config
[service_home]
Type = wifi
Name = yyyyyyyyy
Security = wpa
Passphrase = xxxxxxxxxx
IPv4=192.168.1.4/255.255.255.0/192.168.1.254
IPv6=off
Nameservers=8.8.8.8,8.8.4.4
For details, refer to the man page connman-service.config
I managed to get a static IP address by manually creating a file named "settings" inside the directory:
/var/lib/connman/wifi_<HASH>_managed_psk/
with the following content:
[wifi_<HASH>_managed_psk]
Name=<SSID> ←Name of the network
SSID=544f52414445585f4252 ←Name of the network in hexadecimal format
Favorite=true
IPv4.method=manual ←Method to be used (in this case manual IP)
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.0.133 ←Desired IP address
IPv4.gateway=192.168.0.1
Passphrase=<PASS> ←Wifi network password
AutoConnect=true
then activated and connected to the wifi
connmanctl enable wifi
connmanctl connect wifi_<HASH>_managed_psk
Try connmanctl enable wifi then you should be able to configure it
once you install connman then it create configuration directory in /var/lib/connman where devices like wifi ,Ethernet etc. configuration file is created. in those file there is entry like :
[service_wifi_<HASH>_managed_psk]
Type = wifi
Name = <SSID>
Passphrase = <PASSPHRASE>
IPv4.method=dhcp
open that file and see given name is correct that you are using in command
connmanctl config wifi_"HASH"_managed_psk --ipv4 manual 192.168.10.2 255.255.255.0 192.168.10.1
if other than wifi_"HASH"_managed_psk then use that . or you can see by using command connmanctl services

How to configure internet on CentOS installation on VirtualBox

I am a beginner to linux. I have done the fresh installation of CentOS 7 on my Windows VirtualBox.
Over the tutorials for CentOs 6 they have mentioned to edit /etc/sysconfig/network-scripts/ifcfg-eth0 file for the configurations.
But in my installation there is no such file. I have ifcfg-enp0s3 and ifcfg-lo files available.
From the CentOS tutorial, the eth0 portion of /etc/sysconfig/network-scripts/ifcfg-eth0 refers to the network interface. eth0 is the most common name for a standard ethernet interface in Linux. From your question, your system has two interfaces: enp0s3 and lo. lo is the loopback interface, so ignore that one. That leaves enp0s3.
Go ahead and follow the instructions with /etc/sysconfig/network-scripts/ifcfg-enp0s3. It should work, assuming that interface doesn't have any weird quirks associated with it.
Same here! I installed CentOS 7 in Windows7 Virtulabox, there is no eth0, but enp0s3.
After first reboot, used command ip addr, enp0s3 had no ip address
bundled;
Then I updated /etc/sysconfig/network-scripts/ifcfg-enp0s3, changed ONBOOT=no to ONBOOT=yes, enp0s3 had ip 10.x.x.x, still useless;
Then I updated /etc/sysconfig/network-scripts/ifcfg-enp0s3 according to the accepted answer of centos minimal installation static ip address, it works!
As my IP address of Ethernet adapter VirtualBox Host-Only Network is 192.168.56.1, I set 192.168.56.35 to enp0s3, and my vbox NIC mode is Host-Only.
Type nmtui in the terminal
Go to 'edit connection' and hit enter
Select 'enp0s3' and hit enter
Go down to 'Automatically connect' using down arrow key
Press space bar
Go down and press hit enter on 'Ok'
Go back and quit
It worked for me like this on windows 10 -Change Adapter 1 Name to "Remote NDIS based Internet Sharing Device"

scan and connect to wifi from linux terminal on virtual machine

I am trying to scan wifi networks via Linux terminal running on a virtual machine. I am running virtual machine on Mac OS. On MAC terminal, I can see all WIFI networks using (airport) command and can connect to one network.
The NetworkAdapter setting for Vistual machine is set to "Share with MAC".
On Linux terminal, When I do ifconfig -a, I get
eth0 & lo
However, when I type : sudo iwlist eht0 scan , I get error message:
sudo iwlist eht0 scan
Can someone help that how I can do that with Linux running on virtual machine ? ? What I am doing wrong . .
On every VM I've ever seen, the virtual machine emulates the WiFi interface of the host OS (Mac) as an ordinary wired interface to the guest OS (Linux). Therefore you can't scan for WiFi networks from the Linux, because as far as it's concerned, it's not a WiFi interface.
The exception to this would be if you attached a USB WiFi adapter and had the guest OS natively recognize it as a USB device (meaning it would be ignored by the host OS). Note this may not work on some virtual machines; VirtualBox is particuarly bad at recongizing network adapters.
well if you:
nmcli dev wifi
it will show you all the wireless access points (ESSID) available then you can
nmcli dev wifi connect $ESSID password $PASSWORD
example
nmcli dev wifi connect "School Hotspot" password "q5w4e3r2t1y0"
That kinda thang :-)

How to access Raspberry PI QEMU VM via network

I have successfully setup a Raspberry PI VM on my Mac OS X via QEMU. Now I want to access the filesystem of this VM from my Mac.
When I call ifconfig on my VM I get this.
And here the content of my /etc/network/interfaces file
On my Mac
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 3c:07:54:65:da:50
inet6 fe80::3e07:54ff:fe65:da50%en0 prefixlen 64 scopeid 0x4
inet6 fdbf:a879:6730::3e07:54ff:fe65:da50 prefixlen 64 autoconf
inet6 fdbf:a879:6730::401e:56f5:f2f9:a236 prefixlen 64 autoconf temporary
inet 192.168.1.119 netmask 0xffffff00 broadcast 192.168.1.255
nd6 options=1<PERFORMNUD>
media: autoselect (1000baseT <full-duplex,flow-control>)
status: active
I think the reason is, that the VM uses some kind of Shared Network. Is there a way that the VM get the IP address from my router?
The easier method - less flexible but you don't need to muck around so much
They way you have configured qemu appears to be the default host NAT network (aka. qemu -net nic -net user configuration)
By default, your host (your Mac in this case) will be found on 10.0.2.2 when accessed from your guest. From inside your guest you can connect to services on your host (your MAC) at 10.0.2.2. But this is using NAT, so you can't go back the other way as easily.
For example, if you decide to you want to connect to the SSH service and a web server running inside your guest, you will need to start qemu with modified options like the following:
qemu -net nic -net user,hostfwd=tcp::2222-:22,hostfwd=tcp::22280-:80
What this will do is route connections from port 22280 on your host (your MAC) to port 80 inside your qemu guest, (same for port 2222 --> port 22 in the guest)
Which means you can browse to http://localhost:22280 on your Mac, to get to the web server in your virtual Raspberry Pi, etc.
FTP and SMB will be more complicated to setup this way because of the different ports used and they way they are used, etc. although if you setup FTP to use PASV mode it wont be too much of a problem.
The more complicated method
This involves doing what you suggested, configuring the virtual machine quest to be able to get an IP address from your router. In this case, you need to make a bridge from your virtual machine onto your hosts network.
This requires a lot more setup than can be quickly explained here, but essentially, you need to assign your NIC to a vlan and add a tap interface, for example:
qemu -net nic,vlan=0 -net tap,ifname=tap0
This however requires more setup on the host (initially, manual, as you figure out your own situation, but then, scriptable) to create a bridge and tap interface - which usually requires root access beyond that needed to simply run qemu. A bit of Googling brings up a variety of methods to do this, because it varies more depending on your setup. (I found an example setup script here: https://gist.github.com/EmbeddedAndroid/6572715 )
Note - network MAC addresses, network card models, etc. and other qemu options omitted for clarity.
The SAMBA method
Note: I have only tried this under Linux
You can enable a samba server inside qemu:
qemu -smb /path/to/files
This creates a SMB share accessible from inside the guest at \10.0.2.4\qemu mapped from /path/to/files on the host.
If you are happy to use SFTP/SCP then IMO the easiest thing to do is to install openssh-server on your Pi guest:
sudo apt-get update && sudo apt-get install openssh-server
When you launch your Pi VM use the -redir switch when your launch your QEMU guest to redirect port 22 (SSH/SFTP/SCP) e.g.
qemu <other-qemu-switches-options-etc> -redir tcp:2222::22
You can then connect to your VM SFTP/SCP (or SSH) via port 2222 on your host machine. So from your host you can use localhost; from other machines on your LAN you can use :2222
[update 2019] As noted by #ChristophBimminger in a comment, in newer versions of QEMU the -redir switch has been deprecated/removed. The way to achieve this same thing is now via the -net or -netdev switches. Please check the man page, e.g. Debian testing (I don't currently have a QEMU running so can't give a definitive example).

Resources