May
26
2009
Hello,
The last days I keep trying to configure my server. I know how to configure the network to this:
MODEM -> (eth0) Servidor (eth1) -> (LAN Port) Router (LAN Ports) -> Computers
This topology don`t work for me, because in this way I lost one WAN Port. So I thought in this topology:
MODEM -> (eth0) Servidor (eth1) -> (Porta WAN) Router (Portas LAN) -> Computadores
First of all configure your eth1 manyally as (edit /etc/network/interfaces):
auto eth1
iface eth1 inet static
address 192.168.100.254
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255
After this I add this iptables rules:
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING –out-interface eth0 -j MASQUERADE
iptables -A FORWARD –in-interface eth0 -j ACCEPT
I need to setup the router manually:
IP Address : 192.168.100.1
Subnet Mask : 255.255.255.0
ISP Gateway Address : 192.168.100.254
Primary DNS Address : 200.247.141.11 (DNS)
Secondary DNS Address : 200.247.141.12 (DNS)
So up and running
Matheus
May
24
2009
Hello,
Today I will just recomment to you the post of Juliano Martins about how o install Ubuntu from pendrive.
UPDATE: In the last days I tried the tool from Ubuntu (USB Startup Disk Creaator) and it works!
Best Regards,
Matheus
May
20
2009
Good night,
To install ssh server in Ubuntu use:
$ sudo apt-get install openssh-server
To let it safer edit /etc/ssh/sshd_config
$ sudo vi /etc/ssh/sshd_config
Than change the lines:
AllowUsers USER
AllowGroups GROUP_USER
PasswordAuthentication yes
MaxStartups 2:100:2
Port XXX # Change the port
What MaxStartups do? Specify the number of un authenticated connections in server. The syntax is start:percent:max. Example: 10:50:20. When it gets to 10 connections it will start with the percent. So every new connection will have 50% of chance to be automaticlly refused. When it gets to 20. It will denied ALL the new connections.
If you want, you can ask for a second password, if you type it wrong, it will close the connection:
Edit /home/user/.profile
echo Put your password
read senha
if [ $senha == "SOMETHING" ]
then
# CODES THAT ALREADY ARE AT .profile
else
exit
fi
With this you can do some tricks, to create a new RANDOM password every time somebody connect and send it to your e-mail. So you will need to put your normal password, than access your e-mail account, verify the new password and type it.
Best Regards,
Matheus
References:
Desabilitar Comando SU
Informação MaxStartups
May
19
2009
Good Night,
This is a simple tip, how to execute some file in computer startup. (I used this tip to enable the port forward on startup)
Copy your file to /etc/init.d/ using “cp file /etc/init.d/file”
Edit /etc/rc.local (as root) and add the file that you want to execute. You must use the full path like /etc/init.d/file.sh for example.
The file must have execution permissions, do this using “chmod +x /etc/init.d/file.sh”
Matheus
PS: You must add the line before “exit 0″ in rc.local
May
18
2009
Good afternoon,
If you want to forward ports to a virtualmachine in VirtualBox you should do this:
Create an interface “tap”
#sudo tunctl -u $USER
Set the tap address:
#sudo ip addr add 192.168.0.20/32 dev tap0
# sudo ip link set tap0 up
Enable Ip Forward
# sudo sysctl net.ipv4.ip_forward=1
Add route:
#sudo route add -host 192.168.0.150 dev tap0
Create nat:
# sudo iptables –flush
#sudo iptables -t nat –flush
#sudo iptables -t nat -A POSTROUTING –out-interface eth1 -j MASQUERADE
#sudo iptables -A FORWARD –in-interface eth1 -j ACCEPT
Redirecting port 3333 to 3389:
#iptables -t nat -A PREROUTING -i eth1 -p tcp -d 192.168.0.100 –dport 3333 -j DNAT –to 192.168.0.150:3389
eth1 – Ethernet connected to the router.
192.168.0.150 – IP of virtualmachine
192.168.0.20 – IP of tap
192.168.0.100 – IP of my real machine that receive the connections in 3333
After this configure manually your virtualmachine to:
IP: 192.168.0.150
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.0.100
I had problems with ‘–’ so here is a file with the commands: Forward ports to a virtualmachine.
Hope this is usefull,
Matheus
References:
IPtables Tutorial
IPTables Port Redirect
VirtualBox, com nat
VBoxManage Port Forward
May
16
2009
Good night,
A few days ago I created a XML-RPC server to test some functions. What is XML-RPC? XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism.(wikipedia) To start using XML-RPC in Java I used apache xml-rpc.
Example client and server XML-RPC.
Best Regards,
Matheus
May
14
2009
Hello,
Today in class one of my teachers was using Windows 7 as your “main” operational system. He said “Windows 7 never crashed”. So i decided to try it too in VirtualBox.
You have to access Microsoft Windows 7 page. Download the version you want to use. You will have to fill a form and then you will receibe a mail confirmation. When you confirm it you will be able to access a page with the link location and your cd-key.
Open your Virtual box go to “New”, choose a name. Change the options to Windows, version Windows 7 (32/64). Create, set the memory size. Create a new Virtual HardDisk. (I used 15GB). Start it, choose the image file and start the installation.
(Installation is so easy, i will not comment it here.)
Matheus
PS: I know I haven’t published regularly in the last days, but I’m sick (flu) and I’m testing some stuff that take a lot of time like IPV6.
May
13
2009
Hey,
Just a fast tip, if you want to have a ssh server more secure disable root access in “/etc/ssh/sshd_config”
Find the line starting with PermitRootLogin and set it to nojust like this:
PermitRootLogin no.
I already setup my ubuntu server, and have infos about ssh and other configurations. I’m translating the old articles to english first, so don’t get angry if I take a little time to post it. I hope in the next month the portuguese version and the english, start to run together
Bye,
Matheus
May
09
2009
Good Night,
Here I will show you how to create your own url shortener.
First of all you need to create a table like this:
CREATE TABLE IF NOT EXISTS `urls` (
`uid` int(11) NOT NULL auto_increment,
`url` text default NULL,
`unique_chars` varchar(25) BINARY NOT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `unique_chars` (`unique_chars`)
);
This code was taken from Abhise in this post “Create your own tinyurl with php and mySQL” that was my bigest reference, from it I took some functions and update other ones to be more efficient. For an example I changed the field to BINARY so it be CASE SENSITIVE (aaaa different from AAAA)
The Abhise says to create many files, I particularly, created one file with all functions where I add all the functions and just called the functions in the files.
Read more »
Tags: apache, como fazer, howto, little url, mod_rewrite, MySQL, php, programação, tinyurl
Aprendendo, MySQL, php | Matheus (X-warrior) Bratfisch |
Comments (7)
May
07
2009
Hello,
A few weeks ago I had a test of Concurrent programming (INE5410), where I had to implement a RankSort in Pascal FC. In this problem we have a Vector that must be order by N process. After the test the professor send us an resolution that I will put here.
- RankSort implementation in Pascal FC.
- Pascal FC editor for windows
Best Regards,
Matheus