2004年10月8日

Reminders in MySQL

1. Fix Chinese issue in MySQL
# vi /etc/my.cnf
// [myqld]
// default-character-set = big5
// [client]
// default-character-set = big5

2. Note port number while using mysql_real_connect()
// mysql_real_connect(&mysql, DB_IP, DB_USER, DB_PW, DB_NAME, DB_PORT, NULL, 0)
// DB_PORT=3306

3. To get the last day of every month
// (To_DAYS(DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH),\'%%Y-%%m-01\'))-TO_DAYS(DATE_FORMAT(CURDATE(),\'%%Y-%%m-01\')))

4. When configuring permission, the HOST field could be left as blank to prevent database connection failure.

2004年1月27日

Simple Router/NAT Settings

1. If there is no DHCP service, configure WAN/LAN IP manually.
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
ifconfig eth1 10.0.0.100 netmask 255.255.255.0 broadcast 10.0.0.255
2.Add routing rule if needed.
route add –net 192.168.1.0 netmask 255.255.255.0 dev eth0
route add –net 10.0.0.0 netmask 255.255.255.0 dev eth1
3. Add a default gateway IP.
route add default gw 10.0.0.1
4. Enable forwarding.
echo "1" > /proc/sys/net/ipv4/ip_forward
5. Set a simple NAT rule thru iptables tool. eth1 is output interface.
iptables –t nat –A POSTROUTING –o eth1 –s 192.168.1.0/24 –j MASQUERADE
6. Add DNS servers.
echo "168.95.1.1" > /etc/resolv.conf