Find the interface name on which system address is configured on solaris 10 - solaris-10

When I check ifconfig -a command on Solaris 10, I get a list of interfaces configured.
However my requirement is, I need the interface name on which my system address is configured.
Ex. my IP is 1.2.3.4 How can I check if on which interface this Ip is configred.
Also I dont have an Ip address of system. I just need to find interface on which system Ip is configured.
Thanks in avance

One way to go about this is to examine your /etc/hostname.interface files. One of these will contain the hostname. You may only have one, but if you are using IPMP you'll have others and if you're on multiple networks you'll have more.
Example of a solaris 10 host with an IPMP pair for the front-end and an IPMP pair for the back-end:
#ls -C1 /etc/hostname.*
/etc/hostname.e1000g0
/etc/hostname.e1000g1
/etc/hostname.e1000g2
/etc/hostname.e1000g3
#cat /etc/hostname.*
myhostname netmask + broadcast + group ipmp_fe up
group ipmp_fe up
myhostname-nfs netmask + broadcast + group ipmp_be up
group ipmp_be up
Each interface with an IP address will have a hostname in the corresponding /etc/hostname.interface file which corresponds to an entry in /etc/hosts. A simple shell script can parse this out for you. In the example above, this host is using IPMP so you have 2 extra files which do not contain the hostname.
There are other ways to configure solaris networking but the above is how it's been done for a long time and likely how it's done on your system.

Related

Force .NET to use a Certain IP when Connecting to MYSQL

I have a situation, where I have a computer with multiple IP's, the computers primary IP will never change, but all the secondary IP's will.
I connect to a remote MYSQL computer and I have access granted based on my IP address. Sometimes, my PC likes to select one of the secondary IP's.
I looked in to the "Set As Source" flag and tested that solution, but what happens is, that I can't select those extra IP's for outbound communication.
Dim IPS As IPAddress() = Dns.GetHostAddresses(Dns.GetHostName())
Any IP with the "set as source" = false - won't be returned with the above code.
So how would I get around this dilemma? I can't seem to find a solution, with socket progamming I can bind any IP I want, but I don't see a way to do this with a mySQL connection.
Anyway, I was able to accomplish this by adding a second NIC on the Server and putting the single IP on 1 NIC and all the other IP's on the second NIC. Then putting in a route that forces the traffic through the Primary NIC interface to MySQL.
Without two NICS, you can't select which IP it uses, But with two you can assign the routes to either NIC (Interface).

How mariadb resolves user's hostname?

I am using MariaDB on Linux RedHat and running Java App. I am interested in how DB resolves user hostname because I want to use user#localhost instead of user#127.0.0.1.
The name resolution in Linux is done in the resolver library. The main functions are gethostbyname() and gethostbyaddr(). In the /etc/nsswitch.conf file you can change the search order. You can use the following options:
dns
Use the Domain Name System (DNS) service to resolve the address. This mechanism uses the /etc/resolv.conf file.
files
Search in the /etc/hosts and /etc/network files.
nis or nisplus
Use the Network Information System (NIS) to resolve the host or network address.
In oyur case, is almost the same. The relation between 127.0.0.1 and localhost is defined in /etc/hosts

Finding Hostname of MySQL installed on AWS

I am not able to figure out hostname of my MySQL database which is installed on AWS T2 micro server.
I can connect via phpmyadmin. And connecting via PHP code as localhost works ok too.
However can't find hostname or ip which is needed to connect it from service hosted on other server (where localhost won't be an option)
Tried running following
SELECT variable_value FROM global_variables WHERE variable_name = 'hostname'
However the output is ip-172-31-23-11. This doesn't work as hostname when I try to connect.
The output from SELECT variable_value FROM global_variables WHERE variable_name = 'hostname' is showing you the non fully qualified private DNS name.
This should be fine to connect to this instance from the same VPC but if you need to connect from outside of the VPC then instead you should use the public DNS. This, as with the private DNS, is shown in the EC2 dashboard under the instance details (and elsewhere).
As an example:
You then also need to consider network controls such as VPC ACLs and Security Groups. Make sure the security group of your instance allows access from the originating IP over 3306 (default MySQL port).
You'll also want to check the bind-address in /etc/my.cnf to either allow connections specifically from certain addresses as well as localhost/127.0.0.1 or simply remove or comment out the line to allow MySQL to listen to all incoming traffic.
If the application you're trying to connect to the DB with lives on another server, you'll need to get either the public DNS, public IP address, or create an entry in DNS (Route53) that points "database.example.com" into your public IP/DNS name. You can then use one of those as the connection string within the app.
depending on settings, you may also have to follow some of the instructions here.
you might need to bind mysql to listen on the hosts network interface in order to get outside connectivity.
I suggest using telnet to figure that out. if you can't connect (via the command: "telnet 54.4.54.4 5432" (where 54.4.54.4 is your public ip/DNS/route53 entered hostname) then you need to check your security group as well and make sure port 5432 is open to connections from where you're trying to telnet from.

elasticsearch multiple nic bind network interfaces

introduction
when configuring elasticsearch I ran into a problem with binding the
listening interfaces.
somehow the documentation does not provide how to setup multiple network interfaces (network def and bind def)
problem description
my intention is to setup the network.bind_host as _eth1:ipv4_ and _local_
even when trying to setup the bind_host as _local_ only,
the elastic search port 9200 is still only reachable by eth1 (of course i have restarted the server)
solutions tried
i have tested the firewall configuration by setting up a netcat server and this one works perfectly for that port
so this results in 2 Questions:
how to configure multiple nics? (whats the notation?)
would i require to change the network.publish_host ?!
.
any other pointers?
current configuration:
network.bind_host: _eth1:ipv4_
network.publish_host: _eth1:ipv4_
network.host: _eth1:ipv4_
also tested configuration:
network.bind_host: _local_
network.publish_host: _eth1:ipv4_
network.host: _local_
PS:
afaik the publish_host is the nic for the inter-server communication
Using a YAML list for the desired property:
network.bind_host:
- _local_
- _en0:ipv4_
If I understand this answer correctly, publish_host should be _eth1:ipv4_. Your publish_host has to be a one of the interfaces to which elasticsearch binds via the bind_host property.
The above linked answer is actually great, so I have to cite it here:
"bind_host" is the host that an Elasticsearch node uses in the socket
bind call when starting the network. Due to socket programming model,
you can "bind" to an address. By referencing an "address", the socket
allows access to one or all underlying network devices. There are
several addresses with predefined semantics, e.g. 0.0.0.0 is reserved
for "bind to all network devices". So the "bind_host" address does not
necessarily reflect a single unique address.
"publish_host" must be a single unique network address. It is used for
connect calls by other nodes, not for socket bind call by the node
itself. By using "publish_host" all nodes and clients can be sure they
can connect to this node. Declaring this single unique address to the
outside can be interpreted as "publishing", so it is called
"publish_host".
You can not set "bind_host" and "publish_host" to arbitrary values,
the values must adhere to the underlying socket model.

samba - remote connection

I have a samba-server. Can connect to it from my local network with no problem.
Can see that 139 and 445 port are opened. Site "speed-tester.info" also tells me that these ports are opened.
BUT when I scan my server nmap doesnt show me these ports!
have this string in smb.conf, so samba should listen external interface:
interfaces = lo0 msk*
I tried to add "\\89.179.246.174\disk_1" to my network in windows 7 but it failed.
Please help. What is wrong?
I was tired trying to connect my samba shares to my pc remotely.
So I found for myself 2 other solutions:
Use expandrive (binds drive to explorer over ssh, but ssh slows down connection)
Use hamachi
pipitas, thanks anyway!
First, your line interfaces = lo0 msk* does not look right to me. I've never come across an OS that names its NIC devices with a 'msk*' convention.
Second, get aware of the correct syntax for the interfaces = ... statement in smb.conf. Here is my summary of it:
... may hold one or several network interface names
... may hold one or several IP addresses
... may hold one or several hostnames
... may hold one or several IPaddress/netmask pairs
... may hold one or several broadcast/netmask pairs
... may hold a mixture of all of the above
More details to be found in man smb.conf. Assuming that 89.179.246.174 is the address of your Samba server, the following should do what you want:
interfaces = lo0 89.170.246.174