Know CentOS7 IP address - centos

I just installed CentOS on my VM, I want to know his IP address to be able to connect.
When I'm doing ip addr:
I get this:
[root#localhost]# ip addr
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
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 42:01:0a:f0:7e:a4 brd ff:ff:ff:ff:ff:ff
My IP address is not displayed.

You can use
make sure your system connect with network
# ip address show
OR SIMPLY
# ip a s
However, it is still possible to use the old-fashioned ifconfig command. Thus our objective is to install ifconfig on CentOS 7 Linux which is a part of net-tools package.

Related

Docker: Accessing to a mysql container from another container in same host (No route to host error)

I have a virtual machine with this IP: 10.23.23.23
On this VM, Docker is running and 2 containers are created:
Container1 (Apache running) : This container exposes the port 13080 and bin the port 80 of apache inside the container
Container2 (mysql) : This container exposes the port 5555 and bind the port 3306 of mysql inside the container.
In Container1, i am trying to access to container2, but i get the following error: SQLSTATE[HY000] [2002] No route to host
Notes:
The following command on VM host:
ip addr show docker0
returns:
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 02:42:cf:7e:ea:b7 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::41:cfff:fe7e:eab7/64 scope link
valid_lft forever preferred_lft forever
What can i do to be able to join the second container (mysql) from the first one ?
This seems to be IP:PORT exposing issue. If you want to refer containers using host IP make sure mysql is listening on all the IPs i.e 0.0.0.0 in the container and then give it a try using host ports.
Normally these issues occur when services in the container are running at localhost/127.0.0.1.

Bluetooth PAN connection - ARP not working

My setup is an embedded device that is going to be accessed from a tablet (could be Android or iOS-based).
The device is accessed via Bluetooth and it implements the PAN profile (NAP role), such that the tablet sees it as a device through which it can access the internet.
I use DBus to register a NAP server with Bluez. This works fine, and Bluez creates a network interface named 'bnep0' when the tablet connects.
I have configured the bnep0 interface in /etc/network/interfaces:
iface bnep0 inet static
address 10.254.239.1
netmask 255.255.255.0
post-up service isc-dhcp-server start
pre-down service isc-dhcp-server stop
I use udev to bring the interface up/down using the a rule defined in /etc/udev/rules.d/50-bnep.rules:
ACTION=="add", KERNEL=="bnep0" SUBSYSTEM=="net", RUN+="/sbin/ifup bnep0"
ACTION=="remove", KERNEL=="bnep0", SUBSYSTEM=="net", RUN+="/sbin/ifdown bnep0"
As you can see, I use interface up/down events to start/stop a DHCP server that provides an IP address to the tablet.
My DHCP server is configured by the following lines in /etc/dhcp/dhcpd.conf:
subnet 10.254.239.0 netmask 255.255.255.0 {
range 10.254.239.2 10.254.239.254;
}
As a side note, I also create a network bridge br0 in /etc/network/interfaces. That is required by Bluez in order to register a NAP interface:
iface br0 inet manual
bridge_ports none
bridge_fd 0
bridge_stp off
All this works fine. The tablet will perform Bluetooth pairing with my device and connect successfully. I can also observe that the tablet queries my device's DHCP server and gets assigned the address 10.254.239.2
On my device, I get the output from command 'ip addr show':
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 5c:e0:c5:af:7b:f6 brd ff:ff:ff:ff:ff:ff
inet6 fe80::984d:cdff:fe4b:65be/64 scope link
valid_lft forever preferred_lft forever
9: bnep0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN group default qlen 1000
link/ether 5c:e0:c5:af:7b:f6 brd ff:ff:ff:ff:ff:ff
inet 10.254.239.1/24 brd 10.254.239.255 scope global bnep0
valid_lft forever preferred_lft forever
inet6 fe80::5ee0:c5ff:feaf:7bf6/64 scope link
valid_lft forever preferred_lft forever
I then launch an application on my embedded device, which opens a TCP server socket on address 10.254.239.1, port 15137. The application listens for incoming connections from the tablet.
Now I attempt to open a TCP client socket from the tablet to IP address 10.254.239.1. I can observe (using wireshark) that interface bnep0 receives ARP requests for IP address 10.254.239.1. But my device does not generate any ARP response, and the tablet application will time out when attempting to connect the TCP socket :-(
Likewise, if I try to ping the tablet from my embedded device, I observe that my device sends ARP requests for 10.254.239.2 to which the tablet responds normally. But it is as if the ARP response is not received by the device, because it does not send any ping request afterwards.
Thus, the symptom is that incoming ARP packets on interface bnep0 are not processed.
I really cannot understand what I am missing. Can any of you help me?
As it turned out, the problem was my own lack of understanding of how a network bridge works.
I found the very informative HOWTO Persistently bridge traffic between two or more Ethernet interfaces (Debian), which clearly states that once a network interface has been added to a bridge, it cannot be used as an endpoint for IP traffic.
Thus, what I needed to do was to change the setup of my network interfaces in /etc/network/interfaces such that the bridge becomes the IP endpoint:
iface br0 inet static
address 10.254.239.1
netmask 255.255.255.0
bridge_ports none
bridge_fd 0
bridge_stp off
Note that the section for bnep0 can be completely omitted.
Also thanks to ELinux - Bluetooth Network for inspiration.

Configure multicast group address on CentOs, and set multi devices to join this group address

all, i have 3 computers hosted on the same LAN with CentOs 6.5 OS installed, and i want to configure a specific Multicast Group IP address for own purpose, rather than the default 224.0.0.1; then add the all computers NIC to the group address. Anyone could tell me how to configure it? the hosts basic configuration is as below:
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:4B:B6:29
inet addr:192.168.2.5 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe4b:b629/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
# cat config-2.6.32-504.30.3.el6.x86_64|grep MULTICAST
CONFIG_IP_MULTICAST=y
Thanks in advance and looking forward your help.

How to restart my network properly after binding two ips with single nic in debian?

I have binded two ips with single nic (Network Interface Card) in debian this way.
step 1:
vim /etc/network/interfaces into the following format:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
auto eth0:1
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
Now 192.168.1.100 and 192.168.1.100 are all binded with my local nic.
step2:
vim /etc/network/ifstate into the following format:
lo=lo
eth0=eth0
eth0:1=eth0:1
It is time to restart my network now.
/etc/init.d/networking restart
[....] Running /etc/init.d/networking restart is deprecated because it may not r[warnble some interfaces ... (warning).
[....] Reconfiguring network interfaces...RTNETLINK answers: File exists
Failed to bring up eth0.
Ignoring unknown interface eth0:1=eth0:1.
done.
ifdown eth0 && ifup eth0
ifdown: interface eth0 not configured
RTNETLINK answers: File exists
Failed to bring up eth0.
The two ip have been binded with single NIC when to reboot my pc.
I want to know the proper way to restart networking not to reboot it.
Typically to stop/start/restart the network interface on Debian:
/etc/init.d/networking stop
/etc/init.d/networking start
/etc/init.d/networking restart
To verify changes after making changes and restarting:
ifconfig -a
https://wiki.debian.org/Bonding

PXE dhcp route issue

I have PXE running on Centos 6.x. I am trying to image a server with 4 nics. eth0, eth1, eth2, eth3.
eth0 and eth1 are on the network segment that the pxe server is on. I also using this pxe server to serve up files required for the build process via a webserver.
When DHCP hands out an IP address, it does so for all the interfaces, eth0 eth1 eth2 and eth3. It also hands out a default gateway. The default gateway gets configured on eth3. This is wrong as eth3 is not connected to the network where the web server is and it cannot pull down it's files from the webserver.
the address range I am using in PXE is 192.168.20.0/24 gw 192.168.20.1. How can I get PXE DHCP to set the default gateway 192.168.20.1 on eth0 and not eth3
here is the route table
Destination Gateway Genmask Flags Metric Ref Use IFace
192.168.20.0 * 255.255.255.0 U 0 0 0 eth3
192.168.20.0 * 255.255.255.0 U 0 0 0 eth2
192.168.20.0 * 255.255.255.0 U 0 0 0 eth1
192.168.20.0 * 255.255.255.0 U 0 0 0 eth0
127.0.0.1 * 255.255.255.0 U 0 0 0 lo
default 192.168.20.1 0.0.0.0 UG 0 0 0 eth3
here is my dhcp config
ddns-update-style interim;
not authoritative;
option domain-name "mydomain.com";
option domain-name-servers 192.168.20.15;
option subnet-mask 255.255.255.0;
subnet 192.168.20.0 netmask 255.255.255.0 {
authoritative;
range 192.168.20.220 192.168.20.245;
option routers 192.168.20.1;
default-lease-time 900;
max-lease-time 1200000000;
allow unknown-clients;
allow booting;
allow bootp;
next-server 192.168.20.15;
filename "pxelinux.0";
}
Any ideas how I get the default gateway to be on eth0 so I can route properly?
Thanks - Oli
You said on question:
server with 4 nics. eth0, eth1, eth2, eth3. ...
eth0 and eth1 are on the network segment that the pxe server is on. ...
then on the answer:
another DHCP server that was issuing DHCP leases on the network that eth2 and eth3
So basically both segments DHCP servers provide same GW IP. It means that all your NIC's are on the same IP subnet 192.168.20.0/24.
Change your subnet setup.
I had another DHCP server that was issuing DHCP leases on the network that eth2 and eth3 was connected to. This interfered with the routes and caused eth0 and eth1 routing problems. I stopped the DHCP service on the network eth 2 and eth3 were on and everything was fine after that

Resources